-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
43 lines (36 loc) · 1.22 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
43
provider "aws" {
shared_config_files = ["~/.aws/config"]
shared_credentials_files = ["~/.aws/credentials"]
}
resource "aws_vpc" "fis-vpc" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "public_subnet" {
cidr_block = "10.0.1.0/24"
vpc_id = aws_vpc.fis-vpc.id
}
resource "aws_subnet" "private_subnet" {
cidr_block = "10.0.2.0/24"
vpc_id = aws_vpc.fis-vpc.id
}
// Create an internet gateway to allow the VPC to connect to the internet
resource "aws_internet_gateway" "fis_public_internet_gateway" {
vpc_id = aws_vpc.fis-vpc.id
}
// Create a route table for the public subnet to route traffic to the internet gateway
resource "aws_route_table" "fis_public_subnet_route_table" {
vpc_id = aws_vpc.fis-vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.fis_public_internet_gateway.id
}
route {
ipv6_cidr_block = "::/0"
gateway_id = aws_internet_gateway.fis_public_internet_gateway.id
}
}
// Associate the public subnet with the route table to allow traffic to the internet gateway
resource "aws_route_table_association" "fis_public_association" {
route_table_id = aws_route_table.fis_public_subnet_route_table.id
subnet_id = aws_subnet.public_subnet.id
}