Skip to content

Instantly share code, notes, and snippets.

@nackjicholson
Created February 8, 2018 16:43
Show Gist options
  • Save nackjicholson/7399d45b09211dff6e77e72b61118af4 to your computer and use it in GitHub Desktop.
Save nackjicholson/7399d45b09211dff6e77e72b61118af4 to your computer and use it in GitHub Desktop.
awscli shell script to create a cloudformation stack
#!/usr/bin/env bash
STACK_NAME=$1
if [ -z "$1" ]
then
echo "No STACK_NAME argument supplied"
exit 1
fi
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Creating stack..."
STACK_ID=$( \
aws cloudformation create-stack \
--stack-name ${STACK_NAME} \
--template-body file://${DIR}/cron-batch-stack.yml \
--capabilities CAPABILITY_IAM \
--parameters file://${DIR}/parameters.json \
--tags file://${DIR}/tags.json \
| jq -r .StackId \
)
echo "Waiting on ${STACK_ID} create completion..."
aws cloudformation wait stack-create-complete --stack-name ${STACK_ID}
aws cloudformation describe-stacks --stack-name ${STACK_ID} | jq .Stacks[0].Outputs
[
{
"ParameterKey": "MyFooParam",
"ParameterValue": "bar"
}
]
[
{
"Key": "app",
"Value": "myapp"
},
{
"Key": "team",
"Value": "myteam"
},
{
"Key": "env",
"Value": "dev"
},
{
"Key": "created_by",
"Value": "nackjicholson"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment