diff options
| author | Paul Buetow <paul@buetow.org> | 2023-12-20 11:14:23 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-12-20 11:14:23 +0200 |
| commit | 594190ae05b6500f4f76201409748f4e455880c7 (patch) | |
| tree | 2506552ce7d80ad81e1701dc236f8dcd89bea065 /org-buetow-base | |
| parent | 520a02aa0cb03a812edd086407e7587f5f769437 (diff) | |
refactor
Diffstat (limited to 'org-buetow-base')
| -rw-r--r-- | org-buetow-base/efs.tf | 27 | ||||
| -rw-r--r-- | org-buetow-base/network.tf | 78 | ||||
| -rw-r--r-- | org-buetow-base/outputs.tf | 24 | ||||
| -rw-r--r-- | org-buetow-base/variables.tf | 5 | ||||
| -rw-r--r-- | org-buetow-base/zone.tf | 2 |
5 files changed, 45 insertions, 91 deletions
diff --git a/org-buetow-base/efs.tf b/org-buetow-base/efs.tf index 7f35d41..0e916ec 100644 --- a/org-buetow-base/efs.tf +++ b/org-buetow-base/efs.tf @@ -1,32 +1,28 @@ -resource "aws_efs_file_system" "my_self_hosted_services_efs" { - creation_token = "my-self-hosted-services-efs" +resource "aws_efs_file_system" "self_hosted_services_efs" { + creation_token = "self-hosted-services-efs" encrypted = true - - tags = { - Name = "${var.environment}-my-self-hosted-services-efs" - } } resource "aws_efs_mount_target" "efs_mt_a" { - file_system_id = aws_efs_file_system.my_self_hosted_services_efs.id - subnet_id = aws_subnet.my_public_subnet_a.id + file_system_id = aws_efs_file_system.self_hosted_services_efs.id + subnet_id = aws_subnet.public_subnet_a.id security_groups = [aws_security_group.efs_self_hosted_services_sg.id] } resource "aws_efs_mount_target" "efs_mt_b" { - file_system_id = aws_efs_file_system.my_self_hosted_services_efs.id - subnet_id = aws_subnet.my_public_subnet_b.id + file_system_id = aws_efs_file_system.self_hosted_services_efs.id + subnet_id = aws_subnet.public_subnet_b.id security_groups = [aws_security_group.efs_self_hosted_services_sg.id] } resource "aws_efs_mount_target" "efs_mt_c" { - file_system_id = aws_efs_file_system.my_self_hosted_services_efs.id - subnet_id = aws_subnet.my_public_subnet_c.id + file_system_id = aws_efs_file_system.self_hosted_services_efs.id + subnet_id = aws_subnet.public_subnet_c.id security_groups = [aws_security_group.efs_self_hosted_services_sg.id] } resource "aws_security_group" "efs_self_hosted_services_sg" { - vpc_id = aws_vpc.my_vpc.id # Replace with your VPC ID + vpc_id = aws_vpc.vpc.id # Replace with your VPC ID ingress { from_port = 2049 # NFS port @@ -41,9 +37,4 @@ resource "aws_security_group" "efs_self_hosted_services_sg" { protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } - - tags = { - Name = "efs-sg" - Name = "${var.environment}-efs-sg" - } } diff --git a/org-buetow-base/network.tf b/org-buetow-base/network.tf index f4414a3..d32f8ca 100644 --- a/org-buetow-base/network.tf +++ b/org-buetow-base/network.tf @@ -1,86 +1,62 @@ -resource "aws_vpc" "my_vpc" { +resource "aws_vpc" "vpc" { cidr_block = "10.0.0.0/16" # Specify your CIDR block enable_dns_support = true enable_dns_hostnames = true - - tags = { - Name = "${var.environment}-my-vpc" - } } -resource "aws_internet_gateway" "my_igw" { - vpc_id = aws_vpc.my_vpc.id - - tags = { - Name = "${var.environment}-my-igw" - } +resource "aws_internet_gateway" "igw" { + vpc_id = aws_vpc.vpc.id } -resource "aws_subnet" "my_public_subnet_a" { - vpc_id = aws_vpc.my_vpc.id +resource "aws_subnet" "public_subnet_a" { + vpc_id = aws_vpc.vpc.id cidr_block = "10.0.1.0/24" availability_zone = "eu-central-1a" map_public_ip_on_launch = true - - tags = { - Name = "${var.environment}-my-public-subnet-a" - } } -resource "aws_subnet" "my_public_subnet_b" { - vpc_id = aws_vpc.my_vpc.id +resource "aws_subnet" "public_subnet_b" { + vpc_id = aws_vpc.vpc.id cidr_block = "10.0.2.0/24" availability_zone = "eu-central-1b" map_public_ip_on_launch = true - - tags = { - Name = "${var.environment}-my-public-subnet-b" - } } -resource "aws_subnet" "my_public_subnet_c" { - vpc_id = aws_vpc.my_vpc.id +resource "aws_subnet" "public_subnet_c" { + vpc_id = aws_vpc.vpc.id cidr_block = "10.0.3.0/24" availability_zone = "eu-central-1c" map_public_ip_on_launch = true - - tags = { - Name = "${var.environment}-my-public-subnet-c" - } } -resource "aws_route_table" "my_route_table" { - vpc_id = aws_vpc.my_vpc.id +resource "aws_route_table" "route_table" { + vpc_id = aws_vpc.vpc.id route { cidr_block = "0.0.0.0/0" - gateway_id = aws_internet_gateway.my_igw.id - } - - tags = { - Name = "${var.environment}-my-route-table" + gateway_id = aws_internet_gateway.igw.id } } resource "aws_route_table_association" "a" { - subnet_id = aws_subnet.my_public_subnet_a.id - route_table_id = aws_route_table.my_route_table.id + subnet_id = aws_subnet.public_subnet_a.id + route_table_id = aws_route_table.route_table.id } resource "aws_route_table_association" "b" { - subnet_id = aws_subnet.my_public_subnet_b.id - route_table_id = aws_route_table.my_route_table.id + subnet_id = aws_subnet.public_subnet_b.id + route_table_id = aws_route_table.route_table.id } resource "aws_route_table_association" "c" { - subnet_id = aws_subnet.my_public_subnet_c.id - route_table_id = aws_route_table.my_route_table.id + subnet_id = aws_subnet.public_subnet_c.id + route_table_id = aws_route_table.route_table.id } resource "aws_security_group" "allow_ssh" { name = "allow_ssh" description = "Allow SSH inbound traffic" - vpc_id = aws_vpc.my_vpc.id + vpc_id = aws_vpc.vpc.id ingress { from_port = 22 @@ -88,16 +64,12 @@ resource "aws_security_group" "allow_ssh" { protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } - - tags = { - Name = "${var.environment}-allow-ssh" - } } resource "aws_security_group" "allow_web" { name = "allow_http" description = "Allow HTTP inbound traffic" - vpc_id = aws_vpc.my_vpc.id + vpc_id = aws_vpc.vpc.id ingress { from_port = 80 @@ -119,16 +91,12 @@ resource "aws_security_group" "allow_web" { protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } - - tags = { - Name = "${var.environment}-allow_web" - } } resource "aws_security_group" "allow_outbound" { name = "allow_outbound" description = "Allow outbound traffic" - vpc_id = aws_vpc.my_vpc.id + vpc_id = aws_vpc.vpc.id egress { from_port = 0 @@ -136,8 +104,4 @@ resource "aws_security_group" "allow_outbound" { protocol = "-1" # -1 means all protocols cidr_blocks = ["0.0.0.0/0"] # Allows outbound traffic to all IP addresses } - - tags = { - Name = "${var.environment}-allow-outbound" - } } diff --git a/org-buetow-base/outputs.tf b/org-buetow-base/outputs.tf index e846cf3..ea0ed87 100644 --- a/org-buetow-base/outputs.tf +++ b/org-buetow-base/outputs.tf @@ -1,21 +1,21 @@ -output "my_self_hosted_services_efs_id" { - value = aws_efs_file_system.my_self_hosted_services_efs.id +output "self_hosted_services_efs_id" { + value = aws_efs_file_system.self_hosted_services_efs.id } -output "my_vpc_id" { - value = aws_vpc.my_vpc.id +output "vpc_id" { + value = aws_vpc.vpc.id } -output "my_public_subnet_a_id" { - value = aws_subnet.my_public_subnet_a.id +output "public_subnet_a_id" { + value = aws_subnet.public_subnet_a.id } -output "my_public_subnet_b_id" { - value = aws_subnet.my_public_subnet_b.id +output "public_subnet_b_id" { + value = aws_subnet.public_subnet_b.id } -output "my_public_subnet_c_id" { - value = aws_subnet.my_public_subnet_c.id +output "public_subnet_c_id" { + value = aws_subnet.public_subnet_c.id } output "allow_ssh_sg_id" { @@ -30,6 +30,10 @@ output "allow_outbound_sg_id" { value = aws_security_group.allow_outbound.id } +output "aws_buetow_org_zone_id" { + value = aws_route53_zone.aws_buetow_org.zone_id +} + output "aws_buetow_org_certificate_arn" { value = "arn:aws:acm:eu-central-1:634617747016:certificate/4ae442c0-3b56-4e17-9a3f-023faf39d244" } diff --git a/org-buetow-base/variables.tf b/org-buetow-base/variables.tf deleted file mode 100644 index 20fd78c..0000000 --- a/org-buetow-base/variables.tf +++ /dev/null @@ -1,5 +0,0 @@ -variable "environment" { - description = "The production environment" - type = string - default = "production" -} diff --git a/org-buetow-base/zone.tf b/org-buetow-base/zone.tf index 18db3ab..49816df 100644 --- a/org-buetow-base/zone.tf +++ b/org-buetow-base/zone.tf @@ -1,3 +1,3 @@ -resource "aws_route53_zone" "my_zone" { +resource "aws_route53_zone" "aws_buetow_org" { name = "aws.buetow.org." } |
