Last active
June 17, 2020 02:18
-
-
Save chrismckinnel/62a7846f2dea4d8e821d1126b69416c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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