Skip to content

Instantly share code, notes, and snippets.

@chrismckinnel
Last active June 17, 2020 02:18
Show Gist options
  • Save chrismckinnel/62a7846f2dea4d8e821d1126b69416c2 to your computer and use it in GitHub Desktop.
Save chrismckinnel/62a7846f2dea4d8e821d1126b69416c2 to your computer and use it in GitHub Desktop.
# Function to automatically call cfn-lint when deploying AWS CloudFormation templates
function aws() {
export COMMAND=$@
if [[ $COMMAND == cloudformation\ create-stack* ]] || [[ $COMMAND == cloudformation\ update-stack* ]];
then
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--template-body)
filename="$2"
shift
shift
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
cfn-lint validate ${filename#"file://"}
fi
/usr/local/bin/aws $COMMAND
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment