Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to configure retries with the AWS CLI?

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.

like image 547
Ben Butler-Cole Avatar asked Jul 06 '17 15:07

Ben Butler-Cole


People also ask

Which command line is used to configure the aws?

aws/config ), the AWS CLI will create it for you.

Does aws retry SDK?

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.

Which command is used to get AWS CLI?

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.

Does AWS CLI timeout?

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.


2 Answers

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

like image 148
Federico Avatar answered Nov 10 '22 05:11

Federico


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>
like image 34
Frederic Henri Avatar answered Nov 10 '22 04:11

Frederic Henri