-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathvpc.tf
35 lines (35 loc) · 880 Bytes
/
vpc.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
resource "aws_vpc" "this" {
cidr_block = var.vpc_cidr
tags = {
"Name" = "${var.name}"
}
}
resource "aws_subnet" "public" {
vpc_id = aws_vpc.this.id
cidr_block = var.subnet_cidr_public
availability_zone = "us-east-2a"
tags = {
"Name" = "${var.name}-public"
}
}
resource "aws_route_table" "this-rt" {
vpc_id = aws_vpc.this.id
tags = {
"Name" = "${var.name}-route-table"
}
}
resource "aws_route_table_association" "public" {
subnet_id = aws_subnet.public.id
route_table_id = aws_route_table.this-rt.id
}
resource "aws_internet_gateway" "this-igw" {
vpc_id = aws_vpc.this.id
tags = {
"Name" = "${var.name}-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
}