Is it possible to configure retries with the AWS CLI?

Question:

I have a script which uses the AWS CLI (currently v1.11.90) to coordinate various AWS resources. Amongst other things it calls aws cloudformation list-stacks three or four times in a row.

I fairly frequently get errors because my requests are being throttled:

In particular if I happen to have the CloudFormation console open in my browser this happens pretty reliably.

I would like to configure it to be more forgiving in these cases — either to back off more aggressively, or to retry more times. I’ve tried to find a way of doing this and have seen a few references to being able to do it in boto, but I can’t see how to do it via the CLI.

Answer:

The other answers are good, but to answer the precise question: yes, define environment variable AWS_MAX_ATTEMPTS

See https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html

Leave a Reply