mirror of
https://codeberg.org/scottslowe/learning-tools.git
synced 2026-03-11 09:04:37 +00:00
Commit a set of files that show the use of modules Signed-off-by: Scott Lowe <scott.lowe@scottlowe.org>
36 lines
1.2 KiB
HCL
36 lines
1.2 KiB
HCL
# Create a new VPC
|
|
resource "aws_vpc" "vpc" {
|
|
cidr_block = "${var.vpc_cidr_block}"
|
|
enable_dns_hostnames = "${var.vpc_dns_hostnames}"
|
|
enable_dns_support = "${var.vpc_dns_support}"
|
|
}
|
|
|
|
# Create a public subnet in the new VPC
|
|
resource "aws_subnet" "subnet" {
|
|
vpc_id = "${aws_vpc.vpc.id}"
|
|
cidr_block = "${var.subnet_cidr_block}"
|
|
map_public_ip_on_launch = "${var.subnet_map_pub_ip}"
|
|
}
|
|
|
|
# Create a new Internet gateway
|
|
resource "aws_internet_gateway" "gateway" {
|
|
vpc_id = "${aws_vpc.vpc.id}"
|
|
}
|
|
|
|
# Create a route table for the new VPC
|
|
resource "aws_route_table" "routes" {
|
|
vpc_id = "${aws_vpc.vpc.id}"
|
|
}
|
|
|
|
# Create a route in new route table
|
|
resource "aws_route" "default_route" {
|
|
route_table_id = "${aws_route_table.routes.id}"
|
|
destination_cidr_block = "0.0.0.0/0"
|
|
gateway_id = "${aws_internet_gateway.gateway.id}"
|
|
}
|
|
|
|
# Associate route table with subnet in VPC
|
|
resource "aws_route_table_association" "rte_tbl_assoc" {
|
|
subnet_id = "${aws_subnet.subnet.id}"
|
|
route_table_id = "${aws_route_table.routes.id}"
|
|
}
|