Exploring AWS !!
Day 34:
CloudFormation: IaC (Infrastructure as Code)
Instead of creating multiple instances, databases and other resources manually, we can create a single piece of code which can be used to create multiple infrastructures. CloudFormation not only creates resource on AWS account but also waits for them to stabilize while they start. It verifies failure, then it can gracefully roll infrastructure back to a past known good state.
CloudFormation allows us to model our entire infrastructure in file. We can create or modify an existing AWS CloudFormation template. A template describes all of our resources and preparation. To make changes or modify, we can simply track the differences in our templates to check changes in our infrastructure, similar to way the developers control revisions to source code. We can also reuse our template to set up our resources consistently and repeatedly. We can just describe our resource once and then provision the same resource over and over to multiple regions.
Top Features: Authoring with JSON/YAML, Authoring with familiar programming languages, safety controls, preview changes to our environment.
Concepts:
Template: Its JSON or YAML formatted file, saved as .json, .yaml, and .template. We can specify multiple resources in single template and configuration for these resources to work together.
Stacks: We can manage related resource as single unit called stack. We can also delete entire architect by deleting stack. We can work with stack by using AWS CloudFormation console, API or AWS CLI.
Change Sets: To change the running resource, we need to update stack. We can generate a change set, which is a summary of our proposed changes. If we generate change set, we can see how our changes will cause our database to be replaced, and we will be able to plan accordingly.
How does CloudFormation work?
— Code infrastructure from scratch or use available template.
— Code locally or upload into S3 bucket.
— Use AWS CloudFormation via GUI or CLI to create a stack based on our template.
— AWS CloudFormation provisions and config resources we specified on our template.
CloudFormation Templates:
We can use AWS CloudFormation Designer or any other text editor.
CloudFormation supports:
JSON — ECMA-404, JSON Std.
YAML — Version 1.1
CloudFormation Designer:
Graphic tool for creating, viewing and modifying AWS CloudFormation templates. We can design our template resources by drag and drop and then edit.