I want to understand the idiomatic Bash (ie the Bash equivalent of 'Pythonic') way with the AWS CLI to create an AWS resource (say an AWS Cloud9 EC2 environment) and then 'poll'/'wait'/'sleep' for that resource to reach a certain state; when the AWS resources reaches the given state, the command completes and the user is able to enter commands back into the shell.
EG after the user hits Enter
[cloudshell-user@ip-10-10-10-10 ~]$ #an idiomatic Bash one-liner that combines 'aws cloud9 create-environment-ec2 --name this-resource-will-take-a-moment-to-create --instance-type t2.micro' and 'aws cloud9 describe-environments --environment-ids tHiSiDwAsThEoUtPuToFtHePrEvIoUsCoMmAnD'
Then after some time the user will see
[cloudshell-user@ip-10-10-10-10 ~]$ #an idiomatic Bash one-liner that combines 'aws cloud9 create-environment-ec2 --name this-resource-will-take-a-moment-to-create --instance-type t2.micro' and 'aws cloud9 describe-environments --environment-ids tHiSiDwAsThEoUtPuToFtHePrEvIoUsCoMmAnD'
[cloudshell-user@ip-10-10-10-10 ~]$
at which point the AWS Cloud9 EC2 environment has reached a given state.
As the create(create-,launch-, etc)/wait(get-/describe-) pattern is common among AWS services API calls and then corresponding AWS CLI commands the one-liner should be re-usable given minor changes for other services.
The Bash one-liner will be used in the CloudShell but should be portable to be used in other installations of Bash.
I have read about &&
and sleep
but would like some direction as to how to integrate these commands (or any alternative ones) in a idiomatic Bash one-liner. Also I am concerned about not violating any throttling or request limiting AWS APIs have.