pmac72
pmac72

Reputation: 9192

configure aws ec2 wait timeout option

Is there an option or a setting somewhere to control the timeout for an aws ec2 wait command? Or the number of attempts or waiting period between attempts?

I want to be able to aws ec2 wait instance-terminated for some instances I'm quickly spinning up to perform a few task then terminating. It times out on some longer running tasks with "Waiter InstanceTerminated failed: Max attempts exceeded".

I can't seem to find any info anywhere. I've grepped the cli source code, but my knowledge of Python is too limited for me to understand what's going on. I see there might be something in this test using maxAttempts and delay, but can't figure out how to leverage that from the cli.

So far my suboptimal solution is to sleep first, then start the wait.

Upvotes: 5

Views: 5857

Answers (2)

Pedro
Pedro

Reputation: 489

There's an open Github issue about adding configurable parameters https://github.com/aws/aws-cli/issues/1295

You can also find some environment variables you can define here

https://docs.aws.amazon.com/cli/latest/topic/config-vars.html

One of them being AWS_MAX_ATTEMPTS Number of total requests

But for my use case (restore dynamo table from snapshot) does not seem to be working

Upvotes: 0

DrStrangepork
DrStrangepork

Reputation: 3134

There is not a timeout option in the AWS CLI, but you can just use the native timeout command from coreutils to do what you want.

timeout 10 aws ec2 wait instance-terminated

will abort if the command does not return within 10 seconds. A timeout will automatically return error code 124, otherwise it returns the error code of the command.

Upvotes: 1

Related Questions