Reputation: 2051
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:
An error occurred (Throttling) when calling the ListStacks operation (reached max retries: 4): Rate exceeded
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.
Upvotes: 7
Views: 9853
Reputation: 1731
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
Upvotes: 8
Reputation: 53713
Seems you're using ListStack
for cloudformation service maybe implementing a polling and retry, a simpler solution is now built into the CLI for this: aws <service> wait <condition>
so the polling is already implemented.
$ aws cloudformation wait stack-exists --stack-name <name of the stack>
Upvotes: 2
Reputation: 1241
If you are creating some resources and waiting for that one to create successfully, AWS cli provided wait module[1] Since you want to retry for an error you can do a retry using while or until. Below code will run until command is successful.
while [ $? -ne 0 ]; do
YOUR COMMAND
GOOD CONDITION TO EXIT AFTER SOME RETRIES
done
Make sure that you are using a good condition to exit after some retries otherwise it will end up with a infinite loop.
[1] http://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/index.html
Upvotes: 0