Skip to content

Instantly share code, notes, and snippets.

@jghaines
Created January 25, 2017 00:07
Show Gist options
  • Select an option

  • Save jghaines/6b25a48c8531c236b0ec4831f4465ce4 to your computer and use it in GitHub Desktop.

Select an option

Save jghaines/6b25a48c8531c236b0ec4831f4465ce4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# wrapper around "aws cloudformation" CLI to ignore certain pseudo-errors
# aws cloudformation deploy exits with 255 for "No changes to deploy" see: https://github.com/awslabs/serverless-application-model/issues/71
# this script exits with 0 for that case
STDERR=$(( aws cloudformation "$@" ) 2>&1)
ERROR_CODE=$?
echo ${STDERR} 1>&2
if [[ "${ERROR_CODE}" -eq "255" && "${STDERR}" =~ "No changes to deploy" ]]; then exit 0; fi
exit ${ERROR_CODE}
@khalidx
Copy link
Copy Markdown

khalidx commented May 24, 2017

Good stuff!

@MoenCertiK
Copy link
Copy Markdown

nice!

@jeroneemou
Copy link
Copy Markdown

Can be solved with --no-fail-on-empty-changeset switch now 💪

@sapporo46
Copy link
Copy Markdown

@jeroneemou - This got me out of a hole, thanks!

@latheesan-k
Copy link
Copy Markdown

You can also add this to exit gracefully after the sam deploy ... command:

if [ "$?" -eq 255 ]
then
    echo "No changes to deploy."
    true
fi

@jhford-scout24
Copy link
Copy Markdown

the PIPESTATUS variable might be useful to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment