Use ModifyLoadBalancerAttributes with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use ModifyLoadBalancerAttributes with a CLI

The following code examples show how to use ModifyLoadBalancerAttributes.

CLI
AWS CLI

To modify the attributes of a load balancer

This example modifies the CrossZoneLoadBalancing attribute of the specified load balancer.

Command:

aws elb modify-load-balancer-attributes --load-balancer-name my-load-balancer --load-balancer-attributes "{\"CrossZoneLoadBalancing\":{\"Enabled\":true}}"

Output:

{ "LoadBalancerAttributes": { "CrossZoneLoadBalancing": { "Enabled": true } }, "LoadBalancerName": "my-load-balancer" }

This example modifies the ConnectionDraining attribute of the specified load balancer.

Command:

aws elb modify-load-balancer-attributes --load-balancer-name my-load-balancer --load-balancer-attributes "{\"ConnectionDraining\":{\"Enabled\":true,\"Timeout\":300}}"

Output:

{ "LoadBalancerAttributes": { "ConnectionDraining": { "Enabled": true, "Timeout": 300 } }, "LoadBalancerName": "my-load-balancer" }
PowerShell
Tools for PowerShell

Example 1: This example enables cross-zone load balancing for the specified load balancer.

Edit-ELBLoadBalancerAttribute -LoadBalancerName my-load-balancer -CrossZoneLoadBalancing_Enabled $true

Example 2: This example disables connection draining for the specified load balancer.

Edit-ELBLoadBalancerAttribute -LoadBalancerName my-load-balancer -ConnectionDraining_Enabled $false

Example 3: This example enables access logging for the specified load balancer.

Edit-ELBLoadBalancerAttribute -LoadBalancerName my-load-balancer ` >> -AccessLog_Enabled $true ` >> -AccessLog_S3BucketName amzn-s3-demo-logging-bucket ` >> -AccessLog_S3BucketPrefix my-app/prod ` >> -AccessLog_EmitInterval 60