Monday 2 July 2018

How to Validate the AWS CloudFormation Template and execute the Dry-Run

Commands for validate the Cloudformation file and Run the CloudFormation template as a Dry-Run. The file can be in a json or yaml format To Run the below AWS commands on your terminal you should first install awscli and configure the user credentials and also a cloudformation template running in your region to which we are going to change some resources in the template and update the cfn template and run as dry-run and check the changes are valid or not and then execute the changes.

$ aws cloudformation validate-template --template-body file:///home/local/test/example.json

Working with ChangeSet:


create a changeset: aws cloudformation create-change-set --stack-name stackID|stackName --change-set-name changesetname --use-previous-template --parameters ParameterKey="InstanceType",UsePreviousValue=true ParameterKey="KeyPairName",UsePreviousValue=true ParameterKey="Purpose",ParameterValue="production"
View the changeset:
To get the ID of the change set, run the aws cloudformation list-change-sets command: aws cloudformation list-change-sets --stack-name stackID|stackName
Run the aws cloudformation describe-change-set command specifying the ID of the change set that you want to view: aws cloudformation describe-change-set --change-set-name changesetID
Execute the changeset: aws cloudformation execute-change-set --change-set-name changesetID
Delete the changeset: aws cloudformation delete-change-set --change-set-name changesetID

No comments:

Post a Comment