Skip to content

Instantly share code, notes, and snippets.

@thalweg
Created April 16, 2013 14:19
Show Gist options
  • Save thalweg/5396274 to your computer and use it in GitHub Desktop.
Save thalweg/5396274 to your computer and use it in GitHub Desktop.
Wrapper for aws-cli validate-template
#!/usr/bin/env bash
# A simple wrapper for validating locally-stored CloudFormation templates
# Requires aws-cli <https://github.com/aws/aws-cli>
usage(){
echo "$(basename $0) <cfn.json>"
}
if (( $# == 0 )); then
usage
exit 1
fi
# Store the first arg, then shift params in case we need to pass onto aws
file="$1"
shift
if [[ -f "$file" && -r "$file" ]]; then
aws cloudformation validate-template --template-body "$(cat "$file")" "$@"
exit $?
else
echo "$file does not exist or is not readable"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment