Elb Ag Application Load Balancer
Elb Ag Application Load Balancer
Elb Ag Application Load Balancer
Table of Contents
What Is an Application Load Balancer? ................................................................................................. 1
Application Load Balancer Components ........................................................................................ 1
Application Load Balancer Overview ............................................................................................. 1
Benefits of Migrating from a Classic Load Balancer ......................................................................... 2
How to Get Started .................................................................................................................... 2
Related Services ......................................................................................................................... 3
Pricing ...................................................................................................................................... 3
Getting Started .................................................................................................................................. 2
Before You Begin ....................................................................................................................... 4
Step 1: Select a Load Balancer Type ............................................................................................. 4
Step 2: Configure Your Load Balancer and Listener ......................................................................... 5
Step 3: Configure a Security Group for Your Load Balancer .............................................................. 5
Step 4: Configure Your Target Group ............................................................................................ 5
Step 5: Register Targets with Your Target Group ............................................................................ 6
Step 6: Create and Test Your Load Balancer .................................................................................. 6
Step 7: Delete Your Load Balancer (Optional) ................................................................................ 6
Tutorials ............................................................................................................................................ 8
Tutorial: Use Path-Based Routing ................................................................................................. 8
Before You Begin ............................................................................................................... 8
Create Your Load Balancer .................................................................................................. 8
Tutorial: Use Microservices as Targets ......................................................................................... 10
Before You Begin ............................................................................................................. 10
Create Your Load Balancer ................................................................................................ 11
Tutorial: Create an Application Load Balancer Using the AWS CLI .................................................... 12
Before You Begin ............................................................................................................. 12
Create Your Load Balancer ................................................................................................ 12
Add an HTTPS Listener ..................................................................................................... 13
Add Targets Using Port Overrides ....................................................................................... 14
Add Path-Based Routing ................................................................................................... 14
Delete Your Load Balancer ................................................................................................ 15
Load Balancers ................................................................................................................................. 16
Subnets for Your Load Balancer ................................................................................................. 16
Load Balancer Security Groups ................................................................................................... 16
Load Balancer State .................................................................................................................. 17
Load Balancer Attributes ........................................................................................................... 17
IP Address Type ....................................................................................................................... 17
Deletion Protection .................................................................................................................. 18
Connection Idle Timeout ........................................................................................................... 18
Application Load Balancers and AWS WAF ................................................................................... 19
Create a Load Balancer ............................................................................................................. 19
Step 1: Configure a Load Balancer and a Listener ................................................................... 5
Step 2: Configure Security Settings for an HTTPS Listener ..................................................... 20
Step 3: Configure a Security Group ..................................................................................... 21
Step 4: Configure a Target Group ......................................................................................... 5
Step 5: Configure Targets for the Target Group .................................................................... 21
Step 6: Create the Load Balancer ....................................................................................... 22
Update Availability Zones .......................................................................................................... 22
Update Security Groups ............................................................................................................ 23
Recommended Rules ......................................................................................................... 23
Update the Associated Security Groups ............................................................................... 24
Update the Address Type .......................................................................................................... 24
Update Tags ............................................................................................................................ 25
Delete a Load Balancer ............................................................................................................. 25
Listeners .......................................................................................................................................... 27
iii
Elastic Load Balancing Application Load Balancers
iv
Elastic Load Balancing Application Load Balancers
v
Elastic Load Balancing Application Load Balancers
Application Load Balancer Components
A listener checks for connection requests from clients, using the protocol and port that you configure,
and forwards requests to one or more target groups, based on the rules that you define. Each rule
specifies a target group, condition, and priority. When the condition is met, the traffic is forwarded to
the target group. You must define a default rule for each listener, and you can add rules that specify
different target groups based on the content of the request (also known as content-based routing).
Each target group routes requests to one or more registered targets, such as EC2 instances, using the
protocol and port number that you specify. You can register a target with multiple target groups. You
can configure health checks on a per target group basis. Health checks are performed on all targets
registered to a target group that is specified in a listener rule for your load balancer.
The following diagram illustrates the basic components. Notice that each listener contains a default rule,
and one listener contains another rule that routes requests to a different target group. One target is
registered with two target groups.
1
Elastic Load Balancing Application Load Balancers
Benefits of Migrating from a Classic Load Balancer
priority order to determine which rule to apply, and then selects a target from the target group for the
rule action. You can configure listener rules to route requests to different target groups based on the
content of the application traffic. Routing is performed independently for each target group, even when
a target is registered with multiple target groups.
You can add and remove targets from your load balancer as your needs change, without disrupting the
overall flow of requests to your application. Elastic Load Balancing scales your load balancer as traffic to
your application changes over time. Elastic Load Balancing can scale to the vast majority of workloads
automatically.
You can configure health checks, which are used to monitor the health of the registered targets so that
the load balancer can send requests only to the healthy targets.
For more information, see How Elastic Load Balancing Works in the Elastic Load Balancing User Guide.
• Support for path-based routing. You can configure rules for your listener that forward requests based
on the URL in the request. This enables you to structure your application as smaller services, and route
requests to the correct service based on the content of the URL.
• Support for host-based routing. You can configure rules for your listener that forward requests based
on the host field in the HTTP header. This enables you to route requests to multiple domains using a
single load balancer.
• Support for routing requests to multiple applications on a single EC2 instance. You can register each
instance or IP address with the same target group using multiple ports.
• Support for redirecting requests from one URL to another.
• Support for returning a custom HTTP response.
• Support for registering targets by IP address, including targets outside the VPC for the load balancer.
• Support for registering Lambda functions as targets.
• Support for the load balancer to authenticate users of your applications through their corporate or
social identities before routing requests.
• Support for containerized applications. Amazon Elastic Container Service (Amazon ECS) can select
an unused port when scheduling a task and register the task with a target group using this port. This
enables you to make efficient use of your clusters.
• Support for monitoring the health of each service independently, as health checks are defined at the
target group level and many CloudWatch metrics are reported at the target group level. Attaching
a target group to an Auto Scaling group enables you to scale each service dynamically based on
demand.
• Access logs contain additional information and are stored in compressed format.
• Improved load balancer performance.
For more information about the features supported by each load balancer type, see Comparison of
Elastic Load Balancing Products.
• Getting Started with Elastic Load Balancing in the Elastic Load Balancing User Guide.
2
Elastic Load Balancing Application Load Balancers
Related Services
• Tutorial: Use Path-Based Routing with Your Application Load Balancer (p. 8)
• Tutorial: Use Microservices as Targets with Your Application Load Balancer (p. 10)
Related Services
Elastic Load Balancing works with the following services to improve the availability and scalability of
your applications.
• Amazon EC2 — Virtual servers that run your applications in the cloud. You can configure your load
balancer to route traffic to your EC2 instances.
• Amazon EC2 Auto Scaling — Ensures that you are running your desired number of instances, even if
an instance fails, and enables you to automatically increase or decrease the number of instances as the
demand on your instances changes. If you enable Auto Scaling with Elastic Load Balancing, instances
that are launched by Auto Scaling are automatically registered with the load balancer, and instances
that are terminated by Auto Scaling are automatically de-registered from the load balancer.
• AWS Certificate Manager — When you create an HTTPS listener, you can specify certificates provided
by ACM. The load balancer uses certificates to terminate connections and decrypt requests from
clients. For more information, see SSL Certificates (p. 33).
• Amazon CloudWatch — Enables you to monitor your load balancer and take action as needed. For
more information, see CloudWatch Metrics for Your Application Load Balancer (p. 68).
• Amazon ECS — Enables you to run, stop, and manage Docker containers on a cluster of EC2 instances.
You can configure your load balancer to route traffic to your containers. For more information, see
Service Load Balancing in the Amazon Elastic Container Service Developer Guide.
• Route 53 — Provides a reliable and cost-effective way to route visitors to websites by translating
domain names (such as www.example.com) into the numeric IP addresses (such as 192.0.2.1) that
computers use to connect to each other. AWS assigns URLs to your resources, such as load balancers.
However, you might want a URL that is easy for users to remember. For example, you can map your
domain name to a load balancer.
• AWS WAF — You can use AWS WAF with your Application Load Balancer to allow or block requests
based on the rules in a web access control list (web ACL). For more information, see Application Load
Balancers and AWS WAF (p. 19).
To view information about services that are integrated with your load balancer, select your load balancer
in the AWS Management Console and choose the Integrated services tab.
Pricing
With your load balancer, you pay only for what you use. For more information, see Elastic Load Balancing
Pricing.
3
Elastic Load Balancing Application Load Balancers
Before You Begin
Tasks
• Before You Begin (p. 4)
• Step 1: Select a Load Balancer Type (p. 4)
• Step 2: Configure Your Load Balancer and Listener (p. 5)
• Step 3: Configure a Security Group for Your Load Balancer (p. 5)
• Step 4: Configure Your Target Group (p. 5)
• Step 5: Register Targets with Your Target Group (p. 6)
• Step 6: Create and Test Your Load Balancer (p. 6)
• Step 7: Delete Your Load Balancer (Optional) (p. 6)
Alternatively, to create a Network Load Balancer, see Getting Started with Network Load Balancers in
the User Guide for Network Load Balancers. To create a Classic Load Balancer, see Create a Classic Load
Balancer in the User Guide for Classic Load Balancers.
4
Elastic Load Balancing Application Load Balancers
Step 2: Configure Your Load Balancer and Listener
The name of your Application Load Balancer must be unique within your set of Application Load
Balancers and Network Load Balancers for the region, can have a maximum of 32 characters, can
contain only alphanumeric characters and hyphens, must not begin or end with a hyphen, and must
not begin with "internal-".
2. For Scheme and IP address type, keep the default values.
3. For Listeners, keep the default, which is a listener that accepts HTTP traffic on port 80.
4. For Availability Zones, select the VPC that you used for your EC2 instances. For each Availability
Zone that you used to launch your EC2 instances, select the Availability Zone and then select the
public subnet for that Availability Zone.
5. Choose Next: Configure Security Settings.
6. For this tutorial, you are not creating an HTTPS listener. Choose Next: Configure Security Groups.
On the Configure Security Groups page, complete the following procedure to have Elastic Load
Balancing create a security group for your load balancer on your behalf.
5
Elastic Load Balancing Application Load Balancers
Step 5: Register Targets with Your Target Group
6
Elastic Load Balancing Application Load Balancers
Step 7: Delete Your Load Balancer (Optional)
7
Elastic Load Balancing Application Load Balancers
Tutorial: Use Path-Based Routing
• Getting Started with Elastic Load Balancing (Elastic Load Balancing User Guide)
• Tutorial: Use Path-Based Routing with Your Application Load Balancer (p. 8)
• Tutorial: Use Microservices as Targets with Your Application Load Balancer (p. 10)
• Tutorial: Create an Application Load Balancer Using the AWS CLI (p. 12)
8
Elastic Load Balancing Application Load Balancers
Create Your Load Balancer
Note that the status of the instances is initial until the instances are registered and have
passed health checks, and then it is unused until you configure the target group to receive
traffic from the load balancer.
5. Create a target group for the second set of targets as follows:
Note that the status of the instances is initial until the instances are registered and have
passed health checks, and then it is unused until you configure the target group to receive
traffic from the load balancer.
6. On the navigation pane, under LOAD BALANCING, choose Load Balancers.
7. Choose Create Load Balancer.
8. For Select load balancer type, choose Application Load Balancer.
9. Choose Continue.
10. Complete the Configure Load Balancer page as follows:
The name of your Application Load Balancer must be unique within your set of Application Load
Balancers and Network Load Balancers for the region, can have a maximum of 32 characters,
can contain only alphanumeric characters and hyphens, and must not begin or end with a
hyphen.
b. For Scheme, an Internet-facing load balancer routes requests from clients over the Internet to
targets. An internal load balancer routes requests to targets using private IP addresses.
c. For Listeners, the default is a listener that accepts HTTP traffic on port 80. You can keep the
default listener settings, modify the protocol or port of the listener, or choose Add to add
another listener.
d. For Availability Zones, select the VPC that you used for your EC2 instances. Select at least two
Availability Zones. If there is one subnet for an Availability Zone, it is selected. If there is more
than one subnet for an Availability Zone, select one of the subnets. Note that you can select
only one subnet per Availability Zone.
e. Choose Next: Configure Security Settings.
11. (Optional) If you created a secure listener in the previous step, complete the Configure Security
Settings page as follows:
a. If you created or imported a certificate using AWS Certificate Manager, select Choose an
existing certificate from AWS Certificate Manager (ACM), and then select the certificate from
Certificate name.
b. If you uploaded a certificate using IAM, select Choose an existing certificate from AWS Identity
and Access Management (IAM), and then select your certificate from Certificate name.
c. If you have a certificate to upload but ACM is not supported in your region, choose Upload a
new SSL Certificate to AWS Identity and Access Management (IAM). For Certificate name,
type a name for the certificate. For Private Key, copy and paste the contents of the private
key file (PEM-encoded). In Public Key Certificate, copy and paste the contents of the public
key certificate file (PEM-encoded). In Certificate Chain, copy and paste the contents of the
certificate chain file (PEM-encoded), unless you are using a self-signed certificate and it's not
important that browsers implicitly accept the certificate.
d. For Select policy, keep the default security policy.
9
Elastic Load Balancing Application Load Balancers
Tutorial: Use Microservices as Targets
a. For Target group name, choose the second target group that you created.
b. For Path pattern specify the exact pattern to be used for path-based routing (for example, /
img/*). For more information, see Listener Rules (p. 28).
c. Choose Save.
10
Elastic Load Balancing Application Load Balancers
Create Your Load Balancer
The name of your Application Load Balancer must be unique within your set of Application Load
Balancers and Network Load Balancers for the region, can have a maximum of 32 characters,
can contain only alphanumeric characters and hyphens, and must not begin or end with a
hyphen.
b. For Scheme, an Internet-facing load balancer routes requests from clients over the Internet to
targets. An internal load balancer routes requests to targets using private IP addresses.
c. For Listeners, the default is a listener that accepts HTTP traffic on port 80. You can keep the
default listener settings, modify the protocol or port of the listener, or choose Add to add
another listener.
d. For Availability Zones, select the VPC that you used for your EC2 instances. Select at least two
Availability Zones. If there is one subnet for an Availability Zone, it is selected. If there is more
than one subnet for an Availability Zone, select one of the subnets. Note that you can select
only one subnet per Availability Zone.
e. Choose Next: Configure Security Settings.
8. (Optional) If you created a secure listener in the previous step, complete the Configure Security
Settings page as follows:
a. If you created or imported a certificate using AWS Certificate Manager, select Choose an
existing certificate from AWS Certificate Manager (ACM), and then select the certificate from
Certificate name.
b. If you uploaded a certificate using IAM, select Choose an existing certificate from AWS Identity
and Access Management (IAM), and then select the certificate from Certificate name.
c. If you have a certificate to upload but ACM is not supported in your region, choose Upload a
new SSL Certificate to AWS Identity and Access Management (IAM). For Certificate name,
type a name for the certificate. For Private Key, copy and paste the contents of the private
key file (PEM-encoded). In Public Key Certificate, copy and paste the contents of the public
key certificate file (PEM-encoded). In Certificate Chain, copy and paste the contents of the
certificate chain file (PEM-encoded), unless you are using a self-signed certificate and it's not
important that browsers implicitly accept the certificate.
d. For Select policy, keep the default security policy.
9. Choose Next: Configure Security Groups.
10. Complete the Configure Security Groups page as follows:
11
Elastic Load Balancing Application Load Balancers
Tutorial: Create an Application
Load Balancer Using the AWS CLI
If you get an error message that elbv2 is not a valid choice, update your AWS CLI. For more
information, see Installing the AWS Command Line Interface in the AWS Command Line Interface User
Guide.
• Launch your EC2 instances in a virtual private cloud (VPC). Ensure that the security groups for these
instances allow access on the listener port and the health check port. For more information, see Target
Security Groups (p. 58).
1. Use the create-load-balancer command to create a load balancer. You must specify two subnets that
are not from the same Availability Zone.
The output includes the Amazon Resource Name (ARN) of the load balancer, with the following
format:
12
Elastic Load Balancing Application Load Balancers
Add an HTTPS Listener
arn:aws:elasticloadbalancing:us-east-2:123456789012:loadbalancer/app/my-load-
balancer/1234567890123456
2. Use the create-target-group command to create a target group, specifying the same VPC that you
used for your EC2 instances:
The output includes the ARN of the target group, with this format:
arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/my-
targets/1234567890123456
3. Use the register-targets command to register your instances with your target group:
4. Use the create-listener command to create a listener for your load balancer with a default rule that
forwards requests to your target group:
The output contains the ARN of the listener, with the following format:
arn:aws:elasticloadbalancing:us-east-2:123456789012:listener/app/my-load-
balancer/1234567890123456/1234567890123456
5. (Optional) You can verify the health of the registered targets for your target group using this
describe-target-health command:
1. Create an SSL certificate for use with your load balancer using one of the following methods:
• Create or import the certificate using AWS Certificate Manager (ACM). For more information, see
Request a Certificate or Importing Certificates in the AWS Certificate Manager User Guide.
• Upload the certificate using AWS Identity and Access Management (IAM). For more information,
see Working with Server Certificates in the IAM User Guide.
2. Use the create-listener command to create the listener with a default rule that forwards requests to
your target group. You must specify an SSL certificate when you create an HTTPS listener. Note that
you can specify an SSL policy other than the default using the --ssl-policy option.
13
Elastic Load Balancing Application Load Balancers
Add Targets Using Port Overrides
2. Use the register-targets command to register your instances with your target group. Notice that the
instance IDs are the same for each container, but the ports are different.
3. Use the create-rule command to add a rule to your listener that forwards requests to the target
group:
2. Use the register-targets command to register your instances with your target group:
3. Use the create-rule command to add a rule to your listener that forwards requests to the target
group if the URL contains the specified pattern:
14
Elastic Load Balancing Application Load Balancers
Delete Your Load Balancer
15
Elastic Load Balancing Application Load Balancers
Subnets for Your Load Balancer
For more information, see How Elastic Load Balancing Works in the Elastic Load Balancing User Guide.
Contents
• Subnets for Your Load Balancer (p. 16)
• Load Balancer Security Groups (p. 16)
• Load Balancer State (p. 17)
• Load Balancer Attributes (p. 17)
• IP Address Type (p. 17)
• Deletion Protection (p. 18)
• Connection Idle Timeout (p. 18)
• Application Load Balancers and AWS WAF (p. 19)
• Create an Application Load Balancer (p. 19)
• Availability Zones for Your Application Load Balancer (p. 22)
• Security Groups for Your Application Load Balancer (p. 23)
• IP Address Types for Your Application Load Balancer (p. 24)
• Tags for Your Application Load Balancer (p. 25)
• Delete an Application Load Balancer (p. 25)
To ensure that your load balancer can scale properly, verify that each subnet for your load balancer has a
CIDR block with at least a /27 bitmask (for example, 10.0.0.0/27) and has at least 8 free IP addresses.
Your load balancer uses these IP addresses to establish connections with the instances.
The rules for the security groups associated with your load balancer security group must allow traffic
in both directions on both the listener and the health check ports. Whenever you add a listener to a
load balancer or update the health check port for a target group, you must review your security group
rules to ensure that they allow traffic on the new port in both directions. For more information, see
Recommended Rules (p. 23).
16
Elastic Load Balancing Application Load Balancers
Load Balancer State
provisioning
access_logs.s3.enabled
Indicates whether access logs stored in Amazon S3 are enabled. The default is false.
access_logs.s3.bucket
The name of the S3 bucket for the access logs. This attribute is required if access logs are enabled.
For more information, see Bucket Permissions (p. 86).
access_logs.s3.prefix
IP Address Type
You can set the IP address type of your Internet-facing load balancer when you create it or after it is
active. Note that internal load balancers must use IPv4 addresses.
ipv4
The load balancer supports only IPv4 addresses (for example, 192.0.2.1)
dualstack
The load balancer supports both IPv4 and IPv6 addresses (for example,
2001:0db8:85a3:0:0:8a2e:0370:7334).
17
Elastic Load Balancing Application Load Balancers
Deletion Protection
Clients that communicate with the load balancer using IPv4 addresses resolve the A record and clients
that communicate with the load balancer using IPv6 addresses resolve the AAAA record. However,
the load balancer communicates with its targets using IPv4 addresses, regardless of how the client
communicates with the load balancer.
For more information, see IP Address Types for Your Application Load Balancer (p. 24).
Deletion Protection
To prevent your load balancer from being deleted accidentally, you can enable deletion protection. By
default, deletion protection is disabled for your load balancer.
If you enable deletion protection for your load balancer, you must disable it before you can delete the
load balancer.
By default, Elastic Load Balancing sets the idle timeout value to 60 seconds. Therefore, if the target
doesn't send some data at least every 60 seconds while the request is in flight, the load balancer can
18
Elastic Load Balancing Application Load Balancers
Application Load Balancers and AWS WAF
close the front-end connection. To ensure that lengthy operations such as file uploads have time to
complete, send at least 1 byte of data before each idle timeout period elapses, and increase the length
of the idle timeout period as needed.
For back-end connections, we recommend that you enable the HTTP keep-alive option for your EC2
instances. You can enable HTTP keep-alive in the web server settings for your EC2 instances. If you
enable HTTP keep-alive, the load balancer can reuse back-end connections until the keep-alive timeout
expires. We also recommend that you configure the idle timeout of your application to be larger than the
idle timeout configured for the load balancer.
To check whether your load balancer integrates with AWS WAF, select your load balancer in the AWS
Management Console and choose the Integrated services tab.
Before you begin, ensure that you have a virtual private cloud (VPC) with at least one public subnet in
each of the Availability Zones used by your targets.
To create a load balancer using the AWS CLI, see Tutorial: Create an Application Load Balancer Using the
AWS CLI (p. 12).
To create a load balancer using the AWS Management Console, complete the following tasks.
Tasks
• Step 1: Configure a Load Balancer and a Listener (p. 5)
• Step 2: Configure Security Settings for an HTTPS Listener (p. 20)
• Step 3: Configure a Security Group (p. 21)
• Step 4: Configure a Target Group (p. 5)
19
Elastic Load Balancing Application Load Balancers
Step 1: Configure a Load Balancer and a Listener
When you use HTTPS for your load balancer listener, you must deploy an SSL certificate on your load
balancer. The load balancer uses this certificate to terminate the connection and decrypt requests from
clients before sending them to the targets. For more information, see SSL Certificates (p. 33). You
must also specify the security policy that the load balancer uses to negotiate SSL connections with the
clients. For more information, see Security Policies (p. 34).
• If you created or imported a certificate using AWS Certificate Manager, select Choose a certificate
from ACM, and then select the certificate from Certificate name.
• If you uploaded a certificate using IAM, select Choose a certificate from IAM, and then select the
certificate from Certificate name.
2. For Security policy, we recommend that you keep the default security policy.
3. Choose Next: Configure Security Groups.
20
Elastic Load Balancing Application Load Balancers
Step 3: Configure a Security Group
To register IP addresses
a. For Network, if the IP address is from a subnet of the target group VPC, select the VPC.
Otherwise, select Other private IP address.
b. For IP, type the IP address.
c. For Port, type the port.
21
Elastic Load Balancing Application Load Balancers
Step 6: Create the Load Balancer
After you disable an Availability Zone, the targets in that Availability Zone remain registered with the
load balancer, but the load balancer will not route requests to them.
22
Elastic Load Balancing Application Load Balancers
Update Security Groups
8. Choose Save.
Recommended Rules
The recommended rules depend on the type of load balancer (Internet-facing or internal).
Inbound
Outbound
instance security health check Allow outbound traffic to instances on the health
group check port
Inbound
VPC CIDR listener Allow inbound traffic from the VPC CIDR on the
load balancer listener port
Outbound
23
Elastic Load Balancing Application Load Balancers
Update the Associated Security Groups
instance security health check Allow outbound traffic to instances on the health
group check port
We also recommend that you allow inbound ICMP traffic to support Path MTU Discovery. For more
information, see Path MTU Discovery in the Amazon EC2 User Guide for Linux Instances.
IPv6 Requirements
24
Elastic Load Balancing Application Load Balancers
Update Tags
You can add multiple tags to each load balancer. Tag keys must be unique for each load balancer. If you
add a tag with a key that is already associated with the load balancer, it updates the value of that tag.
When you are finished with a tag, you can remove it from your load balancer.
Restrictions
To update the tags for a load balancer using the AWS CLI
You can't delete a load balancer if deletion protection is enabled. For more information, see Deletion
Protection (p. 18).
Note that deleting a load balancer does not affect its registered targets. For example, your EC2 instances
continue to run and are still registered to their target groups. To delete your target groups, see Delete a
Target Group (p. 67).
25
Elastic Load Balancing Application Load Balancers
Delete a Load Balancer
1. If you have a CNAME record for your domain that points to your load balancer, point it to a new
location and wait for the DNS change to take effect before deleting your load balancer.
2. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
3. On the navigation pane, under LOAD BALANCING, choose Load Balancers.
4. Select the load balancer, and then choose Actions, Delete.
5. When prompted for confirmation, choose Yes, Delete.
26
Elastic Load Balancing Application Load Balancers
Listener Configuration
Contents
• Listener Configuration (p. 27)
• Listener Rules (p. 28)
• Redirect Actions (p. 29)
• Fixed-Response Actions (p. 30)
• Host Conditions (p. 30)
• Path Conditions (p. 31)
• Create a Listener for Your Application Load Balancer (p. 32)
• HTTPS Listeners for Your Application Load Balancer (p. 33)
• Listener Rules for Your Application Load Balancer (p. 36)
• Update Server Certificates (p. 39)
• Authenticate Users Using an Application Load Balancer (p. 41)
• Delete a Listener for Your Application Load Balancer (p. 46)
Listener Configuration
Listeners support the following protocols and ports:
You can use an HTTPS listener to offload the work of encryption and decryption to your load balancer
so that your applications can focus on their business logic. If the listener protocol is HTTPS, you must
deploy at least one SSL server certificate on the listener. For more information, see HTTPS Listeners for
Your Application Load Balancer (p. 33).
Application Load Balancers provide native support for WebSockets. You can use WebSockets with both
HTTP and HTTPS listeners.
Application Load Balancers provide native support for HTTP/2 with HTTPS listeners. You can send up
to 128 requests in parallel using one HTTP/2 connection. The load balancer converts these to individual
HTTP/1.1 requests and distributes them across the healthy targets in the target group. Because HTTP/2
uses front-end connections more efficiently, you might notice fewer connections between clients and the
load balancer. You can't use the server-push feature of HTTP/2.
For more information, see Request Routing in the Elastic Load Balancing User Guide.
27
Elastic Load Balancing Application Load Balancers
Listener Rules
Listener Rules
Each listener has a default rule, and you can optionally define additional rules. Each rule consists of a
priority, one or more actions, an optional host condition, and an optional path condition.
Default Rules
When you create a listener, you define actions for the default rule. Default rules can't have conditions. If
no conditions for any of a listener's rules are met, then the action for the default rule is performed.
Rule Priority
Each rule has a priority. Rules are evaluated in priority order, from the lowest value to the highest value.
The default rule is evaluated last. You can change the priority of a nondefault rule at any time. You
cannot change the priority of the default rule. For more information, see Reorder Rules (p. 38).
Rule Actions
Each rule action has a type, an order, and information required to perform the action. The following are
the supported action types:
authenticate-cognito
[HTTPS listeners] Use an identity provider that is compliant with OpenID Connect (OIDC) to
authenticate users.
fixed-response
The action with the lowest order value is performed first. The action to be performed last must be a
forward, redirect, or fixed-response action. Each rule must include exactly one of the following
types of actions: forward, redirect, or fixed-response.
You can edit a rule at any time. For more information, see Edit a Rule (p. 37).
Rule Conditions
There are two types of rule conditions: host and path. Each rule can have up to one host condition and
up to one path condition. When the conditions for a rule are met, then its action is performed.
28
Elastic Load Balancing Application Load Balancers
Redirect Actions
Redirect Actions
You can use redirect actions to redirect client requests from one URL to another. You can configure
redirects as either temporary (HTTP 302) or permanent (HTTP 301) based on your needs.
protocol://hostname:port/path?query
You must modify at least one of the following components to avoid a redirect loop: protocol, hostname,
port, or path. Any components that you do not modify retain their original values.
protocol
The protocol (HTTP or HTTPS). You can redirect HTTP to HTTP, HTTP to HTTPS, and HTTPS to
HTTPS. You cannot redirect HTTPS to HTTP.
hostname
The hostname.
port
You can reuse URI components of the original URL in the target URL using the following reserved
keywords:
• #{protocol} - Retains the protocol. Use in the protocol and query components
• #{host} - Retains the domain. Use in the hostname, path, and query components
• #{port} - Retains the port. Use in the port, path, and query components
• #{path} - Retains the path. Use in the path and query components
• #{query} - Retains the query parameters. Use in the query component
For example, the following rule sets up a permanent redirect to a URL that uses the HTTPS protocol and
the specified port (40443), but retains the original hostname, path, and query parameters. This screen is
equivalent to "https://#{host}:40443/#{path}?#{query}".
The following rule sets up a permanent redirect to a URL that retains the original protocol, port,
hostname, and query parameters, and uses the #{path} keyword to create a modified path. This screen
is equivalent to "#{protocol}://#{host}:#{port}/new/#{path}?#{query}".
29
Elastic Load Balancing Application Load Balancers
Fixed-Response Actions
When a redirect action is taken, the action is recorded in the access logs. For more information,
see Access Log Entries (p. 81). The count of successful redirect actions is reported in the
HTTP_Redirect_Count metric. For more information, see Application Load Balancer Metrics (p. 69).
To add a redirect action to an existing rule or create a new rule with a redirect action, see Listener
Rules for Your Application Load Balancer (p. 36).
Fixed-Response Actions
You can use fixed-response actions to drop client requests and return a custom HTTP response. You
can use this action to return a 2XX, 4XX, or 5XX response code and an optional message.
When a fixed-response action is taken, the action and the URL of the redirect target are recorded in
the access logs. For more information, see Access Log Entries (p. 81). The count of successful fixed-
response actions is reported in the HTTP_Fixed_Response_Count metric. For more information, see
Application Load Balancer Metrics (p. 69).
To add a fixed-response action to an existing rule or create a new rule with a fixed-response
action, see Listener Rules for Your Application Load Balancer (p. 36).
Host Conditions
You can use host conditions to define rules that forward requests to different target groups based on the
host name in the host header (also known as host-based routing). This enables you to support multiple
domains using a single load balancer.
Each host condition has one hostname. If the hostname in the host header matches the hostname in a
listener rule exactly, the request is routed using that rule.
A hostname is case-insensitive, can be up to 128 characters in length, and can contain any of the
following characters:
30
Elastic Load Balancing Application Load Balancers
Path Conditions
You can include up to three wildcard characters. You must include at least one "." character. You can
include only alphabetical characters after the final "." character.
Example hostnames
• example.com
• test.example.com
• *.example.com
Console Example
The following is an example of a rule with a host condition as shown in the console. If the hostname in
the host header matches *.example.com, the request is forwarded to the target group named my-
web-servers. For more information, see Add a Rule (p. 36).
Path Conditions
You can use path conditions to define rules that forward requests to different target groups based on the
URL in the request (also known as path-based routing).
Each path condition has one path pattern. If the path of the URL in a request matches the path pattern
in a listener rule, the request is routed using that rule. The path pattern is applied only to the path of the
URL, not to its query parameters.
A path pattern is case-sensitive, can be up to 128 characters in length, and can contain any of the
following characters. You can include up to three wildcard characters.
• /img/*
• /js/*
The path pattern is used to route requests but does not alter them. For example, if a rule has a path
pattern of /img/*, the rule would forward a request for /img/picture.jpg to the specified target
group as a request for /img/picture.jpg.
Console Example
The following is an example of a rule with a path condition as shown in the console. If the URL in the
request matches /img/*, the request is forwarded to the target group named my-targets. For more
information, see Add a Rule (p. 36).
31
Elastic Load Balancing Application Load Balancers
Create a Listener
Prerequisites
• To add a forward action to the default listener rule, you must specify an available target group. For
more information, see Create a Target Group (p. 53).
• To create an HTTPS listener, you must specify a certificate and a security policy. The load balancer
uses the certificate to terminate the connection and decrypt requests from clients before routing
them to targets. For more information, see SSL Certificates (p. 33). The load balancer uses the
security policy when negotiating SSL connections with the clients. For more information, see Security
Policies (p. 34).
Add a Listener
You configure a listener with a protocol and a port for connections from clients to the load balancer, and
a target group for the default listener rule. For more information, see Listener Configuration (p. 27).
• If you created or imported a certificate using AWS Certificate Manager, choose From ACM and
choose the certificate.
• If you uploaded a certificate using IAM, choose From IAM and choose the certificate.
9. Choose Save.
32
Elastic Load Balancing Application Load Balancers
Configure HTTPS Listeners
10. (Optional) To define additional listener rules that forward requests based on a path pattern or a
hostname, see Add a Rule (p. 36).
Use the create-listener command to create the listener and default rule, and the create-rule command to
define additional listener rules.
To use an HTTPS listener, you must deploy at least one SSL/TLS server certificate on your load balancer.
The load balancer uses this certificate to terminate the connection and then decrypt requests from
clients before sending them to the targets.
Elastic Load Balancing uses a Secure Socket Layer (SSL) negotiation configuration, known as a security
policy, to negotiate SSL connections between a client and the load balancer. A security policy is a
combination of protocols and ciphers. The protocol establishes a secure connection between a client and
a server and ensures that all data passed between the client and your load balancer is private. A cipher
is an encryption algorithm that uses encryption keys to create a coded message. Protocols use several
ciphers to encrypt data over the internet. During the connection negotiation process, the client and the
load balancer present a list of ciphers and protocols that they each support, in order of preference. By
default, the first cipher on the server's list that matches any one of the client's ciphers is selected for the
secure connection.
Application Load Balancers do not support SSL renegotiation for client or target connections.
SSL Certificates
The load balancer uses an X.509 certificate (SSL/TLS server certificate). Certificates are a digital form
of identification issued by a certificate authority (CA). A certificate contains identification information, a
validity period, a public key, a serial number, and the digital signature of the issuer.
When you create a certificate for use with your load balancer, you must specify a domain name.
We recommend that you create certificates for your load balancer using AWS Certificate Manager (ACM).
ACM integrates with Elastic Load Balancing so that you can deploy the certificate on your load balancer.
For more information, see the AWS Certificate Manager User Guide.
Alternatively, you can use SSL/TLS tools to create a certificate signing request (CSR), then get the CSR
signed by a CA to produce a certificate, then import the certificate into ACM or upload the certificate
to AWS Identity and Access Management (IAM). For more information about importing certificates into
ACM, see Importing Certificates in the AWS Certificate Manager User Guide. For more information about
uploading certificates to IAM, see Working with Server Certificates in the IAM User Guide.
Important
You cannot install certificates with 4096-bit RSA keys or EC keys on your load balancer through
integration with ACM. You must upload certificates with 4096-bit RSA keys or EC keys to IAM in
order to use them with your load balancer.
When you create an HTTPS listener, you must specify a default certificate. You can create an optional
certificate list for the listener by adding more certificates. This enables a load balancer to support
33
Elastic Load Balancing Application Load Balancers
Security Policies
multiple domains on the same port and provide a different certificate for each domain. The default
certificate for a listener is not added to the certificate list by default. For more information, see Update
Server Certificates (p. 39).
Clients can use the Server Name Indication (SNI) protocol extension to specify the hostname they are
trying to reach. If the hostname doesn't match a certificate in the certificate list, the load balancer
selects the default certificate. If the hostname matches a single certificate in the certificate list, the
load balancer selects this certificate. If a hostname provided by a client matches multiple certificates in
the certificate list, the load balancer selects the best certificate that the client can support. Certificate
selection is based on the following criteria in the following order:
The load balancer access log entries indicate the hostname specified by the client and the certificate
presented to the client. For more information, see Access Log Entries (p. 81).
Security Policies
You can choose the security policy that is used for front-end connections. The
ELBSecurityPolicy-2016-08 security policy is always used for backend connections. Application
Load Balancers do not support custom security policies.
Elastic Load Balancing provides the following security policies for Application Load Balancers:
• ELBSecurityPolicy-2016-08
• ELBSecurityPolicy-FS-2018-06
• ELBSecurityPolicy-TLS-1-2-2017-01
• ELBSecurityPolicy-TLS-1-2-Ext-2018-06
• ELBSecurityPolicy-TLS-1-1-2017-01
• ELBSecurityPolicy-2015-05
• ELBSecurityPolicy-TLS-1-0-2015-04
We recommend the ELBSecurityPolicy-2016-08 policy for general use. You can use the
ELBSecurityPolicy-FS-2018-06 policy if you require Forward Secrecy (FS). You can use one of the
ELBSecurityPolicy-TLS policies to meet compliance and security standards that require disabling
certain TLS protocol versions, or to support legacy clients that require deprecated ciphers. Only a small
percentage of internet clients require TLS version 1.0. To view the TLS protocol version for requests to
your load balancer, enable access logging for your load balancer and examine the access logs. For more
information, see Access Logs (p. 79).
The following table describes the security policies defined for Application Load Balancers.
TLS Protocols
Protocol-TLSv1 ♦ ♦ ♦
Protocol-TLSv1.1 ♦ ♦ ♦ ♦
34
Elastic Load Balancing Application Load Balancers
Update the Security Policy
Protocol-TLSv1.2 ♦ ♦ ♦ ♦ ♦ ♦
TLS Ciphers
ECDHE-ECDSA-AES128-GCM- ♦ ♦ ♦ ♦ ♦ ♦
SHA256
ECDHE-RSA-AES128-GCM-SHA256 ♦ ♦ ♦ ♦ ♦ ♦
ECDHE-ECDSA-AES128-SHA256 ♦ ♦ ♦ ♦ ♦ ♦
ECDHE-RSA-AES128-SHA256 ♦ ♦ ♦ ♦ ♦ ♦
ECDHE-ECDSA-AES128-SHA ♦ ♦ ♦ ♦ ♦
ECDHE-RSA-AES128-SHA ♦ ♦ ♦ ♦ ♦
ECDHE-ECDSA-AES256-GCM- ♦ ♦ ♦ ♦ ♦ ♦
SHA384
ECDHE-RSA-AES256-GCM-SHA384 ♦ ♦ ♦ ♦ ♦ ♦
ECDHE-ECDSA-AES256-SHA384 ♦ ♦ ♦ ♦ ♦ ♦
ECDHE-RSA-AES256-SHA384 ♦ ♦ ♦ ♦ ♦ ♦
ECDHE-RSA-AES256-SHA ♦ ♦ ♦ ♦ ♦
ECDHE-ECDSA-AES256-SHA ♦ ♦ ♦ ♦ ♦
AES128-GCM-SHA256 ♦ ♦ ♦ ♦ ♦
AES128-SHA256 ♦ ♦ ♦ ♦ ♦
AES128-SHA ♦ ♦ ♦ ♦
AES256-GCM-SHA384 ♦ ♦ ♦ ♦ ♦
AES256-SHA256 ♦ ♦ ♦ ♦ ♦
AES256-SHA ♦ ♦ ♦ ♦
DES-CBC3-SHA ♦
† Do not use this security policy unless you must support a legacy client that requires the DES-CBC3-SHA
cipher, which is a weak cipher.
To view the configuration of a security policy for Application Load Balancers using the AWS CLI, use the
describe-ssl-policies command.
35
Elastic Load Balancing Application Load Balancers
Update Listener Rules
Each rule consists of a priority, one or more actions, an optional host condition, and an optional path
condition. For more information, see Listener Rules (p. 28).
Note
The console displays a relative sequence number for each rule, not the rule priority. You can get
the priority of a rule by describing it using the AWS CLI or the Elastic Load Balancing API.
Prerequisites
A forward action routes requests to its target group. Before you create a rule with a forward action or
update the target group for a rule with a forward action, create the target group and add targets to it.
For more information, see Create a Target Group (p. 53).
Add a Rule
You define a default rule when you create a listener, and you can define additional nondefault rules at
any time.
36
Elastic Load Balancing Application Load Balancers
Edit a Rule
7. To leave this screen, choose the Back to the load balancer icon (the back button) in the menu bar.
Use the create-rule command to create the rule. Use the describe-rules command to view information
about the rule.
Edit a Rule
You can edit the action and conditions for a rule at any time.
37
Elastic Load Balancing Application Load Balancers
Reorder Rules
6. For the rule to edit, choose the Edit rules icon (the pencil).
7. (Optional) Modify the conditions and actions as needed. For example, you can edit a condition or
action (pencil icon), add a path condition if you don't have one already, add a host condition if you
don't have one already, add an authenticate action for a rule for an HTTPS listener, or delete a
condition or action (trash can icon). You can't add conditions to the default rule.
8. Choose Update.
9. To leave this screen, choose the Back to the load balancer icon (the back button) in the menu bar.
Reorder Rules
Rules are evaluated in priority order, from the lowest value to the highest value. The default rule is
evaluated last. You can change the priority of a nondefault rule at any time. You cannot change the
priority of the default rule.
Note
The console displays a relative sequence number for each rule, not the rule priority. When you
reorder rules using the console, they get new rule priorities based on the existing rule priorities.
To set the priority of a rule to a specific value, use the AWS CLI or the Elastic Load Balancing API.
6. Select the check box next to a rule, and then use the arrows to give the rule a new priority. The
default rule always has the last priority.
7. When you have finished reordering rules, choose Save.
8. To leave this screen, choose the Back to the load balancer icon (the back button) in the menu bar.
38
Elastic Load Balancing Application Load Balancers
Delete a Rule
Delete a Rule
You can delete the nondefault rules for a listener at any time. You cannot delete the default rule for a
listener. When you delete a listener, all its rules are deleted.
Each certificate comes with a validity period. You must ensure that you renew or replace the certificate
before its validity period ends. Renewing or replacing a certificate does not affect in-flight requests that
were received by the load balancer node and are pending routing to a healthy target. After a certificate
is renewed, new requests use the renewed certificate. After a certificate is replaced, new requests use the
new certificate.
• Certificates provided by AWS Certificate Manager and deployed on your load balancer can be renewed
automatically. ACM attempts to renew certificates before they expire. For more information, see
Managed Renewal in the AWS Certificate Manager User Guide.
• If you imported a certificate into ACM, you must monitor the expiration date of the certificate and
renew it before it expires. For more information, see Importing Certificates in the AWS Certificate
Manager User Guide.
• If you imported a certificate into IAM, you must create a new certificate, import the new certificate
to ACM or IAM, add the new certificate to your load balancer, and remove the expired certificate from
your load balancer.
Limitation
ACM supports RSA certificates with a 4096 key length and EC certificates. However, you cannot
install these certificates on your load balancer through integration with ACM. You must upload these
certificates to IAM in order to use them with your load balancer.
39
Elastic Load Balancing Application Load Balancers
Add Certificates
Add Certificates
You can add certificates to the certificate list for your listener using the following procedure. The default
certificate for a listener is not added to the certificate list by default, but you can add the default
certificate to the certificate list.
• If you created or imported a certificate using AWS Certificate Manager, choose From ACM and
choose the certificate.
• If you uploaded a certificate using IAM, choose From IAM and choose the certificate.
6. Choose Save.
40
Elastic Load Balancing Application Load Balancers
Remove Certificates
Remove Certificates
You can remove the nondefault certificates for an HTTPS listener at any time. You cannot remove the
default certificate for an HTTPS listener using this procedure.
• Authenticate users through an identity provider (IdP) that is OpenID Connect (OIDC) compliant.
• Authenticate users through well-known social IdPs, such as Amazon, Facebook, or Google, through the
user pools supported by Amazon Cognito.
• Authenticate users through corporate identities, using SAML, LDAP, or Microsoft AD, through the user
pools supported by Amazon Cognito.
• Create a new OIDC app in your IdP. You must configure a client ID and a client secret.
• Get the following endpoints published by the IdP: authorization, token, and user info. You can locate
this information in the well-known config.
• Whitelist one of the following redirect URLs in your IdP app, whichever your users will use, where DNS
is the domain name of your load balancer and CNAME is the DNS alias for your application:
• https://DNS/oauth2/idpresponse
• https://CNAME/oauth2/idpresponse
41
Elastic Load Balancing Application Load Balancers
Prepare to Use Amazon Cognito
• Create a user pool. For more information, see Amazon Cognito User Pools in the Amazon Cognito
Developer Guide.
• Create a user pool client. You must configure the client to generate a client secret, use code grant
flow, and support the same OAuth scopes that the load balancer uses. For more information, see
Configuring a User Pool App Client in the Amazon Cognito Developer Guide.
• Create a user pool domain. For more information, see Adding a Domain Name for Your User Pool in the
Amazon Cognito Developer Guide.
• Verify that the requested scope returns an ID token. For example, the default scope, openid returns an
ID token but the aws.cognito.signin.user.admin scope does not.
• To federate with a social or corporate IdP, enable the IdP in the federation section. For more
information, see Add Social Sign-in to a User Pool or Add Sign-in with a SAML IdP to a User Pool in the
Amazon Cognito Developer Guide.
• Whitelist the following redirect URLs in the callback URL field for Amazon Cognito, where DNS is the
domain name of your load balancer, and CNAME is the DNS alias for your application (if you are using
one):
• https://DNS/oauth2/idpresponse
• https://CNAME/oauth2/idpresponse
• Whitelist your user pool domain on your IdP app's callback URL. Use the format for your IdP. For
example:
• https://domain-prefix.auth.region.amazoncognito.com/saml2/idpresponse
• https://user-pool-domain/oauth2/idpresponse
To enable an IAM user to configure a load balancer to use Amazon Cognito to authenticate users, you
must grant the user permission to call the cognito-idp:DescribeUserPoolClient action.
By default, the SessionTimeout field is set to 7 days. If you want shorter sessions, you can configure
a session timeout as short as 1 second. For more information, see Authentication Logout and Session
Timeout (p. 46).
Set the OnUnauthenticatedRequest field as appropriate for your application. For example:
42
Elastic Load Balancing Application Load Balancers
Configure User Authentication
• Applications that require the user to log in using a social or corporate identity—This is supported
by the default option, authenticate. If the user is not logged in, the load balancer redirects the
request to the IdP authorization endpoint and the IdP prompts the user to log in using its user
interface.
• Applications that provide a personalized view to a user that is logged in or a general view to a user
that is not logged in—To support this type of application, use the allow option. If the user is logged
in, the load balancer provides the user claims and the application can provide a personalized view.
If the user is not logged in, the load balancer forwards the request without the user claims and the
application can provide the general view.
• Single-page applications with JavaScript that loads every few seconds—By default, after the
authentication session cookie expires, the AJAX calls are redirected to the IdP and are blocked. If you
use the deny option, the load balancer returns an HTTP 401 Unauthorized error to these AJAX calls.
The load balancer must be able to communicate with the IdP token endpoint (TokenEndpoint) and
the IdP user info endpoint (UserInfoEndpoint). Verify that the security groups for your load balancer
and the network ACLs for your VPC allow outbound access to these endpoints. Verify that your VPC
has internet access. If you have an internal-facing load balancer, use a NAT gateway to enable the load
balancer to access these endpoints.
The following is an example of the actions.json file that specifies an authenticate-oidc action
and a forward action.
[{
"Type": "authenticate-oidc",
"AuthenticateOidcConfig": {
"Issuer": "https://idp-issuer.com",
"AuthorizationEndpoint": "https://authorization-endpoint.com",
"TokenEndpoint": "https://token-endpoint.com",
"UserInfoEndpoint": "https://user-info-endpoint.com",
"ClientId": "abcdefghijklmnopqrstuvwxyz123456789",
"ClientSecret": "123456789012345678901234567890",
"SessionCookieName": "my-cookie",
"SessionTimeout": 3600,
"Scope": "email",
"AuthenticationRequestExtraParams": {
"display": "page",
"prompt": "login"
},
"OnUnauthenticatedRequest": "deny"
},
"Order": 1
},
{
"Type": "forward",
"TargetGroupArn": "arn:aws:elasticloadbalancing:region-code:account-
id:targetgroup/target-group-name/target-group-id",
"Order": 2
}]
[{
43
Elastic Load Balancing Application Load Balancers
Authentication Flow
"Type": "authenticate-cognito",
"AuthenticateCognitoConfig": {
"UserPoolArn": "arn:aws:cognito-idp:region-code:account-id:userpool/user-pool-id",
"UserPoolClientId": "abcdefghijklmnopqrstuvwxyz123456789",
"UserPoolDomain": "userPoolDomain1",
"SessionCookieName": "my-cookie",
"SessionTimeout": 3600,
"Scope": "email",
"AuthenticationRequestExtraParams": {
"display": "page",
"prompt": "login"
},
"OnUnauthenticatedRequest": "deny"
},
"Order": 1
},
{
"Type": "forward",
"TargetGroupArn": "arn:aws:elasticloadbalancing:region-code:account-
id:targetgroup/target-group-name/target-group-id",
"Order": 2
}]
Authentication Flow
Elastic Load Balancing uses the OIDC authorization code flow, which includes the following steps.
1. When the conditions for a rule with an authenticate action are met, the load balancer checks for an
authentication session cookie in the request headers. If the cookie is not present, the load balancer
redirects the user to the IdP authorization endpoint so that the IdP can authenticate the user.
2. After the user is authenticated, the IdP redirects the user back to the load balancer with an
authorization grant code. The load balancer presents the code to the IdP token endpoint to get the
ID token and access token.
3. After the load balancer validates the ID token, it exchanges the access token with the IdP user info
endpoint to get the user claims.
4. The load balancer creates the authentication session cookie and sends it to the client so that the
client's user agent can send the cookie to the load balancer when making requests. Because most
browsers limit a cookie to 4K in size, the load balancer shards a cookie that is greater than 4K in
size into multiple cookies. If the total size of the user claims and access token received from the
IdP is greater than 11K bytes in size, the load balancer returns an HTTP 500 error to the client and
increments the ELBAuthUserClaimsSizeExceeded metric.
5. The load balancer sends the user claims to the target in HTTP headers. For more information, see
User Claims Encoding and Signature Verification (p. 44).
6. If the IdP provides a valid refresh token in the ID token, the load balancer saves the refresh token
and uses it to refresh the user claims each time the access token expires, until the session times out
or the IdP refresh fails. If the user logs out, the refresh fails and the load balancer redirects the user
to the IdP authorization endpoint. This enables the load balancer to drop sessions after the user logs
out. For more information, see Authentication Logout and Session Timeout (p. 46).
44
Elastic Load Balancing Application Load Balancers
User Claims Encoding and Signature Verification
x-amzn-oidc-accesstoken
The subject field (sub) from the user info endpoint, in plain text.
x-amzn-oidc-data
Applications that require the full user claims can use any standard JWT library. The JWT format includes
a header, payload, and signature that are base64 URL encoded. The JWT signature is ECDSA + P-256 +
SHA256.
{
"alg": "algorithm",
"kid": "12345678-1234-1234-1234-123456789012",
"signer": "arn:aws:elasticloadbalancing:region-code:account-id:loadbalancer/app/load-
balancer-name/load-balancer-id",
"iss": "url",
"client": "client-id",
"exp": "expiration"
}
The JWT payload is a JSON object that contains the user claims received from the IdP user info endpoint.
{
"sub": "1234567890",
"name": "name",
"email": "[email protected]",
...
}
Because the load balancer does not encrypt the user claims, we recommend that you configure the
target group to use HTTPS. If you configure your target group to use HTTP, be sure to restrict the traffic
to your load balancer using security groups. We also recommend that you verify the signature before
doing any authorization based on the claims. To get the public key, get the key ID from the JWT header
and use it to look up the public key from the following regional endpoint:
https://public-keys.auth.elb.region.amazonaws.com/key-id
https://s3-us-gov-west-1.amazonaws.com/aws-elb-public-keys-prod-us-gov-west-1/key-id
https://s3-us-gov-east-1.amazonaws.com/aws-elb-public-keys-prod-us-gov-east-1/key-id
The following example shows how to get the public key in Python:
import jwt
45
Elastic Load Balancing Application Load Balancers
Authentication Logout and Session Timeout
import requests
import base64
import json
# Step 1: Get the key id from JWT headers (the kid field)
encoded_jwt = headers.dict['x-amzn-oidc-data']
jwt_headers = encoded_jwt.split('.')[0]
decoded_jwt_headers = base64.b64decode(jwt_headers)
decoded_json = json.loads(decoded_jwt_headers)
kid = decoded_json['kid']
The refresh token and the session timeout work together as follows:
• If the session timeout is shorter than the access token expiration, the load balancer honors the session
timeout and has the user log in again after the authentication session times out.
• If the session timeout is longer than the access token expiration and the IdP does not support refresh
tokens, the load balancer keeps the authentication session until it times out and then has the user log
in again.
• If the session timeout is longer than the access token expiration and the IdP supports refresh tokens,
the load balancer refreshes the user session each time the access token expires. The load balancer has
the user log in again only after the authentication session times out or the refresh flow fails.
46
Elastic Load Balancing Application Load Balancers
Delete a Listener
47
Elastic Load Balancing Application Load Balancers
Routing Configuration
You define health check settings for your load balancer on a per target group basis. Each target group
uses the default health check settings, unless you override them when you create the target group
or modify them later on. After you specify a target group in a rule for a listener, the load balancer
continually monitors the health of all targets registered with the target group that are in an Availability
Zone enabled for the load balancer. The load balancer routes requests to the registered targets that are
healthy.
Contents
• Routing Configuration (p. 48)
• Target Type (p. 49)
• Registered Targets (p. 49)
• Target Group Attributes (p. 50)
• Deregistration Delay (p. 50)
• Slow Start Mode (p. 51)
• Sticky Sessions (p. 52)
• Create a Target Group (p. 53)
• Health Checks for Your Target Groups (p. 54)
• Register Targets with Your Target Group (p. 57)
• Lambda Functions as Targets (p. 60)
• Tags for Your Target Group (p. 66)
• Delete a Target Group (p. 67)
Routing Configuration
By default, a load balancer routes requests to its targets using the protocol and port number that you
specified when you created the target group. Alternatively, you can override the port used for routing
traffic to a target when you register it with the target group.
48
Elastic Load Balancing Application Load Balancers
Target Type
If a target group is configured with the HTTPS protocol or uses HTTPS health checks, SSL connections to
the targets use the security settings from the ELBSecurityPolicy2016-08 policy.
Target Type
When you create a target group, you specify its target type, which determines the type of target you
specify when registering targets with this target group. After you create a target group, you cannot
change its target type.
instance
When the target type is ip, you can specify IP addresses from one of the following CIDR blocks:
These supported CIDR blocks enable you to register the following with a target group: ClassicLink
instances, instances in a peered VPC, AWS resources that are addressable by IP address and port (for
example, databases), and on-premises resources linked to AWS through AWS Direct Connect or a VPN
connection.
Important
You can't specify publicly routable IP addresses.
If you specify targets using an instance ID, traffic is routed to instances using the primary private IP
address specified in the primary network interface for the instance. If you specify targets using IP
addresses, you can route traffic to an instance using any private IP address from one or more network
interfaces. This enables multiple applications on an instance to use the same port. Each network
interface can have its own security group.
If the target type of your target group is lambda, you can register a single Lambda function. When the
load balancer receives a request for the Lambda function, it invokes the Lambda function. For more
information, see Lambda Functions as Targets (p. 60).
Registered Targets
Your load balancer serves as a single point of contact for clients and distributes incoming traffic across its
healthy registered targets. You can register each target with one or more target groups. You can register
each EC2 instance or IP address with the same target group multiple times using different ports, which
enables the load balancer to route requests to microservices.
49
Elastic Load Balancing Application Load Balancers
Target Group Attributes
If demand on your application increases, you can register additional targets with one or more target
groups in order to handle the demand. The load balancer starts routing requests to a newly registered
target as soon as the registration process completes and the target passes the initial health checks.
If demand on your application decreases, or you need to service your targets, you can deregister targets
from your target groups. Deregistering a target removes it from your target group, but does not affect
the target otherwise. The load balancer stops routing requests to a target as soon as it is deregistered.
The target enters the draining state until in-flight requests have completed. You can register the target
with the target group again when you are ready for it to resume receiving requests.
If you are registering targets by instance ID, you can use your load balancer with an Auto Scaling group.
After you attach a target group to an Auto Scaling group, Auto Scaling registers your targets with the
target group for you when it launches them. For more information, see Attaching a Load Balancer to
Your Auto Scaling Group in the Amazon EC2 Auto Scaling User Guide.
deregistration_delay.timeout_seconds
The amount of time for Elastic Load Balancing to wait before deregistering a target. The range is 0–
3600 seconds. The default value is 300 seconds.
slow_start.duration_seconds
The time period, in seconds, during which the load balancer sends a newly registered target a
linearly increasing share of the traffic to the target group. The range is 30–900 seconds (15 minutes).
The default is 0 seconds (disabled).
stickiness.enabled
The cookie expiration period, in seconds. After this period, the cookie is considered stale. The
minimum value is 1 second and the maximum value is 7 days (604800 seconds). The default value is
1 day (86400 seconds).
stickiness.type
The following target group attribute is supported if the target group type is lambda:
lambda.multi_value_headers.enabled
Indicates whether the request and response headers exchanged between the load balancer and the
Lambda function include arrays of values or strings. The possible values are true or false. The
default value is false. For more information, see Multi-Value Headers (p. 63).
Deregistration Delay
Elastic Load Balancing stops sending requests to targets that are deregistering. By default, Elastic Load
Balancing waits 300 seconds before completing the deregistration process, which can help in-flight
50
Elastic Load Balancing Application Load Balancers
Slow Start Mode
requests to the target to complete. To change the amount of time that Elastic Load Balancing waits,
update the deregistration delay value.
The initial state of a deregistering target is draining. After the deregistration delay elapses, the
deregistration process completes and the state of the target is unused. If the target is part of an Auto
Scaling group, it can be terminated and replaced.
If a deregistering target has no in-flight requests and no active connections, Elastic Load Balancing
immediately completes the deregistration process, without waiting for the deregistration delay to elapse.
However, even though target deregistration is complete, the status of the target will be displayed as
draining until the deregistration delay elapses.
If a deregistering target terminates the connection before the deregistration delay elapses, the client
receives a 500-level error response.
Considerations
• When you enable slow start for a target group, the targets already registered with the target group do
not enter slow start mode.
• When you enable slow start for an empty target group and then register one or more targets using
a single registration operation, these targets do not enter slow start mode. Newly registered targets
enter slow start mode only when there is at least one registered target that is not in slow start mode.
• If you deregister a target in slow start mode, the target exits slow start mode. If you register the same
target again, it enters slow start mode again.
• If a target in slow start mode becomes unhealthy and then healthy again before the duration period
elapses, the target remains in slow start mode and exits slow start mode when the remainder of the
duration period elapses. If a target that is not in slow start mode changes from unhealthy to healthy, it
does not enter slow start mode.
51
Elastic Load Balancing Application Load Balancers
Sticky Sessions
To update the slow start duration value using the AWS CLI
Sticky Sessions
Sticky sessions are a mechanism to route requests to the same target in a target group. This is useful for
servers that maintain state information in order to provide a continuous experience to clients. To use
sticky sessions, the clients must support cookies.
When a load balancer first receives a request from a client, it routes the request to a target and
generates a cookie to include in the response to the client. The next request from that client contains the
cookie. If sticky sessions are enabled for the target group and the request goes to the same target group,
the load balancer detects the cookie and routes the request to the same target.
Application Load Balancers support load balancer-generated cookies only. The name of the cookie is
AWSALB. The contents of these cookies are encrypted using a rotating key. You cannot decrypt or modify
load balancer-generated cookies.
WebSockets connections are inherently sticky. If the client requests a connection upgrade to
WebSockets, the target that returns an HTTP 101 status code to accept the connection upgrade is the
target used in the WebSockets connection. After the WebSockets upgrade is complete, cookie-based
stickiness is not used.
You enable sticky sessions at the target group level. You can also set the duration for the stickiness of
the load balancer-generated cookie, in seconds. The duration is set with each request. Therefore, if the
client sends a request before each duration period expires, the sticky session continues. If you enable
sticky sessions on multiple target groups, we recommend that you configure the same duration for all
target groups.
52
Elastic Load Balancing Application Load Balancers
Create a Target Group
To route traffic to the targets in a target group, specify the target group in an action when you create a
listener or create a rule for your listener. For more information, see Listener Rules (p. 28).
You can add or remove targets from your target group at any time. For more information, see Register
Targets with Your Target Group (p. 57). You can also modify the health check settings for your target
group. For more information, see Modify the Health Check Settings of a Target Group (p. 57).
a. (Optional) For Protocol and Port, modify the default values as needed.
b. For VPC, select a virtual private cloud (VPC).
53
Elastic Load Balancing Application Load Balancers
Configure Health Checks
8. (Optional) For Health check settings and Advanced health check settings, modify the default
settings as needed.
9. Choose Create.
10. (Optional) Add one or more tags as follows:
Use the create-target-group command to create the target group, the add-tags command to tag your
target group, and the register-targets command to add targets.
Each load balancer node routes requests only to the healthy targets in the enabled Availability Zones
for the load balancer. Each load balancer node checks the health of each target, using the health check
settings for the target groups with which the target is registered. After your target is registered, it must
pass one health check to be considered healthy. After each health check is completed, the load balancer
node closes the connection that was established for the health check.
If a target group contains only unhealthy registered targets, the load balancer nodes route requests
across its unhealthy targets.
54
Elastic Load Balancing Application Load Balancers
Target Health Status
Setting Description
The following table describes the possible values for the health status of a registered target.
Value Description
55
Elastic Load Balancing Application Load Balancers
Health Check Reason Codes
Value Description
unhealthy The target did not respond to a health check or failed the
health check.
unused The target is not registered with a target group, the target
group is not used in a listener rule for the load balancer, or
the target is in an Availability Zone that is not enabled for
the load balancer.
56
Elastic Load Balancing Application Load Balancers
Check the Health of Your Targets
Use the describe-target-health command. The output of this command contains the target health state.
If the status is any value other than Healthy, the output also includes a reason code.
To modify the health check settings of a target group using the console
To modify the health check settings of a target group using the AWS CLI
If demand on your currently registered targets increases, you can register additional targets in order to
handle the demand. When your target is ready to handle requests, register it with your target group. The
load balancer starts routing requests to the target as soon as the registration process completes and the
target passes the initial health checks.
If demand on your registered targets decreases, or you need to service a target, you can deregister it
from your target group. The load balancer stops routing requests to a target as soon as you deregister it.
When the target is ready to receive requests, you can register it with the target group again.
When you deregister a target, the load balancer waits until in-flight requests have completed. This
is known as connection draining. The status of a target is draining while connection draining is in
progress.
57
Elastic Load Balancing Application Load Balancers
Target Security Groups
When you deregister a target that was registered by IP address, you must wait for the deregistration
delay to complete before you can register the same IP address again.
If you are registering targets by instance ID, you can use your load balancer with an Auto Scaling group.
After you attach a target group to an Auto Scaling group and the group scales out, the instances
launched by the Auto Scaling group are automatically registered with the target group. If you detach the
target group from the Auto Scaling group, the instances are automatically deregistered from the target
group. For more information, see Attaching a Load Balancer to Your Auto Scaling Group in the Amazon
EC2 Auto Scaling User Guide.
Recommended Rules
Inbound
load balancer instance listener Allow traffic from the load balancer on the
security group instance listener port
load balancer health check Allow traffic from the load balancer on the health
security group check port
We also recommend that you allow inbound ICMP traffic to support Path MTU Discovery. For more
information, see Path MTU Discovery in the Amazon EC2 User Guide for Linux Instances.
Contents
• Register or Deregister Targets by Instance ID (p. 58)
• Register or Deregister Targets by IP Address (p. 59)
• Register or Deregister a Lambda Function (p. 60)
58
Elastic Load Balancing Application Load Balancers
Register or Deregister Targets
6. To deregister instances, select them from Registered instances and choose Remove.
7. Choose Save.
Use the register-targets command to add targets and the deregister-targets command to remove
targets.
59
Elastic Load Balancing Application Load Balancers
Lambda Functions as Targets
6. To deregister IP addresses, choose the Deregister targets icon (the minus sign) in the menu bar. If
you have many registered IP addresses, you might find it helpful to add a filter or change the sort
order. Select the IP addresses and then choose Deregister.
7. To leave this screen, choose the Back to target group icon (the back button) in the menu bar.
Use the register-targets command to add targets and the deregister-targets command to remove
targets.
Use the register-targets command to add targets and the deregister-targets command to remove
targets.
60
Elastic Load Balancing Application Load Balancers
Prepare the Lambda Function
Limits
• The maximum size of the request body that you can send to a Lambda function is 1 MB. For related
size limits, see HTTP Header Limits.
• The maximum size of the response JSON that the Lambda function can send is 1 MB.
• WebSockets are not supported. Upgrade requests are rejected with an HTTP 400 code.
Contents
• Prepare the Lambda Function (p. 61)
• Create a Target Group for the Lambda Function (p. 60)
• Receive Events From the Load Balancer (p. 62)
• Respond to the Load Balancer (p. 63)
• Multi-Value Headers (p. 63)
• Enable Health Checks (p. 65)
• Deregister the Lambda Function (p. 66)
If you create the target group and register the Lambda function using the AWS Management Console,
the console adds the required permissions to your Lambda function policy on your behalf. Otherwise,
after you create the target group and register the function using the AWS CLI, you must use the add-
permission command to grant Elastic Load Balancing permission to invoke your Lambda function.
We recommend that you include the --source-arn parameter to restrict function invocation to the
specified target group.
You can register one Lambda function per target group. To ensure that you can change your Lambda
function and that the load balancer always invokes the current version of the Lambda function, create
a function alias and include the alias in the function ARN when you register the Lambda function with
the load balancer. For more information, see AWS Lambda Function Versioning and Aliases and Traffic
Shifting Using Aliases in the AWS Lambda Developer Guide.
Function Timeout
The load balancer waits until your Lambda function responds or times out. We recommend that you
configure the timeout of the Lambda function based on your expected run time. For information about
the default timeout value and how to change it, see Basic AWS Lambda Function Configuration. For
information about the maximum timeout value you can configure, see AWS Lambda Limits.
61
Elastic Load Balancing Application Load Balancers
Receive Events From the Load Balancer
To create a target group and deregister the Lambda function using the AWS CLI
If the content type is one of the following types, the load balancer sends the body to the Lambda
function as is and sets isBase64Encoded to false: text/*, application/json, application/javascript,
and application/xml. For all other types, the load balancer Base64 encodes the body and sets
isBase64Encoded to true.
{
"requestContext": {
"elb": {
"targetGroupArn":
"arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-target-
group/6d0ecf831eec9f09"
}
},
"httpMethod": "GET",
"path": "/",
"queryStringParameters": {parameters},
"headers": {
"accept": "text/html,application/xhtml+xml",
"accept-language": "en-US,en;q=0.8",
"content-type": "text/plain",
"cookie": "cookies",
"host": "lambda-846800462-us-east-2.elb.amazonaws.com",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)",
"x-amzn-trace-id": "Root=1-5bdb40ca-556d8b0c50dc66f0511bf520",
"x-forwarded-for": "72.21.198.66",
"x-forwarded-port": "443",
"x-forwarded-proto": "https"
},
"isBase64Encoded": false,
"body": "request_body"
}
62
Elastic Load Balancing Application Load Balancers
Respond to the Load Balancer
To include a binary content in the body of the response, you must Base64 encode the content and set
isBase64Encoded to true. The load balancer decodes the content to retrieve the binary content and
sends it to the client in the body of the HTTP response.
The load balancer does not honor hop-by-hop headers, such as Connection or Transfer-Encoding.
You can omit the Content-Length header because the load balancer computes it before sending
responses to clients.
{
"isBase64Encoded": false,
"statusCode": 200,
"statusDescription": "200 OK",
"headers": {
"Set-cookie": "cookies",
"Content-Type": "application/json"
},
"body": "Hello from Lambda (optional)"
}
For Lambda function templates that work with Application Load Balancers, see application-load-
balancer-serverless-app on github. Alternatively, open the Lambda console, create a function, and select
one of the following from the AWS Serverless Application Repository:
• ALB-Lambda-Target-HelloWorld
• ALB-Lambda-Target-UploadFiletoS3
• ALB-Lambda-Target-BinaryResponse
• ALB-Lambda-Target-WhatisMyIP
Multi-Value Headers
If requests from a client or responses from a Lambda function contain headers with multiple values or
contains the same header multiple times, you can enable support for multi-value header syntax. After
you enable multi-value headers, the request and response headers exchanged between the load balancer
and the Lambda function use arrays. Otherwise, the load balancer uses the last value it receives.
Contents
• Requests with Multi-Value Headers (p. 63)
• Responses with Multi-Value Headers (p. 64)
• Enable Multi-Value Headers (p. 64)
http://www.example.com?&myKey=val1&myKey=val2
63
Elastic Load Balancing Application Load Balancers
Multi-Value Headers
With the default format, the load balancer uses the last value sent by the client and sends you an event
that includes the following:
With multi-value headers, the load balancer uses both key values sent by the client and sends you an
event that includes the following:
Similarly, suppose that the client sends a request with two cookies in the header:
"cookie": "name1=value1",
"cookie": "name2=value2",
With the default format, the load balancer uses the last cookie sent by the client and sends you an event
that includes the following:
"headers": {
"cookie": "name2=value2",
...
},
With multi-value headers, the load balancer uses both cookies sent by the client and sends you an event
that includes the following:
"multiValueHeaders": {
"cookie": ["name1=value1", "name2=value2"],
...
},
{
"headers": {
"Set-cookie": "cookie-name=cookie-value;Domain=myweb.com;Secure;HttpOnly",
"Content-Type": "application/json"
},
}
{
"multiValueHeaders": {
"Set-cookie": ["cookie-name=cookie-value;Domain=myweb.com;Secure;HttpOnly","cookie-
name=cookie-value;Expires=May 8, 2019"],
"Content-Type": ["application/json"]
},
}
64
Elastic Load Balancing Application Load Balancers
Enable Health Checks
You are charged for health checks as you are for any Lambda function invocation.
The following is the format of the health check event sent to your Lambda function. To check whether
an event is a health check event, check the value of the user-agent field. The user agent for health
checks is ELB-HealthChecker/2.0.
{
"requestContext": {
"elb": {
"targetGroupArn":
"arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-target-
group/6d0ecf831eec9f09"
}
},
"httpMethod": "GET",
"path": "/",
"queryStringParameters": {},
"headers": {
"user-agent": "ELB-HealthChecker/2.0"
},
"body": "",
"isBase64Encoded": false
}
65
Elastic Load Balancing Application Load Balancers
Deregister the Lambda Function
To enable health checks for a target group using the AWS CLI
To replace a Lambda function, we recommend that you create a new target group, register the new
function with the new target group, and update the listener rules to use the new target group instead of
the existing one.
You can add multiple tags to each target group. Tag keys must be unique for each target group. If you
add a tag with a key that is already associated with the target group, it updates the value of that tag.
When you are finished with a tag, you can remove it.
Restrictions
66
Elastic Load Balancing Application Load Balancers
Delete a Target Group
4. On the Tags tab, choose Add/Edit Tags and do one or more of the following:
To update the tags for a target group using the AWS CLI
67
Elastic Load Balancing Application Load Balancers
CloudWatch Metrics
CloudWatch metrics
You can use Amazon CloudWatch to retrieve statistics about data points for your load balancers and
targets as an ordered set of time-series data, known as metrics. You can use these metrics to verify
that your system is performing as expected. For more information, see CloudWatch Metrics for Your
Application Load Balancer (p. 68).
Access logs
You can use access logs to capture detailed information about the requests made to your load
balancer and store them as log files in Amazon S3. You can use these access logs to analyze traffic
patterns and to troubleshoot issues with your targets. For more information, see Access Logs for
Your Application Load Balancer (p. 79).
Request tracing
You can use request tracing to track HTTP requests. The load balancer adds a header with a trace
identifier to each request it receives. For more information, see Request Tracing for Your Application
Load Balancer (p. 90).
CloudTrail logs
You can use AWS CloudTrail to capture detailed information about the calls made to the Elastic
Load Balancing API and store them as log files in Amazon S3. You can use these CloudTrail logs
to determine which calls were made, the source IP address where the call came from, who made
the call, when the call was made, and so on. For more information, see Logging API Calls for Your
Application Load Balancer Using AWS CloudTrail (p. 92).
You can use metrics to verify that your system is performing as expected. For example, you can create a
CloudWatch alarm to monitor a specified metric and initiate an action (such as sending a notification to
an email address) if the metric goes outside what you consider an acceptable range.
Elastic Load Balancing reports metrics to CloudWatch only when requests are flowing through the load
balancer. If there are requests flowing through the load balancer, Elastic Load Balancing measures and
68
Elastic Load Balancing Application Load Balancers
Application Load Balancer Metrics
sends its metrics in 60-second intervals. If there are no requests flowing through the load balancer or no
data for a metric, the metric is not reported.
Contents
• Application Load Balancer Metrics (p. 69)
• Metric Dimensions for Application Load Balancers (p. 77)
• Statistics for Application Load Balancer Metrics (p. 77)
• View CloudWatch Metrics for Your Load Balancer (p. 78)
Metric Description
ActiveConnectionCount The total number of concurrent TCP connections active from clients to
the load balancer and from the load balancer to targets.
Dimensions
• LoadBalancer
The number of TLS connections initiated by the client that did not
ClientTLSNegotiationErrorCount
establish a session with the load balancer. Possible causes include a
mismatch of ciphers or protocols.
Dimensions
• LoadBalancer
• AvailabilityZone, LoadBalancer
ConsumedLCUs The number of load balancer capacity units (LCU) used by your load
balancer. You pay for the number of LCUs that you use per hour. For
more information, see Elastic Load Balancing Pricing.
Statistics: All
Dimensions
• LoadBalancer
69
Elastic Load Balancing Application Load Balancers
Application Load Balancer Metrics
Metric Description
Statistics: The only meaningful statistic is Sum.
Dimensions
• LoadBalancer
Dimensions
• LoadBalancer
Dimensions
• LoadBalancer
HTTPCode_ELB_3XX_Count The number of HTTP 3XX redirection codes that originate from the load
balancer.
Dimensions
• LoadBalancer
HTTPCode_ELB_4XX_Count The number of HTTP 4XX client error codes that originate from the load
balancer. Client errors are generated when requests are malformed or
incomplete. These requests have not been received by the target. This
count does not include any response codes generated by the targets.
Dimensions
• LoadBalancer
• AvailabilityZone, LoadBalancer
70
Elastic Load Balancing Application Load Balancers
Application Load Balancer Metrics
Metric Description
HTTPCode_ELB_5XX_Count The number of HTTP 5XX server error codes that originate from the load
balancer. This count does not include any response codes generated by
the targets.
Dimensions
• LoadBalancer
• AvailabilityZone, LoadBalancer
IPv6ProcessedBytes The total number of bytes processed by the load balancer over IPv6.
Dimensions
• LoadBalancer
Dimensions
• LoadBalancer
• AvailabilityZone, LoadBalancer
• TargetGroup, LoadBalancer
• TargetGroup, AvailabilityZone, LoadBalancer
NewConnectionCount The total number of new TCP connections established from clients to the
load balancer and from the load balancer to targets.
Dimensions
• LoadBalancer
71
Elastic Load Balancing Application Load Balancers
Application Load Balancer Metrics
Metric Description
ProcessedBytes The total number of bytes processed by the load balancer over IPv4 and
IPv6.
Dimensions
• LoadBalancer
RejectedConnectionCountThe number of connections that were rejected because the load balancer
had reached its maximum number of connections.
Dimensions
• LoadBalancer
• AvailabilityZone, LoadBalancer
RequestCount The number of requests processed over IPv4 and IPv6. This count
includes only the requests with a response generated by a target of the
load balancer.
Dimensions
• LoadBalancer
• AvailabilityZone, LoadBalancer
• TargetGroup, LoadBalancer
• TargetGroup, AvailabilityZone, LoadBalancer
RuleEvaluations The number of rules processed by the load balancer given a request rate
averaged over an hour.
Dimensions
• LoadBalancer
72
Elastic Load Balancing Application Load Balancers
Application Load Balancer Metrics
Metric Description
StandardProcessedBytes The total number of bytes processed by the load balancer over IPv4 and
IPv6 for instances and IP addresses registered as targets.
Dimensions
• LoadBalancer
Metric Description
Dimensions
• TargetGroup, LoadBalancer
• TargetGroup, AvailabilityZone, LoadBalancer
The number of HTTP response codes generated by the targets. This does
HTTPCode_Target_2XX_Count,
not include any response codes generated by the load balancer.
HTTPCode_Target_3XX_Count,
HTTPCode_Target_4XX_Count,
Reporting criteria: There is a nonzero value
HTTPCode_Target_5XX_Count
Dimensions
• LoadBalancer
• AvailabilityZone, LoadBalancer
• TargetGroup, LoadBalancer
• TargetGroup, AvailabilityZone, LoadBalancer
NonStickyRequestCount The number of requests where the load balancer chose a new target
because it couldn't use an existing sticky session. For example, the
request was the first request from a new client and no stickiness cookie
was presented, a stickiness cookie was presented but it did not specify
a target that was registered with this target group, the stickiness cookie
was malformed or expired, or an internal error prevented the load
balancer from reading the stickiness cookie.
73
Elastic Load Balancing Application Load Balancers
Application Load Balancer Metrics
Metric Description
Statistics: The only valid statistic is Sum. Note that this represents the
average not the sum.
Dimensions
• TargetGroup
• TargetGroup, LoadBalancer
Dimensions
• LoadBalancer
• AvailabilityZone, LoadBalancer
• TargetGroup, LoadBalancer
• TargetGroup, AvailabilityZone, LoadBalancer
TargetResponseTime The time elapsed, in seconds, after the request leaves the load balancer
until a response from the target is received. This is equivalent to the
target_processing_time field in the access logs.
Dimensions
• LoadBalancer
• AvailabilityZone, LoadBalancer
• TargetGroup, LoadBalancer
• TargetGroup, AvailabilityZone, LoadBalancer
74
Elastic Load Balancing Application Load Balancers
Application Load Balancer Metrics
Metric Description
Dimensions
• LoadBalancer
• AvailabilityZone, LoadBalancer
• TargetGroup, LoadBalancer
• TargetGroup, AvailabilityZone, LoadBalancer
Dimensions
• TargetGroup, LoadBalancer
• TargetGroup, AvailabilityZone, LoadBalancer
The AWS/ApplicationELB namespace includes the following metrics for Lambda functions that are
registered as targets.
Metric Description
Dimensions: TargetGroup
The total number of bytes processed by the load balancer for requests to
LambdaTargetProcessedBytes
and responses from a Lambda function.
Dimensions: LoadBalancer
75
Elastic Load Balancing Application Load Balancers
Application Load Balancer Metrics
Metric Description
from the function that is malformed or missing required fields, or the
size of the request body or response exceeded the maximum size of 1
MB. To get the error reason codes, check the error_reason field of the
access log.
Dimensions: TargetGroup
The AWS/ApplicationELB namespace includes the following metrics for user authentication.
Metric Description
Dimensions: LoadBalancer
Dimensions: LoadBalancer
ELBAuthLatency The time elapsed, in milliseconds, to query the IdP for the ID token
and user info. If one or more of these operations fail, this is the time to
failure.
Dimensions: LoadBalancer
The number of times the load balancer successfully refreshed user claims
ELBAuthRefreshTokenSuccess
using a refresh token provided by the IdP.
Dimensions: LoadBalancer
76
Elastic Load Balancing Application Load Balancers
Metric Dimensions for Application Load Balancers
Metric Description
ELBAuthSuccess The number of authenticate actions that were successful. This metric is
incremented at the end of the authentication workflow, after the load
balancer has retrieved the user claims from the IdP.
Dimensions: LoadBalancer
The number of times that a configured IdP returned user claims that
ELBAuthUserClaimsSizeExceeded
exceeded 11K bytes in size.
Dimensions: LoadBalancer
Dimension Description
LoadBalancer Filters the metric data by load balancer. Specify the load balancer as follows:
app/load-balancer-name/1234567890123456 (the final portion of the load
balancer ARN).
TargetGroup Filters the metric data by target group. Specify the target group as follows:
targetgroup/target-group-name/1234567890123456 (the final portion of
the target group ARN).
The Minimum and Maximum statistics reflect the minimum and maximum reported by the individual
load balancer nodes. For example, suppose there are 2 load balancer nodes. One node has
HealthyHostCount with a Minimum of 2, a Maximum of 10, and an Average of 6, while the other node
has HealthyHostCount with a Minimum of 1, a Maximum of 5, and an Average of 3. Therefore, the
load balancer has a Minimum of 1, a Maximum of 10, and an Average of about 4.
The Sum statistic is the aggregate value across all load balancer nodes. Because metrics include multiple
reports per period, Sum is only applicable to metrics that are aggregated across all load balancer nodes.
The SampleCount statistic is the number of samples measured. Because metrics are gathered
based on sampling intervals and events, this statistic is typically not useful. For example, with
77
Elastic Load Balancing Application Load Balancers
View CloudWatch Metrics for Your Load Balancer
HealthyHostCount, SampleCount is based on the number of samples that each load balancer node
reports, not the number of healthy hosts.
A percentile indicates the relative standing of a value in a data set. You can specify any percentile,
using up to two decimal places (for example, p95.45). For example, the 95th percentile means that
95 percent of the data is below this value and 5 percent is above. Percentiles are often used to isolate
anomalies. For example, suppose that an application serves the majority of requests from a cache in 1-2
ms, but in 100-200 ms if the cache is empty. The maximum reflects the slowest case, around 200 ms.
The average doesn't indicate the distribution of the data. Percentiles provide a more meaningful view of
the application's performance. By using the 99th percentile as an Auto Scaling trigger or a CloudWatch
alarm, you can target that no more than 1 percent of requests take longer than 2 ms to process.
Alternatively, you can view metrics for your load balancer using the CloudWatch console.
• To display only the metrics reported for your load balancers, choose Per AppELB Metrics. To view
the metrics for a single load balancer, type its name in the search field.
• To display only the metrics reported for your target groups, choose Per AppELB, per TG Metrics.
To view the metrics for a single target group, type its name in the search field.
• To display only the metrics reported for your load balancers by Availability Zone, choose Per
AppELB, per AZ Metrics. To view the metrics for a single load balancer, type its name in the search
field. To view the metrics for a single Availability Zone, type its name in the search field.
• To display only the metrics reported for your load balancers by Availability Zone and target group,
choose Per AppELB, per AZ, per TG Metrics. To view the metrics for a single load balancer, type
78
Elastic Load Balancing Application Load Balancers
Access Logs
its name in the search field. To view the metrics for a single target group, type its name in the
search field. To view the metrics for a single Availability Zone, type its name in the search field.
Use the following get-metric-statistics command get statistics for the specified metric and dimension.
Note that CloudWatch treats each unique combination of dimensions as a separate metric. You can't
retrieve statistics using combinations of dimensions that were not specially published. You must specify
the same dimensions that were used when the metrics were created.
{
"Datapoints": [
{
"Timestamp": "2016-04-18T22:00:00Z",
"Average": 0.0,
"Unit": "Count"
},
{
"Timestamp": "2016-04-18T04:00:00Z",
"Average": 0.0,
"Unit": "Count"
},
...
],
"Label": "UnHealthyHostCount"
}
Access logging is an optional feature of Elastic Load Balancing that is disabled by default. After you
enable access logging for your load balancer, Elastic Load Balancing captures the logs and stores them in
the Amazon S3 bucket that you specify as compressed files. You can disable access logging at any time.
If you enable server-side encryption with Amazon S3-managed encryption keys (SSE-S3) for your
S3 bucket, each access log file is automatically encrypted before it is stored in your S3 bucket and
decrypted when you access it. You do not need to take any action as there is no difference in the way
you access encrypted or unencrypted log files. Each log file is encrypted with a unique key employing
strong multi-factor encryption. As an additional safeguard, the key itself is encrypted with a master
79
Elastic Load Balancing Application Load Balancers
Access Log Files
key that is regularly rotated. This protects the log data stored in your S3 bucket and meets compliance
requirements for data at rest. For more information, see Protecting Data Using Server-Side Encryption
with Amazon S3-Managed Encryption Keys (SSE-S3) in the Amazon Simple Storage Service Developer
Guide.
There is no additional charge for access logs. You are charged storage costs for Amazon S3, but not
charged for the bandwidth used by Elastic Load Balancing to send log files to Amazon S3. For more
information about storage costs, see Amazon S3 Pricing.
Contents
• Access Log Files (p. 80)
• Access Log Entries (p. 81)
• Bucket Permissions (p. 86)
• Enable Access Logging (p. 89)
• Disable Access Logging (p. 90)
• Processing Access Log Files (p. 90)
The file names of the access logs use the following format:
bucket[/prefix]/AWSLogs/aws-account-id/elasticloadbalancing/region/yyyy/mm/dd/aws-account-
id_elasticloadbalancing_region_load-balancer-id_end-time_ip-address_random-string.log.gz
bucket
The prefix (logical hierarchy) in the bucket. If you don't specify a prefix, the logs are placed at the
root level of the bucket.
aws-account-id
The resource ID of the load balancer. If the resource ID contains any forward slashes (/), they are
replaced with periods (.).
end-time
The date and time that the logging interval ended. For example, an end time of 20140215T2340Z
contains entries for requests made between 23:35 and 23:40.
ip-address
The IP address of the load balancer node that handled the request. For an internal load balancer, this
is a private IP address.
80
Elastic Load Balancing Application Load Balancers
Access Log Entries
random-string
s3://my-bucket/prefix/AWSLogs/123456789012/elasticloadbalancing/us-
east-2/2016/05/01/123456789012_elasticloadbalancing_us-east-2_my-
loadbalancer_20140215T2340Z_172.160.001.192_20sg8hgm.log.gz
You can store your log files in your bucket for as long as you want, but you can also define Amazon S3
lifecycle rules to archive or delete log files automatically. For more information, see Object Lifecycle
Management in the Amazon Simple Storage Service Developer Guide.
Each log entry contains the details of a single request (or connection in the case of WebSockets) made
to the load balancer. For WebSockets, an entry is written only after the connection is closed. If the
upgraded connection can't be established, the entry is the same as for an HTTP or HTTPS request.
Important
Elastic Load Balancing logs requests on a best-effort basis. We recommend that you use access
logs to understand the nature of the requests, not as a complete accounting of all requests.
Syntax
The following table describes the fields of an access log entry, in order. All fields are delimited by spaces.
When new fields are introduced, they are added to the end of the log entry. You should ignore any fields
at the end of the log entry that you were not expecting.
Field Description
type The type of request or connection. The possible values are as follows (ignore
any other values):
• http — HTTP
• https — HTTP over SSL/TLS
• h2 — HTTP/2 over SSL/TLS
• ws — WebSockets
• wss — WebSockets over SSL/TLS
timestamp The time when the load balancer generated a response to the client, in ISO
8601 format. For WebSockets, this is the time when the connection is closed.
elb The resource ID of the load balancer. If you are parsing access log entries,
note that resources IDs can contain forward slashes (/).
target:port The IP address and port of the target that processed this request.
81
Elastic Load Balancing Application Load Balancers
Access Log Entries
Field Description
If the client didn't send a full request, the load balancer can't dispatch the
request to a target, and this value is set to -.
If the request is blocked by AWS WAF, this value is set to - and the value of
elb_status_code is set to 403.
request_processing_time The total time elapsed (in seconds, with millisecond precision) from the time
the load balancer received the request until the time it sent it to a target.
This value is set to -1 if the load balancer can't dispatch the request to a
target. This can happen if the target closes the connection before the idle
timeout or if the client sends a malformed request.
This value can also be set to -1 if the registered target does not respond
before the idle timeout.
target_processing_time The total time elapsed (in seconds, with millisecond precision) from the time
the load balancer sent the request to a target until the target started to
send the response headers.
This value is set to -1 if the load balancer can't dispatch the request to a
target. This can happen if the target closes the connection before the idle
timeout or if the client sends a malformed request.
This value can also be set to -1 if the registered target does not respond
before the idle timeout.
response_processing_timeThe total time elapsed (in seconds, with millisecond precision) from the
time the load balancer received the response header from the target until
it started to send the response to the client. This includes both the queuing
time at the load balancer and the connection acquisition time from the load
balancer to the client.
This value is set to -1 if the load balancer can't send the request to a target.
This can happen if the target closes the connection before the idle timeout
or if the client sends a malformed request.
elb_status_code The status code of the response from the load balancer.
target_status_code The status code of the response from the target. This value is recorded only
if a connection was established to the target and the target sent a response.
Otherwise, it is set to -.
received_bytes The size of the request, in bytes, received from the client (requester). For
HTTP requests, this includes the headers. For WebSockets, this is the total
number of bytes received from the client on the connection.
sent_bytes The size of the response, in bytes, sent to the client (requester). For HTTP
requests, this includes the headers. For WebSockets, this is the total number
of bytes sent to the client on the connection.
"request" The request line from the client, enclosed in double quotes and logged
using the following format: HTTP method + protocol://host:port/uri + HTTP
version.
82
Elastic Load Balancing Application Load Balancers
Access Log Entries
Field Description
"user_agent" A User-Agent string that identifies the client that originated the request,
enclosed in double quotes. The string consists of one or more product
identifiers, product[/version]. If the string is longer than 8 KB, it is truncated.
ssl_cipher [HTTPS listener] The SSL cipher. This value is recorded only if the incoming
connection was established after a successful negotiation. Otherwise, it is
set to -.
ssl_protocol [HTTPS listener] The SSL protocol. This value is recorded only if the
incoming connection was established after a successful negotiation.
Otherwise, it is set to -.
"domain_name" [HTTPS listener] The SNI domain provided by the client during the TLS
handshake, enclosed in double quotes. This value is set to - if the client
doesn't support SNI or the domain doesn't match a certificate and the
default certificate is presented to the client.
"chosen_cert_arn" [HTTPS listener] The ARN of the certificate presented to the client, enclosed
in double quotes. This value is set to session-reused if the session is
reused.
matched_rule_priority The priority value of the rule that matched the request. If a rule matched,
this is a value from 1 to 50,000. If no rule matched and the default action
was taken, this value is set to 0. If an error occurs during rules evaluation, it
is set to -1. For any other error, it is set to -.
request_creation_time The time when the load balancer received the request from the client, in ISO
8601 format.
"actions_executed" The actions taken when processing the request, enclosed in double quotes.
This value is a comma-separated list that can include the following possible
values: waf, waf-failed, authenticate, redirect, fixed-response,
and forward. If no action was taken, such as for a malformed request, this
value is set to -.
"redirect_url" The URL of the redirect target for the location header of the HTTP response,
enclosed in double quotes. If no redirect actions were taken, this value is set
to -.
"error_reason" The reason code, enclosed in double quotes. If the request to the Lambda
function succeeded, this value is set to -. If the request failed, this is one of
the error codes described in Error Reason Codes (p. 83). If the target is
not a Lambda function, this value is set to -.
83
Elastic Load Balancing Application Load Balancers
Access Log Entries
84
Elastic Load Balancing Application Load Balancers
Access Log Entries
Examples
The following are example log entries. Note that the text appears on multiple lines only to make them
easier to read.
The following is an example log entry for an HTTP listener (port 80 to port 80):
The following is an example log entry for an HTTPS listener (port 443 to port 80):
h2 2018-07-02T22:23:00.186641Z app/my-loadbalancer/50dc6c495c0c9188
10.0.1.252:48160 10.0.0.66:9000 0.000 0.002 0.000 200 200 5 257
"GET https://10.0.2.105:773/ HTTP/2.0" "curl/7.46.0" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2
arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067
"Root=1-58337327-72bd00b0343d75b906739c42" "-" "-"
1 2018-07-02T22:22:48.364000Z "redirect" "https://example.com:80/" "-"
ws 2018-07-02T22:23:00.186641Z app/my-loadbalancer/50dc6c495c0c9188
10.0.0.140:40914 10.0.1.192:8010 0.001 0.003 0.000 101 101 218 587
"GET http://10.0.0.30:80/ HTTP/1.1" "-" - -
85
Elastic Load Balancing Application Load Balancers
Bucket Permissions
arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067
"Root=1-58337364-23a8c76965a2ef7629b185e3" "-" "-"
1 2018-07-02T22:22:48.364000Z "forward" "-" "-"
The following is an example log entry for a request to a Lambda function that succeeded:
The following is an example log entry for a request to a Lambda function that failed:
Bucket Permissions
When you enable access logging, you must specify an S3 bucket for the access logs. The bucket must
meet the following requirements.
Requirements
• The bucket must be located in the same region as the load balancer.
• The bucket must have a bucket policy that grants Elastic Load Balancing permission to write the access
logs to your bucket. Bucket policies are a collection of JSON statements written in the access policy
language to define access permissions for your bucket. Each statement includes information about a
single permission and contains a series of elements.
Use one of the following options to prepare an S3 bucket for the access logs.
Options
• If you need to create a bucket and you plan to use the console to enable access logging, you can skip
to Enable Access Logging (p. 89) and select the option to have the console create the bucket and
bucket policy for you.
• If you need to create a bucket for your access logs and you are using the AWS CLI or an API, use the
following procedure to create the bucket and add the required bucket policy manually.
86
Elastic Load Balancing Application Load Balancers
Bucket Permissions
• If you already have a bucket for your access logs, open the Amazon S3 console per step 1 of the
following procedure and then skip to step 4 to add or update the bucket policy.
a. For Bucket Name, enter a name for your bucket (for example, my-loadbalancer-logs). This
name must be unique across all existing bucket names in Amazon S3. In some regions, there
might be additional restrictions on bucket names. For more information, see Bucket Restrictions
and Limitations in the Amazon Simple Storage Service Developer Guide.
b. For Region, select the region where you created your load balancer.
c. Choose Create.
4. Select the bucket and choose Permissions.
5. Choose Bucket Policy. If your bucket already has an attached policy, you can add the required
statement to the existing policy.
6. Choose Policy generator. On the AWS Policy Generator page, do the following:
87
Elastic Load Balancing Application Load Balancers
Bucket Permissions
* These regions requires a separate account. For more information, see AWS GovCloud (US-
West) and China (Beijing).
d. For Actions, choose PutObject to allow Elastic Load Balancing to store objects in the S3
bucket.
e. For Amazon Resource Name (ARN), enter the ARN of your S3 bucket in the following format.
For aws-account-id, specify the ID of the AWS account that owns the load balancer (for
example, 123456789012).
arn:aws:s3:::bucket/prefix/AWSLogs/aws-account-id/*
Note that if you are using the us-gov-west-1 region, specify arn:aws-us-gov instead of
arn:aws in the ARN.
f. Choose Add Statement, Generate Policy. The policy document should be similar to the
following:
{
"Id": "Policy1429136655940",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1429136633762",
"Action": [
"s3:PutObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::my-loadbalancer-logs/my-app/AWSLogs/123456789012/
*",
"Principal": {
"AWS": [
"797873946194"
]
}
}
]
}
88
Elastic Load Balancing Application Load Balancers
Enable Access Logging
g. If you are creating a new bucket policy, copy the entire policy document, and then choose Close.
If you are editing an existing bucket policy, copy the new statement from the policy document
(the text between the [ and ] of the Statement element), and then choose Close.
7. Go back to the Amazon S3 console and paste the policy into the text area as appropriate.
8. Choose Save.
To verify that Elastic Load Balancing created a test file in your S3 bucket
After access logging is enabled for your load balancer, Elastic Load Balancing validates the S3 bucket and
creates a test file to ensure that the bucket policy specifies the required permissions. You can use the
Amazon S3 console to verify that the test file was created. Note that the test file is not an actual access
log file; it doesn't contain example records.
my-bucket/prefix/AWSLogs/123456789012/ELBAccessLogTestFile
89
Elastic Load Balancing Application Load Balancers
Disable Access Logging
After you enable access logging, be sure to disable access logging before you delete the bucket with
your access logs. Otherwise, if there is a new bucket with the same name and the required bucket policy
created in an AWS account that you don't own, Elastic Load Balancing could write the access logs for
your load balancer to this new bucket.
If there is a lot of demand on your website, your load balancer can generate log files with gigabytes
of data. You might not be able to process such a large amount of data using line-by-line processing.
Therefore, you might have to use analytical tools that provide parallel processing solutions. For example,
you can use the following analytical tools to analyze and process access logs:
• Amazon Athena is an interactive query service that makes it easy to analyze data in Amazon S3 using
standard SQL. For more information, see Querying Application Load Balancer Logs in the Amazon
Athena User Guide.
• Loggly
• Splunk
• Sumo Logic
90
Elastic Load Balancing Application Load Balancers
Syntax
If you enable access logs, the contents of the X-Amzn-Trace-Id header are logged. For more information,
see Access Logs for Your Application Load Balancer (p. 79).
Syntax
The X-Amzn-Trace-Id header contains fields with the following format:
Field=version-time-id
Field
The name of the field. The supported values are Root and Self.
An application can add arbitrary fields for its own purposes. The load balancer preserves these fields
but does not use them.
version
Examples
If the X-Amzn-Trace-Id header is not present on an incoming request, the load balancer generates a
header with a Root field and forwards the request. For example:
X-Amzn-Trace-Id: Root=1-67891233-abcdef012345678912345678
If the X-Amzn-Trace-Id header is present and has a Root field, the load balancer inserts a Self field and
forwards the request. For example:
X-Amzn-Trace-Id: Self=1-67891234-12456789abcdef012345678;Root=1-67891233-
abcdef012345678912345678
If an application adds a header with a Root field and a custom field, the load balancer preserves both
fields, inserts a Self field, and forwards the request:
X-Amzn-Trace-Id: Self=1-67891234-12456789abcdef012345678;Root=1-67891233-
abcdef012345678912345678;CalledFrom=app
If the X-Amzn-Trace-Id header is present and has a Self field, the load balancer updates the value of
the Self field.
Limitations
• The load balancer updates the header when it receives an incoming request, not when it receives a
response.
• If the HTTP headers are greater than 7 KB, the load balancer rewrites the X-Amzn-Trace-Id header
with a Root field.
91
Elastic Load Balancing Application Load Balancers
CloudTrail Logs
• With WebSockets, you can trace only until the upgrade request is successful.
To learn more about CloudTrail, see the AWS CloudTrail User Guide.
To monitor other actions for your load balancer, such as when a client makes a request to your
load balancer, use access logs. For more information, see Access Logs for Your Application Load
Balancer (p. 79).
For an ongoing record of events in your AWS account, including events for Elastic Load Balancing, create
a trail. A trail enables CloudTrail to deliver log files to an Amazon S3 bucket. By default, when you create
a trail in the console, the trail applies to all AWS regions. The trail logs events from all regions in the
AWS partition and delivers the log files to the Amazon S3 bucket that you specify. Additionally, you can
configure other AWS services to further analyze and act upon the event data collected in CloudTrail logs.
For more information, see the following:
All Elastic Load Balancing actions for Application Load Balancers are logged by CloudTrail and are
documented in the Elastic Load Balancing API Reference version 2015-12-01. For example, calls to the
CreateLoadBalancer and DeleteLoadBalancer actions generate entries in the CloudTrail log files.
Every event or log entry contains information about who generated the request. The identity
information helps you determine the following:
• Whether the request was made with root or AWS Identity and Access Management (IAM) user
credentials.
• Whether the request was made with temporary security credentials for a role or federated user.
• Whether the request was made by another AWS service.
92
Elastic Load Balancing Application Load Balancers
Understanding Elastic Load Balancing Log File Entries
The log files include events for all AWS API calls for your AWS account, not just Elastic Load Balancing
API calls. You can locate calls to the Elastic Load Balancing API by checking for eventSource elements
with the value elasticloadbalancing.amazonaws.com. To view a record for a specific action, such
as CreateLoadBalancer, check for eventName elements with the action name.
The following are example CloudTrail log records for Elastic Load Balancing for a user who created
an Application Load Balancer and then deleted it using the AWS CLI. You can identify the CLI using
the userAgent elements. You can identify the requested API calls using the eventName elements.
Information about the user (Alice) can be found in the userIdentity element.
{
"eventVersion": "1.03",
"userIdentity": {
"type": "IAMUser",
"principalId": "123456789012",
"arn": "arn:aws:iam::123456789012:user/Alice",
"accountId": "123456789012",
"accessKeyId": "AKIAIOSFODNN7EXAMPLE",
"userName": "Alice"
},
"eventTime": "2016-04-01T15:31:48Z",
"eventSource": "elasticloadbalancing.amazonaws.com",
"eventName": "CreateLoadBalancer",
"awsRegion": "us-west-2",
"sourceIPAddress": "198.51.100.1",
"userAgent": "aws-cli/1.10.10 Python/2.7.9 Windows/7 botocore/1.4.1",
"requestParameters": {
"subnets": ["subnet-8360a9e7","subnet-b7d581c0"],
"securityGroups": ["sg-5943793c"],
"name": "my-load-balancer",
"scheme": "internet-facing"
},
"responseElements": {
"loadBalancers":[{
"type": "application",
"loadBalancerName": "my-load-balancer",
"vpcId": "vpc-3ac0fb5f",
"securityGroups": ["sg-5943793c"],
"state": {"code":"provisioning"},
"availabilityZones": [
{"subnetId":"subnet-8360a9e7","zoneName":"us-west-2a"},
{"subnetId":"subnet-b7d581c0","zoneName":"us-west-2b"}
],
"dNSName": "my-load-balancer-1836718677.us-west-2.elb.amazonaws.com",
"canonicalHostedZoneId": "Z2P70J7HTTTPLU",
"createdTime": "Apr 11, 2016 5:23:50 PM",
"loadBalancerArn": "arn:aws:elasticloadbalancing:us-
west-2:123456789012:loadbalancer/app/my-load-balancer/ffcddace1759e1d0",
"scheme": "internet-facing"
}]
93
Elastic Load Balancing Application Load Balancers
Understanding Elastic Load Balancing Log File Entries
},
"requestID": "b9960276-b9b2-11e3-8a13-f1ef1EXAMPLE",
"eventID": "6f4ab5bd-2daa-4d00-be14-d92efEXAMPLE",
"eventType": "AwsApiCall",
"apiVersion": "2015-12-01",
"recipientAccountId": "123456789012"
}
{
"eventVersion": "1.03",
"userIdentity": {
"type": "IAMUser",
"principalId": "123456789012",
"arn": "arn:aws:iam::123456789012:user/Alice",
"accountId": "123456789012",
"accessKeyId": "AKIAIOSFODNN7EXAMPLE",
"userName": "Alice"
},
"eventTime": "2016-04-01T15:31:48Z",
"eventSource": "elasticloadbalancing.amazonaws.com",
"eventName": "DeleteLoadBalancer",
"awsRegion": "us-west-2",
"sourceIPAddress": "198.51.100.1",
"userAgent": "aws-cli/1.10.10 Python/2.7.9 Windows/7 botocore/1.4.1",
"requestParameters": {
"loadBalancerArn": "arn:aws:elasticloadbalancing:us-
west-2:123456789012:loadbalancer/app/my-load-balancer/ffcddace1759e1d0"
},
"responseElements": null,
"requestID": "349598b3-000e-11e6-a82b-298133eEXAMPLE",
"eventID": "75e81c95-4012-421f-a0cf-babdaEXAMPLE",
"eventType": "AwsApiCall",
"apiVersion": "2015-12-01",
"recipientAccountId": "123456789012"
}
94
Elastic Load Balancing Application Load Balancers
A registered target is not in service
Issues
• A registered target is not in service (p. 95)
• Clients cannot connect to an Internet-facing load balancer (p. 96)
• The load balancer sends requests to unhealthy targets (p. 96)
• The load balancer generates an HTTP error (p. 96)
• A target generates an HTTP error (p. 98)
Verify that your instance is failing health checks and then check for the following:
The security group associated with an instance must allow traffic from the load balancer using the
health check port and health check protocol. You can add a rule to the instance security group to
allow all traffic from the load balancer security group. Also, the security group for your load balancer
must allow traffic to the instances.
A network access control list (ACL) does not allow traffic
The network ACL associated with the subnets for your instances must allow inbound traffic on
the health check port and outbound traffic on the ephemeral ports (1024-65535). The network
ACL associated with the subnets for your load balancer nodes must allow inbound traffic on the
ephemeral ports and outbound traffic on the health check and ephemeral ports.
The ping path does not exist
Create a target page for the health check and specify its path as the ping path.
The connection times out
First, verify that you can connect to the target directly from within the network using the private IP
address of the target and the health check protocol. If you can't connect, check whether the instance
is over-utilized, and add more targets to your target group if it is too busy to respond. If you can
connect, it is possible that the target page is not responding before the health check timeout period.
Choose a simpler target page for the health check or adjust the health check settings.
The target did not return a successful response code
By default, the success code is 200, but you can optionally specify additional success codes when you
configure health checks. Confirm the success codes that the load balancer is expecting and that your
application is configured to return these codes on success.
95
Elastic Load Balancing Application Load Balancers
Clients cannot connect to an Internet-facing load balancer
Verify that you specified public subnets for your load balancer. A public subnet has a route to the
Internet Gateway for your virtual private cloud (VPC).
A security group or network ACL does not allow traffic
The security group for the load balancer and any network ACLs for the load balancer subnets must
allow inbound traffic from the clients and outbound traffic to the clients on the listener ports.
Errors
• HTTP 400: Bad Request (p. 96)
• HTTP 401: Unauthorized (p. 97)
• HTTP 403: Forbidden (p. 97)
• HTTP 414: URI Too Long (p. 97)
• HTTP 460 (p. 97)
• HTTP 463 (p. 97)
• HTTP 500: Internal Server Error (p. 97)
• HTTP 502: Bad Gateway (p. 97)
• HTTP 503: Service Unavailable (p. 98)
• HTTP 504: Gateway Timeout (p. 98)
• HTTP 561: Unauthorized (p. 98)
• The client sent a malformed request that does not meet the HTTP specification.
• The request header exceeded 16K per request line, 16K per single header, or 64K for the entire header.
96
Elastic Load Balancing Application Load Balancers
HTTP 401: Unauthorized
HTTP 460
The load balancer received a request from a client, but the client closed the connection with the load
balancer before the idle timeout period elapsed.
Check whether the client timeout period is greater than the idle timeout period for the load balancer.
Ensure that your target provides a response to the client before the client timeout period elapses, or
increase the client timeout period to match the load balancer idle timeout, if the client supports this.
HTTP 463
The load balancer received an X-Forwarded-For request header with more than 30 IP addresses.
• You configured an AWS WAF web access control list (web ACL) and there was an error executing the
web ACL rules.
• You configured a listener rule to authenticate users, but one of the following is true:
• The load balancer is unable to communicate with the IdP token endpoint or the IdP user info
endpoint. Verify that the security groups for your load balancer and the network ACLs for your VPC
allow outbound access to these endpoints. Verify that your VPC has internet access. If you have an
internal-facing load balancer, use a NAT gateway to enable internet access.
• The size of the claims returned by the IdP exceeded the maximum size supported by the load
balancer.
• A client submitted an HTTP/1.0 request without a host header, and the load balancer was unable to
generate a redirect URL.
• A client submitted a request without an HTTP protocol, and the load balancer was unable to
generate a redirect URL.
• The requested scope doesn't return an ID token.
• The load balancer received a TCP RST from the target when attempting to establish a connection.
97
Elastic Load Balancing Application Load Balancers
HTTP 503: Service Unavailable
• The load balancer received an unexpected response from the target, such as "ICMP Destination
unreachable (Host unreachable)", when attempting to establish a connection. Check whether traffic is
allowed from the load balancer subnets to the targets on the target port.
• The target closed the connection with a TCP RST or a TCP FIN while the load balancer had an
outstanding request to the target. Check whether the keep-alive duration of the target is shorter than
the idle timeout value of the load balancer.
• The target response is malformed or contains HTTP headers that are not valid.
• A new target group was used but no targets have passed an initial health check yet. A target must pass
one health check to be considered healthy.
• The load balancer encountered an SSL handshake error or SSL handshake timeout (10 seconds) when
connecting to a target.
• The deregistration delay period elapsed for a request being handled by a target that was deregistered.
Increase the delay period so that lengthy operations can complete.
• The target is a Lambda function that did not respond before its configured timeout was reached.
• The load balancer failed to establish a connection to the target before the connection timeout expired
(10 seconds).
• The load balancer established a connection to the target but the target did not respond before the idle
timeout period elapsed.
• The network ACL for the subnet did not allow traffic from the targets to the load balancer nodes on
the ephemeral ports (1024-65535).
• The target returns a content-length header that is larger than the entity body. The load balancer timed
out waiting for the missing bytes.
• The target is a Lambda function that did not respond before its possible maximum configured timeout
was reached.
98
Elastic Load Balancing Application Load Balancers
Your AWS account has the following limits related to Application Load Balancers.
Regional Limits
Rule Limits
* This limit includes both your Application Load Balancers and your Classic Load Balancers.
99
Elastic Load Balancing Application Load Balancers
Lambda functions as a target This release add support November 29, 2018
to register your Lambda
functions as a target. For more
information, see Lambda
Functions as Targets (p. 60).
Fixed-response actions This release adds support for July 25, 2018
the load balancer to return a
custom HTTP response. For
more information, see Fixed-
Response Actions (p. 30).
Redirect actions This release adds support for July 25, 2018
the load balancer to redirect
requests to a different URL. For
more information, see Redirect
Actions (p. 29).
Security policies for FS and TLS This release adds security June 6, 2018
1.2 policies for Forward Secrecy
(FS) and TLS 1.2. For more
information, see Security
Policies (p. 34).
Authentication support This release adds support for the May 30, 2018
load balancer to authenticate
users of your applications
using their corporate or social
identities before routing
requests. For more information,
see Authenticate Users
Using an Application Load
Balancer (p. 41).
Slow start mode This release adds support March 24, 2018
for slow start mode, which
gradually increases the share of
requests the load balancer sends
to a newly registered target
while it warms up. For more
information, see Slow Start
Mode (p. 51).
100
Elastic Load Balancing Application Load Balancers
Resource-level permissions This release adds support for May 10, 2018
resource-level permissions and
tagging condition keys. For more
information, see Authentication
and Access Control in the Elastic
Load Balancing User Guide.
SNI support This release adds support for October 10, 2017
Server Name Indication (SNI).
For more information, see SSL
Certificates (p. 33).
IP addresses as targets This release adds support for August 31, 2017
registering IP addresses as
targets. For more information,
see Target Type (p. 49).
Security policies for TLS 1.1 and This release adds security February 6, 2017
TLS 1.2 policies for TLS 1.1 and TLS
1.2. For more information, see
Security Policies (p. 34).
Percentiles support for the This release adds support November 17, 2016
TargetResponseTime metric for the new percentile
statistics supported by
Amazon CloudWatch. For more
information, see Statistics for
Application Load Balancer
Metrics (p. 77).
New load balancer type This release of Elastic Load August 11, 2016
Balancing introduces Application
Load Balancers.
101