AWS Elastic Load Balancing ELB

This page shows how to write Terraform and CloudFormation for Elastic Load Balancing ELB and write them securely.

aws_elb (Terraform)

The ELB in Elastic Load Balancing can be configured in Terraform with the resource name aws_elb. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub

access_logs_enabled.tf#L2
resource "aws_elb" "access_logs_set" {
  availability_zones = [
    "us-east-1a",
    "us-east-1b",
    "us-east-1c"
  ]
access_logs_enabled.tf#L2
resource "aws_elb" "access_logs_set" {
  availability_zones = [
    "us-east-1a",
    "us-east-1b",
    "us-east-1c"
  ]

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Security Best Practices for aws_elb

There are 2 settings in aws_elb that should be taken care of for security reasons. The following section explain an overview and example code.

risk-label

Ensure your ALB blocks unwanted access

It is better to limit accessibility to the minimum that is required for the application to work.

risk-label

Ensure to drop invalid headers at Elastic Load Balancing

It's better to drop them at Elastic Load Balancing. Passing invalid headers to the applications might cause issues like HTTP Request Smuggling.

Review your AWS Elastic Load Balancing settings

You can check if the aws_elb setting in your .tf file is correct in 3 min with Shisho Cloud.

Parameters

Explanation in Terraform Registry

Provides an Elastic Load Balancer resource, also known as a "Classic Load Balancer" after the release of Application/Network Load Balancers.

NOTE on ELB Instances and ELB Attachments: Terraform currently provides both a standalone ELB Attachment resource (describing an instance attached to an ELB), and an ELB resource with instances defined in-line. At this time you cannot use an ELB with in-line instances in conjunction with a ELB Attachment resources. Doing so will cause a conflict and will overwrite attachments.

AWS::ElasticLoadBalancing::LoadBalancer (CloudFormation)

The LoadBalancer in ElasticLoadBalancing can be configured in CloudFormation with the resource name AWS::ElasticLoadBalancing::LoadBalancer. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Parameters

Explanation in CloudFormation Registry

Specifies a Classic Load Balancer.

You can specify the AvailabilityZones or Subnets property, but not both.

If this resource has a public IP address and is also in a VPC that is defined in the same template, you must use the DependsOn attribute to declare a dependency on the VPC-gateway attachment.

Frequently asked questions

What is AWS Elastic Load Balancing ELB?

AWS Elastic Load Balancing ELB is a resource for Elastic Load Balancing of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Elastic Load Balancing ELB?

For Terraform, the stelligent/config-lint and stelligent/config-lint source code examples are useful. See the Terraform Example section for further details.