AWS CloudFormation
User Guide (API Version 2010-05-15)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

AWS::ElasticLoadBalancing::LoadBalancer

The AWS::ElasticLoadBalancing::LoadBalancer type creates a LoadBalancer.

This type supports updates. For more information about updating stacks, see Updating AWS CloudFormation Stacks.

Important

If you update the property values for a listener specified by the Listeners property, AWS CloudFormation will delete the existing listener and create a new one with the updated properties. During the time that AWS CloudFormation is performing this action, clients will not be able to connect to the load balancer.

Syntax

{
   "Type": "AWS::ElasticLoadBalancing::LoadBalancer",
   "Properties": {
      "AppCookieStickinessPolicy" : [ AppCookieStickinessPolicy, ... ],
      "AvailabilityZones" : [ String, ... ],
      "HealthCheck" : HealthCheck,
      "Instances" : [ String, ... ],
      "LBCookieStickinessPolicy" : [ LBCookieStickinessPolicy, ... ],
      "Listeners" : [ Listener, ... ],
      "Policies" : [ ElasticLoadBalancing Policy, ... ],
      "Scheme" : String,
      "SecurityGroups" : [ Security Group, ... ],
      "Subnets" : [ String, ... ]
   }
}

Properties

AppCookieStickinessPolicy

Generates one or more stickiness policies with sticky session lifetimes that follow that of an application-generated cookie. These policies can be associated only with HTTP/HTTPS listeners.

Required: No.

Type: A list of AppCookieStickinessPolicy objects.

AvailabilityZones

The Availability Zones in which to create the load balancer. You can specify either AvailabilityZones or Subnets, but not both.

Required: No.

Type: A list of strings.

HealthCheck

When specified, declares an application health check for the instances.

Required: No.

Type: ElasticLoadBalancing HealthCheck Type.

Instances

Provides a list of EC2 instance IDs for the load balancer.

Required: No.

Type: A list of strings.

LBCookieStickinessPolicy

Generates a stickiness policy with sticky session lifetimes controlled by the lifetime of the browser (user-agent), or by a specified expiration period. This policy can be associated only with HTTP/HTTPS listeners.

Required: No.

Type: A list of LBCookieStickinessPolicy objects.

Listeners

One or more listeners for this load balancer. Each listener must be registered for a specific port, and you cannot have more than one listener for a given port.

Required: Yes.

Type: A list of ElasticLoadBalancing Listener Property Type objects.

Policies

A list of elastic load balancing policies to apply to this elastic load balancer.

Required: No.

Type: A list of ElasticLoadBalancing policy objects.

Scheme

For load balancers attached to an Amazon VPC, this parameter can be used to specify the type of load balancer to use. Specify "internal" to create an internal load balancer with a DNS name that resolves to private IP addresses.

Required: No.

Type: String.

SecurityGroups

Required: No.

Type: A list of security groups assigned to your load balancer within your virtual private cloud (VPC).

Update requires: no interruption

Subnets

A list of subnet IDs in your virtual private cloud (VPC) to attach to your load balancer. You can specify either AvailabilityZones or Subnets, but not both.

Required: No.

Type: A list of strings.

For more information about using Elastic Load Balancing in a VPC, see How Do I Use Elastic Load Balancing in Amazon VPC in the Elastic Load Balancing Developer Guide.

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, it returns the resource name. For example, mystack-myelb-1WQN7BJGDB5YQ.

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

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. This section lists the available attributes and corresponding return values.

CanonicalHostedZoneName

The name of the Route 53 hosted zone that is associated with the load balancer.

Example: mystack-myelb-15HMABG9ZCN57-1013119603.us-east-1.elb.amazonaws.com

CanonicalHostedZoneNameID

The ID of the Route 53 hosted zone name that is associated with the load balancer.

Example: Z3DZXE0Q79N41H

DNSName

The DNS name for the load balancer.

Example: mystack-myelb-15HMABG9ZCN57-1013119603.us-east-1.elb.amazonaws.com

SourceSecurityGroup.GroupName

The security group that you can use as part of your inbound rules for your load balancer's back-end Amazon EC2 application instances.

Example: amazon-elb

SourceSecurityGroup.OwnerAlias

The owner of the source security group.

Example: amazon-elb-sg

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

Examples

A load balancer with a health check

"ElasticLoadBalancer" : {
   "Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
   "Properties" : {
      "AvailabilityZones" : { "Fn::GetAZs" : "" },
      "Instances" : [ { "Ref" : "Ec2Instance1" },{ "Ref" : "Ec2Instance2" } ],
      "Listeners" : [ {
         "LoadBalancerPort" : "80",
         "InstancePort" : { "Ref" : "WebServerPort" },
         "Protocol" : "HTTP"
      } ],
      "HealthCheck" : {
         "Target" : {
            "Fn::Join" : [ "", [ "HTTP:", { "Ref" : "WebServerPort" }, "/" ] ]
         },
         "HealthyThreshold" : "3",
         "UnhealthyThreshold" : "5",
         "Interval" : "30",
         "Timeout" : "5"
      }
   }
}

More examples

Examples of AWS CloudFormation templates can be viewed and downloaded from the AWS CloudFormation Sample Templates. These include:

See Also