In addition to the usual VPC, IGW, and subnet that we need for Jenkins, we are going to deploy NAT and ELB for our demo-app
web server scenario.
Note
Please refer to https://github.com/PacktPublishing/Implementing-DevOps-on-AWS/blob/master/5585_05_CodeFiles/Terraform/resources.tf.
We start with VPC, IGW, and NAT:
resource "aws_vpc" "terraform-vpc" { cidr_block = "${var.vpc-cidr}" ... resource "aws_internet_gateway" "terraform-igw" { vpc_id = "${aws_vpc.terraform-vpc.id}" } resource "aws_eip" "nat-eip" { vpc = true } resource "aws_nat_gateway" "terraform-nat" { allocation_id = "${aws_eip.nat-eip.id}" subnet_id = "${aws_subnet.public-1.id}" depends_on = ["aws_internet_gateway.terraform-igw"] ...
We add a public
subnet for Jenkins and ELB, plus a private
one to be used by the EC2 web server:
resource "aws_route_table" "public" { vpc_id...