
If you are not familiar with AWS Application Load Balancers, check out my article FreeKB - Amazon Web Services (AWS) - Getting Started with Application Load Balancer (ALB).
Let's say you have two or more EC2 instances that are producing web apps. An application load balancer can be used to load balance the requests for the web app.
The aws elbv2 create-listener command can be used to create a Listener, using the Amazon Resource Number (ARN) of the Load Balancer and the ARN of the Target Group. So let's first use the aws elbv2 describe-load-balancers command to get the ARN of the Load Balancer that you want to create an HTTP Listener on.
~]$ aws elbv2 describe-load-balancers
{
"LoadBalancers": [
{
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/my-application-load-balanacer/af699b53c6c024d9",
And then use the aws elbv2 describe-target-groups command to get the ARN of the Target Group that will be associated with the Listener.
~]$ aws elbv2 describe-target-groups
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/my-target-group/af5707bbd67c69ab",
Then the aws elbv2 create-listener command can be used to create the listener.
aws elbv2 create-listener \
--load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/my-application-load-balanacer/af699b53c6c024d9 \
--protocol HTTP \
--port 80 \
--default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/my-target-group/af5707bbd67c69ab
Did you find this article helpful?
If so, consider buying me a coffee over at