Setup hello-world app in a secure network which is served via the aws load-balancer.
- Creates VPC with 10.1.0.0/16 cidr block
- A route table is created which routes all traffic to internet gateway
- Two subnets are created with 10.1.1.0/24 and 10.1.4.0/24 cidr block and it is associated with previously created route table
- A NAT gateway is created for private subnets
- A route table is created which routes all traffic to NAT gateway
- A private subnet with cidr block 10.1.2.0/24 and associated with previously created route table
A t2.micro instance is created in a private subnet with a user data which installs docker and starts the app on port 80. A security group is attached which allows incoming traffic to public subnets and outgoing to internet.
-
Creates an application load balancer with following security groups
- allows incoming traffic to port 80
- allows outgoing traffic to private subnet range
-
Creates a target group A with port 80 with healthcheck path
-
Attaches target group A with t2.micro instance in which app is deployed
-
Adds a listener rule to foward the incoming requests to target group A
-
Install awscli via brew
-
Create an IAM access keys with full access to EC2 and VPC and configure with your awscli client
Run
aws configure
and set region to ap-south-1 -
Run
terraform init
to initializes all the plugins and modules -
Run
terraform plan
to check the resources to be created -
Run
terraform apply
to setup the complete infrastructure and to deploy the application