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.
aws/config ), the AWS CLI will create it for you.
Each AWS SDK implements automatic retry logic. The AWS SDK for Java automatically retries requests, and you can configure the retry settings using the ClientConfiguration class.
You can get help with any command when using the AWS Command Line Interface (AWS CLI). To do so, simply type help at the end of a command name.
You can configure the AWS CLI to assume an IAM role for you in combination with MFA. If you are a power user of the CLI, you will realize that you have to enter your MFA token every 60 minutes, which is annoying.
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
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With