Deploying a new service behind an ALB, configuring the ALB, adding a cert with ACM, and configuring DNS

In my previous example, I didn't use a load balancer, and could only assign a DNS record to the auto-assigned public IP. I also couldn't put a cert in front of my app, or redirect 80 to 443.

My flask app running on ECS

To test, call my Amazon Connect phone number: 1-845-318-2265

Github Link

Responsive image

Create a new service using the load balancer option

In the ECS Service Load balancing options, I created an Application Load Balancer, and also created a new listener and target group. The target group listens on port 80 and routes to port 5000 for my Flask app.

Once the ALB was deployed, I added an additional listener on the ALB for HTTPS traffic, and configured it to forward to the target group I previously created in the ECS service deployment. I also attached my ACM cert in the 'Secure listener settings' for this Listener. I also needed to modify the first listener for HTTP/80 traffic, and configured it to 'Redirect' HTTP/80 traffic to HTTPS/443.

Configuring the 443 listener:

Responsive image

Configuring the port 80 listener to redirect:

Responsive image

Add DNS A record for ALB

The last step was straight forward, and I just needed to add an A record for connect.joshweepie.com, configure it to route traffic to the 'Alias to Application and Classic Load Balancer' option, and select my ALB.

Responsive image