Use the following create-app-cookie-stickiness-policy command to create an application-generated cookie stickiness policy:
aws elb create-app-cookie-stickiness-policy --load-balancer-name my-loadbalancer --policy-name my-app-cookie-policy --cookie-name my-app-cookie
Use the following set-load-balancer-policies-of-listener command to enable session stickiness for a load balancer:
aws elb set-load-balancer-policies-of-listener --load-balancer-name my-loadbalancer --load-balancer-port 443 --policy-names my-app-cookie-policy
Note
The set-load-balancer-policies-of-listener command replaces the current set of policies associated with the specified load balancer port. Every time you use this command, specify the --policy-names option to list all policies to enable.
(Optional) Use the following describe-load-balancers command to verify that the sticky policy is enabled:
aws elb describe-load-balancers --load-balancer-name my-loadbalancer
The response includes the following information, which shows that the policy is enabled for the listener on the specified port:
{