Question:
I would like to clone a cloudformation stack in the same region. Is this possible today using the Cloudformation console?
I have a cloudformation template that takes in a big list of parameters. Many times I want to create an identical stack with just a different stack name. Is there a quick way of doing this using the AWS console?
I am thinking of something along the lines of “Launch more like this” option in EC2.
Answer:
I use the following shell script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#!/bin/sh -x # debug if [ -z "$1" ] ; then STACK=jirithhu-monitorStack-1ALS8UFQP3SRV else STACK="$1" fi set -e # parameter 1: stack ID : (example: hhu-monitorStack-1ALS8UFQP3SRV ) aws cloudformation describe-stacks --stack-name $STACK | jq .Stacks[0].Parameters > /tmp/xx.$.pars aws cloudformation get-template --stack-name $STACK | jq -rc .TemplateBody > /tmp/xx.$.body NEWNAME=`echo "COPY-$STACK"` aws cloudformation create-stack --stack-name $NEWNAME \ --template-body file:///tmp/xx.$.body\ --parameters "`cat /tmp/xx.$.pars`" \ --capabilities '[ "CAPABILITY_NAMED_IAM", "CAPABILITY_AUTO_EXPAND" ]' rm /tmp/xx.$* |