Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to clone a Cloudformation stack in the same region?

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.

like image 920
PrasadK Avatar asked Nov 17 '22 20:11

PrasadK


1 Answers

I use the following shell script

#!/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.$$*
like image 178
Jiri Kuthan Avatar answered Dec 20 '22 21:12

Jiri Kuthan