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

github-iconmelscoop-test/check
resource "aws_lb" "enabled" {
  internal           = false
  load_balancer_type = "network"
  name               = "nlb"
  subnets            = var.public_subnet_ids

github-iconmelscoop-test/check
resource "aws_lb" "enabled" {
  internal           = false
  load_balancer_type = "application"
  name               = "alb"
  subnets            = var.public_subnet_ids

github-iconmelscoop-test/check
resource "aws_lb" "lb_good_1" {
}

resource "aws_lb" "lb_good_2" {
}

github-iconmelscoop-test/check
resource "aws_lb" "enabled" {
  load_balancer_type = "network"
  name               = "nlb"
  subnets            = var.public_subnet_ids

  access_logs {
github-icongilyas/infracost
resource "aws_lb" "lb1" {
  load_balancer_type = "application"
}

resource "aws_alb" "alb1" {
}

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.

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.