In this section, you will create an Amazon EC2 application load balancer. This will be the public endpoint to access Trip Management Monolith Application.
The load balancer must use a VPC with two public subnets in different Availability Zones. In these steps, you confirm your default VPC, create a load balancer, and then create two target groups for your load balancer.
You use the same subnet names, and target group values you create with your load balancer, later when you create your Amazon ECS service.
To create an Amazon EC2 application load balancer
Sign in to the AWS Management Console and open the Amazon EC2 console
In the navigation pane, choose Load Balancers, choose Create Load Balancer.
Choose Application Load Balancer, and then choose Create.
In Name, enter the name of your load balancer
In Scheme, choose internet-facing.
In IP address type, choose ipv4.
Configure two listener ports for your load balancer:
Under Availability Zones, in VPC, choose the default VPC. Next, choose two default subnets you want to use. Make a note of subnet ids to use in later part of this tutorial
Choose Next: Configure Security Settings.
Choose Next: Configure Security Groups.
Choose Create new security group,
80port (HTTP) inbound traffic from your IP
8080port (CustomTCPPort) inbound traffic from your IP
Choose Next: Configure Routing.
In Target group, choose New target group and configure your first target group:
Choose Next: Review, and then choose Create.
Go to Load Balancers and click on newly created load balancer. From the Description tab, make a note of the newly created Security Group Id (i.e. sg-xxxxxxxx..) and DNS name of the Load Balancer.
To create a second target group for your load balancer
After your load balancer is provisioned, open the Amazon EC2 console. In the navigation pane, choose Target Groups.
Choose Create target group.
In Target type, choose IP.
In Name, enter a target group name
In Protocol choose HTTP. In Port, enter
In VPC, choose the default VPC.
Note: You must have two target groups created for your load balancer in order for your deployment to run. You only need to make a note of the ARN of your first target group. This ARN is used in the create-service JSON file in the next section.
To update your load balancer to include your second target group
Open the Amazon EC2 console. In the navigation pane, choose Load Balancers.
Choose your load balancer, and then choose the Listeners tab. Choose the listener with port 8080, and then choose Edit.
Choose the pencil icon next to Forward to. Choose your second target group, and then choose the check mark. Choose Update to save the updates.