-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvpc.tf
More file actions
71 lines (59 loc) · 1.7 KB
/
vpc.tf
File metadata and controls
71 lines (59 loc) · 1.7 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# VPC Configuration
resource "aws_vpc" "abnmo_svm_vpc" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "${var.project_name}-vpc"
Projeto = var.project_name
Ambiente = "shared"
}
}
# Internet Gateway
resource "aws_internet_gateway" "abnmo_svm_igw" {
vpc_id = aws_vpc.abnmo_svm_vpc.id
tags = {
Name = "${var.project_name}-internet-gateway"
}
}
# Public Subnets
resource "aws_subnet" "public_subnet_a" {
vpc_id = aws_vpc.abnmo_svm_vpc.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-east-1a"
map_public_ip_on_launch = true
tags = {
Name = "${var.project_name}-public-subnet-a"
Type = "public"
}
}
resource "aws_subnet" "public_subnet_b" {
vpc_id = aws_vpc.abnmo_svm_vpc.id
cidr_block = "10.0.2.0/24"
availability_zone = "us-east-1b"
map_public_ip_on_launch = true
tags = {
Name = "${var.project_name}-public-subnet-b"
Type = "public"
}
}
# Route Table for Public Subnets
resource "aws_route_table" "public_route_table" {
vpc_id = aws_vpc.abnmo_svm_vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.abnmo_svm_igw.id
}
tags = {
Name = "${var.project_name}-public-route-table"
}
}
# Route Table Associations
resource "aws_route_table_association" "public_subnet_a_association" {
subnet_id = aws_subnet.public_subnet_a.id
route_table_id = aws_route_table.public_route_table.id
}
resource "aws_route_table_association" "public_subnet_b_association" {
subnet_id = aws_subnet.public_subnet_b.id
route_table_id = aws_route_table.public_route_table.id
}