Skip to content

Instantly share code, notes, and snippets.

@erbrito
Created October 21, 2016 14:41
Show Gist options
  • Save erbrito/ea97364dc4861c00a672bfa76fb16b3b to your computer and use it in GitHub Desktop.
Save erbrito/ea97364dc4861c00a672bfa76fb16b3b to your computer and use it in GitHub Desktop.
bash that creates an AWS Stack based on a Template. If the stack exists, it will updated it. It recevied as parameter the name of the stack. Requires to be configured the AWS credentials and be installed AWS CLI
#!/usr/bin/env bash
#bash that creates an AWS Stack based on a Template.
#If the stack exists, it will updated it.
#It recevied as parameter the name of the stack.
#Requires to be configured the AWS credentials and be installed AWS CLI
stackName=$1
function updateStack(){
echo "updating stack as it was already created"
local res=$(~/bin/aws cloudformation update-stack --stack-name $stackName --template-body file://build/resources/main/automation/cloudFormation/DynamoDbBundleTable)
echo $res
}
function createStack(){
local res=$(~/bin/aws cloudformation create-stack --stack-name $stackName --template-body file://build/resources/main/automation/cloudFormation/DynamoDbBundleTable)
echo "res: $res"
if [[ ! $res =~ .*cloudformation.* ]]
then
updateStack
fi
}
createStack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment