Learn how to manage Network Stack on AWS which consists of VPC resources (subnets, routes, routing tables, NAT gateways, VPC endpoints, etc) using Terraform AWS VPC module published in Terraform Registry.
Integrate VPC with other resources (eg., autoscaling, security group).
- Explore Terraform Registry - https://registry.terraform.io.
- Explore examples of using terraform-aws-vpc module.
- Using terraform-aws-vpc module create VPC for the real scenario (eg, 3 public subnets, 3 private subnets, single NAT gateway).
- Using terraform-aws-autoscaling module create an autoscaling group which will always have 1 EC2 instance running in public subnet. Install and run
nginx
service when instance starts. - Using terraform-aws-security-group module create a security group for EC2 instances where HTTP and SSH ports are open.
Solutions are inside solutions/1-network directory.
-
Extend your solution to make use of Terraform 0.12 expressions and make VPC resources to span across all availability zones available for you (replace hard-coded values in lists with
for
expressions andcidrsubnet()
functions) -
Create SSH key-pair to be able to SSH to instances. Create TLS private key using
RSA
algorithm, and use it to create EC2 key pair. Update launch configurations to launch instances using correctkey_name
. -
Using terraform-aws-elb module create a public-facing Elastic Load Balancer which will stay in front of EC2 instances launched by an autoscaling group.