Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::ElasticLoadBalancingV2::LoadBalancer

The AWS::ElasticLoadBalancingV2::LoadBalancer resource creates an Elastic Load Balancing Application load balancer that distributes incoming application traffic across multiple targets (such as EC2 instances) in multiple Availability Zones. For more information, see the Application Load Balancers Guide.

Note

AWS CloudFormation does not automatically create tags (key–value pairs) for an Elastic Load Balancing Application load balancer. You must use the Tags property to create tags to associate with the load balancer.

Elastic Load Balancing API Reference version 2015-12-01

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

Copy
{ "Type" : "AWS::ElasticLoadBalancingV2::LoadBalancer", "Properties" : { "LoadBalancerAttributes" : [ LoadBalancerAttributes, ... ], "Name" : String, "Scheme" : String, "SecurityGroups" : [ String, ... ], "Subnets" : [ String, ... ], "Tags" : [ Resource Tag, ... ] } }

YAML

Copy
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer" Properties: LoadBalancerAttributes: - LoadBalancerAttributes Name: String Scheme: String SecurityGroups: - String Subnets: - String Tags: - Resource Tag

Properties

LoadBalancerAttributes

Specifies the load balancer configuration.

Required: No

Type: A list of Elastic Load Balancing LoadBalancer LoadBalancerAttributes

Update requires: No interruption

Name

Specifies a name for the load balancer. This name must be unique within your AWS account and can have a maximum of 32 alphanumeric characters and hyphens. A name can't begin or end with a hyphen.

Required: No

Type: String

Update requires: Replacement

Scheme

Specifies whether the load balancer is internal or Internet-facing. An internal load balancer routes requests to targets using private IP addresses. An Internet-facing load balancer routes requests from clients over the Internet to targets in your public subnets.

For valid and default values, see the Scheme parameter for the CreateLoadBalancer action in the Elastic Load Balancing API Reference version 2015-12-01.

Required: No

Type: String

Update requires: Replacement

SecurityGroups

Specifies a list of the IDs of the security groups to assign to the load balancer.

Required: No

Type: List of strings

Update requires: No interruption

Subnets

Specifies a list of at least two IDs of the subnets to associate with the load balancer. The subnets must be in different Availability Zones.

Required: Yes

Type: List of strings

Update requires: No interruption

Tags

Specifies an arbitrary set of tags (key–value pairs) to associate with this load balancer. Use tags to manage your resources.

Required: No

Type: AWS CloudFormation Resource Tags

Update requires: No interruption

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the ARN of the load balancer, for example:

Copy
arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-internal-load-balancer/50dc6c495c0c9188

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt returns a value for the following attributes.

DNSName

The DNS name for the Application load balancer, for example my-load-balancer-424835706.us-west-2.elb.amazonaws.com.

CanonicalHostedZoneID

The ID of the Amazon Route 53 hosted zone associated with the load balancer, for example Z2P70J7EXAMPLE.

LoadBalancerFullName

The full name of the Application load balancer, for example app/my-load-balancer/50dc6c495c0c9188.

LoadBalancerName

The name of the Application load balancer, for example my-load-balancer.

SecurityGroups

The IDs of the security groups for the Application load balancer, for example sg-123456a.

For more information about using Fn::GetAtt, see Fn::GetAtt.

Example

The following example creates an internal load balancer with an idle timeout period of 50 seconds.

JSON

Copy
"loadBalancer" : { "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "Properties": { "Scheme" : "internal", "Subnets" : [ {"Ref": "SubnetAZ1"}, {"Ref" : "SubnetAZ2"}], "LoadBalancerAttributes" : [ { "Key" : "idle_timeout.timeout_seconds", "Value" : "50" } ], "SecurityGroups": [{"Ref": "SecurityGroup1"}, {"Ref" : "SecurityGroup2"}], "Tags" : [ { "Key" : "key", "Value" : "value" }, { "Key" : "key2", "Value" : "value2" } ] } }

YAML

Copy
loadBalancer: Type: AWS::ElasticLoadBalancingV2::LoadBalancer Properties: Scheme: internal Subnets: - Ref: SubnetAZ1 - Ref: SubnetAZ2 LoadBalancerAttributes: - Key: idle_timeout.timeout_seconds Value: '50' SecurityGroups: - Ref: SecurityGroup1 - Ref: SecurityGroup2 Tags: - Key: key Value: value - Key: key2 Value: value2