diff options
Diffstat (limited to 'playground/ec2-instance-test/network.tf')
| -rw-r--r-- | playground/ec2-instance-test/network.tf | 60 |
1 files changed, 14 insertions, 46 deletions
diff --git a/playground/ec2-instance-test/network.tf b/playground/ec2-instance-test/network.tf index 94cd9d9..2f9562e 100644 --- a/playground/ec2-instance-test/network.tf +++ b/playground/ec2-instance-test/network.tf @@ -1,54 +1,38 @@ -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" { - vpc_id = aws_vpc.my_vpc.id # Referencing the VPC +resource "aws_subnet" "public_subnet" { + vpc_id = aws_vpc.vpc.id # Referencing the VPC cidr_block = "10.0.1.0/24" # Specify your CIDR block for the subnet availability_zone = "eu-central-1a" # Change to your desired AZ map_public_ip_on_launch = true - - tags = { - Name = "${var.environment}-my-subnet" - } } -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.id - route_table_id = aws_route_table.my_route_table.id + subnet_id = aws_subnet.public_subnet.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 @@ -56,16 +40,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_http" { 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 @@ -73,16 +53,12 @@ resource "aws_security_group" "allow_http" { protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } - - tags = { - Name = "${var.environment}-allow_http" - } } resource "aws_security_group" "allow_https" { name = "allow_https" description = "Allow HTTPS inbound traffic" - vpc_id = aws_vpc.my_vpc.id + vpc_id = aws_vpc.vpc.id ingress { from_port = 443 @@ -90,16 +66,12 @@ resource "aws_security_group" "allow_https" { protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } - - tags = { - Name = "${var.environment}-allow-https" - } } 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 @@ -107,8 +79,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-outnound" - } } |
