Amazon Web Services (AWS) - Modify Elastic Load Balancer (ELB) Attributes using the AWS CLI

by
Jeremy Canfield |
Updated: August 03 2023
| Amazon Web Services (AWS) articles
An Elastic Load Balancer (ELB) is typically used to load balance requests across two (or more) different EC2 instances.
The aws elbv2 describe-load-balancers command can be used to list the Elastic Load Balancers that have been created.
aws elbv2 describe-load-balancers
Something like this should be returned.
{
"LoadBalancers": [
{
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/my-load-balancer/ffd90871234abcde",
"DNSName": "my-load-balancer-371234535.us-east-1.elb.amazonaws.com",
"CanonicalHostedZoneId": "Z35SXDOTRQ7X7K",
"CreatedTime": "2023-03-28T01:23:28.410000+00:00",
"LoadBalancerName": "my-load-balancer",
"Scheme": "internet-facing",
"VpcId": "vpc-014d2fcfa335d3c01",
"State": {
"Code": "active"
},
"Type": "application",
"AvailabilityZones": [
{
"ZoneName": "us-east-1b",
"SubnetId": "subnet-03f11411234f6abcd",
"LoadBalancerAddresses": []
},
{
"ZoneName": "us-east-1a",
"SubnetId": "subnet-03123451234f7ab34",
"LoadBalancerAddresses": []
}
],
"SecurityGroups": [
"sg-0c3296123415abcd1"
],
"IpAddressType": "ipv4"
}
]
}
The aws elbv2 modify-load-balancer-attributes command can be used to modify the Load Balancer attributes, using the Amazon Resource Number (ARN) from the prior command.
In thie example, the Load Balancer is configured to put it's access logs in the S3 Bucket named my-bucket-abdefg.
aws elbv2 modify-load-balancer-attributes \
--load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/my-load-balanacer/ffd90871234abcde \
--attributes \
Key=access_logs.s3.enabled,Value=true \
Key=access_logs.s3.bucket,Value=my-bucket-abcdefg \
Key=access_logs.s3.prefix,Value=elb-logs
Did you find this article helpful?
If so, consider buying me a coffee over at