CloudFormation Change Sets
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have discussed CloudFormation Exports.
https://cloudaffaire.com/cloudformation-stack-export/
In this blog post, we are going to discuss change sets in cloudformation stack.
CloudFormation Change Sets:
When you need to update a stack, understanding how your changes will affect running resources before you implement them can help you update stacks with confidence. Change sets allow you to preview how proposed changes to a stack might impact your running resources, for example, whether your changes will delete or replace any critical resources, AWS CloudFormation makes the changes to your stack only when you decide to execute the change set, allowing you to decide whether to proceed with your proposed changes or explore other changes by creating another change set.
Note: Change sets don’t indicate whether AWS CloudFormation will successfully update a stack.
Next, we are going to create a change set of a stack.
Step 1: Login to AWS console and navigate to ‘CloudFormation’.
Step 2: Create a stack named ‘mySTACK’ with below YAML code.
1 2 3 4 5 6 7 8 9 10 |
AWSTemplateFormatVersion: "2010-09-09" Resources: EC2Instance: Type: "AWS::EC2::Instance" Properties: ImageId: "ami-0889b8a448de4fc44" InstanceType: "t2.micro" Tags: - Key: "Name" Value: "myINSTANCEv1" |
Or you can use change_set_demo_v1.yaml from below GitHub repo.
https://github.com/CloudAffaire/CloudFormation
Note: To shorten the code AMI id in the above has been explicitly given for MUMBAI region, create the stack in MUMBAI region only.
Next, we are going to create a change set for the stack ‘mySTACK’.
Step 3: Click ‘Create change set’ located under ‘Change sets’.
Step 4: Upload change set template using below YAML code and click ‘Next’.
1 2 3 4 5 6 7 8 9 10 |
AWSTemplateFormatVersion: "2010-09-09" Resources: EC2Instance: Type: "AWS::EC2::Instance" Properties: ImageId: "ami-0889b8a448de4fc44" InstanceType: "t2.micro" Tags: - Key: "Name" Value: "myINSTANCEv2" #changed from myINSTANCEv1 to myINSTANCEv2 |
Or you can use change_set_demo_v2.yaml from below GitHub repo.
https://github.com/CloudAffaire/CloudFormation
Leave rest of the configurations as it is and click ‘Create change set’.
Our change set successfully created. You can view the proposed changes in JSON format under ‘JSON changes’ tab of change set.
Note: We are changing the instance tag in this change set which is an online operation, hence no resource recreation is required for this change.
Note: Until and unless we execute the change set by clicking ‘Execute’ no changes will be made to the actual AWS infrastructure.
Step 5: Click ‘Execute’ to make the changes effective.
Step 6: Cleanup.
Hope you have enjoyed this article. In the next blog post, we will discuss CloudFormer.
To get more details on CloudFormation, please refer below AWS documentation
https://docs.aws.amazon.com/cloudformation/index.html