LoginSignup
3
2

More than 5 years have passed since last update.

elastic beanstalk cliの結果をshell内で待つようにした

Posted at

aws cliでのコマンドは非同期のため、以下のようなコマンドを連続で実行しようとすると怒られます。

aws elasticbeanstalk update-environment --environment-name $PROD_ENV --template-name production

aws elasticbeanstalk swap-environment-cnames --source-environment-name $PROD_ENV --destination-environment-name $STAGE_ENV
A client error (InvalidParameterValue) occurred when calling the SwapEnvironmentCNAMEs operation: Environment 'tekitouna-env-name' is pending deployment.  Wait until the environment is available and try again.

なので待つようにしました。

npm install -g underscore-cli
while [ "Green" != $(aws elasticbeanstalk describe-environments --application-name $APP_NAME --environment-names $PROD_ENV | underscore select '.Environments .Health' --outfmt text) ]
do
  echo "hoge"
  sleep 5s
done

echo 'owatta'
3
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2