-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathmain.tf
42 lines (42 loc) · 1.34 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# https://docs.aws.amazon.com/glue/latest/dg/set-up-vpc-dns.html
resource "aws_vpc" "this" {
cidr_block = "10.20.20.0/26"
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc#enable_dns_support
enable_dns_support = true
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc#enable_dns_hostnames
enable_dns_hostnames = true
tags = {
"Name" = "app-1"
}
}
resource "aws_subnet" "public" {
count = length(var.subnet_cidr_public)
vpc_id = aws_vpc.this.id
cidr_block = var.subnet_cidr_public[count.index]
availability_zone = var.availability_zone[count.index]
tags = {
"Name" = "app-1-public-${count.index + 1}"
}
}
resource "aws_route_table" "this-rt" {
vpc_id = aws_vpc.this.id
tags = {
"Name" = "app-1-route-table"
}
}
resource "aws_route_table_association" "public" {
count = length(var.subnet_cidr_public)
subnet_id = element(aws_subnet.public.*.id, count.index)
route_table_id = aws_route_table.this-rt.id
}
resource "aws_internet_gateway" "this-igw" {
vpc_id = aws_vpc.this.id
tags = {
"Name" = "app-1-gateway"
}
}
resource "aws_route" "internet-route" {
destination_cidr_block = "0.0.0.0/0"
route_table_id = aws_route_table.this-rt.id
gateway_id = aws_internet_gateway.this-igw.id
}