How to Deploy EC2 Instances in Multiple AZs, with a Load Balancer, and SSL Certificate in AWS with Terraform

Guillermo Musumeci
12 min readMay 25, 2022

In this story, we will learn how to build several components to create a good foundation base to deploy high available web applications in AWS.

We will deploy:

  • Amazon Linux EC2 Instances in multiple AZs
  • An Application Load Balancer (ALB) to distribute the load between these EC2
  • ALB Target Group and Listeners for HTTP and HTTPS protocols
  • Register DNS Records in Route 53
  • Create an SSL certificate using AWS Certificate Manager

If you are interested in deploying similar workloads for internal applications (not accessible from the internet), please look at this story → How to Deploy EC2 Instances with an Internal Load Balancer, and ACM SSL Certificate in AWS with Terraform.

Prerequisite #1: AWS Credentials

Before creating our AWS EC2 Instance, we will need AWS Credentials to execute our Terraform code.

The AWS provider offers a few options for providing credentials for authentication:

  • Static credentials
  • Environment variables
  • Shared…

--

--

Guillermo Musumeci

Certified AWS, Azure & GCP Architect | HashiCorp Ambassador | Terraform SME | KopiCloud Founder | ex-AWS | Entrepreneur | Book Author | Husband & Dad of ✌