Skip to content

Instantly share code, notes, and snippets.

@svdgraaf
Created January 6, 2017 09:53
Show Gist options
  • Save svdgraaf/6c6ab9e9263e84b838234d910409b6b6 to your computer and use it in GitHub Desktop.
Save svdgraaf/6c6ab9e9263e84b838234d910409b6b6 to your computer and use it in GitHub Desktop.
AWS CodePipeline CloudFormation template length workaround
version: 0.1
phases:
pre_build:
commands:
- pip install awscli
build:
commands:
post_build:
commands:
- aws s3 cp ./cfn-ec2.json s3://attunuri/cfn-ec2.json
- aws cloudformation create-stack --stack-name <stack_name> --template-url https://s3.amazonaws.com/<bucket>/template.json --disable-rollback || aws cloudformation update-stack --stack-name cfn-ec2 --template-url https://s3.amazonaws.com/<bucket>/template.json
# create stack cmd
exit_status=$?
if [ $exit_status -ne 0 ]
then
cmd_output="$(# update stack 2>&1)"
exit_status=$?
if [ $exit_status -ne 0 ]
then
echo "$cmd_output" | grep -q "No updates to be performed"
if [ $? -eq 0 ]
then
exit_status=0
fi
fi
fi
exit $exit_status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment