Automating the application load balancer using Terraform
In the last section, we created an application load balancer using the AWS console. In this section, we will see how to automate the entire process using Terraform. These are the steps you need to follow:
- It always starts with boilerplate syntax where you specify the provider (for example, AWS in our case) and the region (such as
us-west-2
in Oregon) where you want to create your resource:provider "aws" {Â Â region = "us-west-2"}
- In the next step, we are going to create the application load balancer. Here, we will use the Terraform
aws_alb
resource to create an application load balancer. To create an application load balancer, we need to pass the following parameters to theaws_alb
resource:-
name
: The name of your load balancer. Please provide some meaningful name (for example,prod-alb-new-lb
), otherwise Terraform will autogenerate a name beginning withtf-lb
.-
subnets
: These are the...