How to create one Application Load Balancer with internal network and 2 instances EC2 with Terraform
First let’s set up our provider:
This is the backend states from terraform where is going to S3 Bucket:
We creates a new VPC with no GateWay:
We have the configuration for the Application Load Balancer:
We set the AMI that will update and launch configuration of the cluster:
We can see that the load balancer is open to the world on tcp/80 and tcp/443 and the ECS EC2 instances have ports 32768 to 65535 open from the load balancer. This is because when we select the container port to 0 in the task definition AWS will randomly assign a port from this range to the container:
We have our variables file where I am using CentOS 7 AMI :
We add terraform.tfvars for access and secret key.