User Tools

Site Tools


aws-cloudformation

AWS CloudFormation

To configure your AWS account

aws configure --profile <my-profile>
export AWS_PROFILE=<my-profile>

To validate a template

aws cloudformation validate-template --template-body file://./template.yml

To create a stack

aws cloudformation create-stack \
  --stack-name <my-stack> \
  --template-body file://./template.yml \
  --parameters ParameterKey=Initials,ParameterValue=<my-initials>

To describe the stack

aws cloudformation describe-stacks --stack-name <my-stack>

To update the stack directly

aws cloudformation update-stack \
  --stack-name <my-stack> \
  --template-body file://./template.yml \
    --parameters ParameterKey=Initials,ParameterValue=<my-initials>

To previsualize the changes before execution ("dry-run" feature)

aws cloudformation create-change-set \
  --stack-name <my-stack> \
  --template-body file://./template.yml \
  --parameters ParameterKey=Initials,ParameterValue=<my-initials> \
  --change-set-name changeset-1

aws cloudformation describe-change-set \
  --stack-name <my-stack> \
  --change-set-name changeset-1 | jq '.Changes[]'

aws cloudformation execute-change-set \
  --stack-name <my-stack> \
  --change-set-name changeset-1

To watch the progression of the operation on the stack (creation, update, deletion)

watch -n1 "aws cloudformation describe-stacks --stack-name <my-stack> | jq '.Stacks[0].StackStatus'"

To delete the stack at the end

aws cloudformation delete-stack --stack-name <my-stack>

aws-cloudformation.txt · Last modified: 2018/08/07 11:11 by jdx