Simple guide for AWS cloud formation - part 1

WeDoIT is Cloud solutions & consulting company founded by cloud experts. As part of give back (or) knowledge sharing with community, our team has started creating these tutorials/cloud topic summaries.  Check out cloud our computing spend optimization tool INVOKE to save cloud hosting costs by 50 to 80%.

AWS CloudFormation is a service which helps you model and setup your AWS resources (in other words your AWS infrastructure).

CloudFormation service comprises 2 steps:

  1. Template creation (or) modify existing template
  2. Stack creation (in other words run/Initiate template to create group of the resources)

Template Creation

Template is a file, in which you describe the resources you would like to create during the run/initiate template phase.

Template file can be created in either JSON (or) YAML syntax. You can save these files with any extension, such as .json, .yaml, .template,or .txt.

You can design CloudFormation template in AWS CloudFormation Designer (or) in a text editor.

Stack Creation

Stack is group of related resources as a single unit. Resources in the stack are defined by the stack’s CloudFormation template. You can perform create, update & delete operations on stack. Update & delete operations modify the aws resources with in that stack.

While performing updates, it is always advisable to generate “Change Sets”  to understand what resources are being modified, otherwise you might loose some data.

For example, if you change the name of an RDS database instance, CloudFormation will create new database and delete the old one. You will lose the data in the old database unless you back it up. Change Sets will highlight these potential problems before you update your stack.


How CloudFormation works?

First step is CloudFormation is create a template using AWS CloudFormation Designer (or) text editor. This template should describe the resources you would like to create. For example, if you want to create an EC2 instance using JSON syntax, template file should contain text like below:
Save this file to with extension like .json, .yaml (or) .txt and to your S3 (or) local.

Second step  (if you would like to create new stack), is create CloudFormation stack by specifying the location of your template file. If template contains parameters, this is the step where you need to provide values for these parameters. You can create stack using either Console (or) API (or) CLI.

By using specified resource configurations and parameters, CloudFormation service makes underlying service call to AWS to provision and configure the described resources. After all the resources have been created, CloudFormation service reports that stack has been created. Once you get this message, you can start using stack resources. If stack creation fails, CloudFormation rolls back your changes by deleting the resources it created.

Second step (If you would like to update existing stack), is modify the stacks CloudFormation template, then create change set by submitting this modified version of template to CloudFormation service. CloudFormation compares the modified template with original one and generates change set. After reviewing the changes, you can execute the change set to update stack and it’s resources.

Deleting Stack

When you delete stack, you specify the stack to delete, CloudFormation deletes the stack and all the resources in that stack. If CloudFormation can’t delete a resource, stack will not be deleted. Any resources that haven’t been deleted will stay there until you delete them and corresponding stack.

If you want to delete stack but retain some resources in that stack, you can use “deletion policy”.

If you are looking for any help with migrating your solutions to cloud providers like AWS, Azure, Google (or) looking for cloud solutions architecture assistance, we are happy to talk to you to address your needs. Click  here to contact us.  

Comments

Popular posts from this blog

AWS Stop Vs Terminate Vs Reboot

How to Configure DNS with Route 53 and GoDaddy

INVOKE Cloud recognized as a Rising Star for IT Management Software by FinancesOnline Directory