AWS Elastic Load Balancing V2 LB

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

aws_lb (Terraform)

The LB in Elastic Load Balancing V2 can be configured in Terraform with the resource name aws_lb. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L3
resource "aws_lb" "enabled" {
  internal           = false
  load_balancer_type = "network"
  name               = "nlb"
  subnets            = var.public_subnet_ids

main.tf#L3
resource "aws_lb" "enabled" {
  internal           = false
  load_balancer_type = "application"
  name               = "alb"
  subnets            = var.public_subnet_ids

main.tf#L1
resource "aws_lb" "lb_good_1" {
}

resource "aws_lb" "lb_good_2" {
}

main.tf#L3
resource "aws_lb" "enabled" {
  load_balancer_type = "network"
  name               = "nlb"
  subnets            = var.public_subnet_ids

  access_logs {
lb_test.tf#L12
resource "aws_lb" "lb1" {
  load_balancer_type = "application"
}

resource "aws_alb" "alb1" {
}

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).

Parameters

Explanation in Terraform Registry

Provides a Load Balancer resource.

Note: aws_alb is known as aws_lb. The functionality is identical.

AWS::ElasticLoadBalancingV2::LoadBalancer (CloudFormation)

The LoadBalancer in ElasticLoadBalancingV2 can be configured in CloudFormation with the resource name AWS::ElasticLoadBalancingV2::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 an Application Load Balancer, a Network Load Balancer, or a Gateway Load Balancer.

Frequently asked questions

What is AWS Elastic Load Balancing V2 LB?

AWS Elastic Load Balancing V2 LB is a resource for Elastic Load Balancing V2 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 V2 LB?

For Terraform, the melscoop-test/check, melscoop-test/check and melscoop-test/check source code examples are useful. See the Terraform Example section for further details.