Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
AWS Cloud Formation
3.
Working
3.1.
Steps
4.
Concepts
4.1.
Templates
4.2.
Stacks
4.3.
Changing Sets
5.
Custom Resources
6.
Drift detection
7.
Mapping and StackSets
7.1.
Mapping 
7.2.
StackSets
8.
Limitations
9.
Frequently Asked Questions
9.1.
What is AWS Cloud Formation?
9.2.
What are the benefits of AWS Cloud Formation?
9.3.
How can we create and delete AWS stacks?
10.
Conclusion
Last Updated: Mar 27, 2024

AWS Cloud Formation

Author Anju Jaiswal
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

It can be challenging to manage an extensive infrastructure with multiple services and laborious and time-consuming to create and maintain several AWS resources. Doing so may cause you to spend more time maintaining your AWS resources rather than developing your applications.

What possibilities do we have for dealing with this problem?

                                           

                                                            Source - Link

 

AWS Cloud Formation can be of benefit. AWS Cloud Formation is a solution that supports you with cloud infrastructure modeling and deployment. You will be able to spend less time managing your AWS resources and more time working on your AWS-based apps due to deploying cloud architecture and configuring your AWS resources.

AWS Cloud Formation

AWS CloudFormation is an AWS tool that automates the setup of AWS resources by using template files.

Because it can automate the deployment of various Infrastructure-as-a-Service (IaaS) services on the AWS  and setup, it's also known as infrastructure automation or Infrastructure-as-Code (IaC) tool and a cloud automation solution. CloudFormation supports almost every AWS service.

 

                                                             Source - Link

You may manage your whole infrastructure or AWS resources in a text file or template with AWS Cloud Formation. A stack is a grouping of AWS services. You can use a stack to generate or edit AWS resources.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Working

AWS Cloud Formation performs underlying service calls to AWS to provision and configure your resources when creating a stack.

Steps

  • Using the JSON or YAML formats, create a new template or use an existing CloudFormation template.

                                         Source - Link

  • Locally or in an S3 bucket, save your code template.
  • To create a stack on your own, use AWS Cloud Formation.
  • AWS CloudFormation creates and configures the resources in your stack that you specify in your template.

Concepts

You deal with templates and stacks when you implement AWS Cloud Formation. Templates are used to describe your AWS resources and their characteristics. CloudFormation creates the resources specified in your template when you develop a stack.

Templates

Templates make it simple to deploy all of the resources needed in an application. You can also reuse your templates across various environments to replicate your infrastructure. Use the parameters, mappings, and conditions sections in the template to make it reusable so you may alter your stacks when you create them.

Stacks

When using Cloud Formation, you manage associated resources as a single entity known as a stack. By constructing, updating, and removing stacks, you can create, edit, and destroy a collection of resources.

 

                                                        Source - Link

The Cloud Formation template for the stack defines all of the stack's resources. Assume you established a template with an Auto Scaling group and Amazon Relational Database Service (Amazon RDS) database instance with an Elastic Load Balancing load balancer. You create a stack by sending CloudFormation the template you created to supply those resources, and CloudFormation takes care of the rest.

Changing Sets

You update a stack if you need to alter the running resources. You can create a change set, a summary of your proposed modifications, before making changes to your resources. Before adopting changes, you may use change sets to evaluate how they can affect your operating resources, especially essential ones.

 

                     

                                               Source - link

If you rename an Amazon RDS database instance, CloudFormation will build a new database and remove the old one. Unless you've already backed up the data in the old database, you'll lose it. If you produce a change set, you'll be able to see how your modification will affect your database, and you'll be able to plan before updating your stack.

Custom Resources

When you create, update, or delete stacks, AWS Cloud Formation allows you to generate custom resources by utilizing AWS Lambda functions to write custom provisioning logic in Cloud Formation templates. This enables Cloud Formation to be extended in different manners. While Lambda is a powerful tool, some jobs, such as container development and testing, necessitate a longer-running computing environment with fewer constraints.

Offloading the custom resource request to a system or service other than Lambda is an option. This is especially handy for time-consuming processes like building container images as part of a CloudFormation stack.

                                                          source-link      

You may utilize the flexibility of a containerized compute environment by using AWS CodeBuild as a long-lived compute environment to develop container images and import them into the Amazon Elastic Container Registry (Amazon ECR) image repository.

While this example builds a Docker container image, the more general pattern of launching a CodeBuild job from a CloudFormation template may apply to other long-lived compute activities.

                     

                                      source-link      

A custom Lambda-backed resource within the CloudFormation template starts a CodeBuild project. The CodeBuild resource contains code that signals to CloudFormation whether the Lambda-backed custom resource was successful or unsuccessful based on the build's success or failure.

Drift detection

  • Cloud Formation allows you to model and provision cloud resources as code safely, reasonably, and consistently.
  • With drift detection enabled, you may use the AWS administration console, CLI, and SDKs to see if your stack's configuration has changed outside of Cloud Formation.
  • Drift detection allows all users to see if the actual configuration of stack resources differs from the intended configuration or if it has drifted.
  • Cloud Formation will generate detailed information on each resource in the drifted stack. If drift detection is enabled for a particular resource, it is considered drifted if its current property value differs from the expected values.

Mapping and StackSets

Mapping 

A CloudFormation template's mappings section matches a key to a corresponding set of named values. Suppose you want to configure values based on a region, for example. In that case, you can create a mapping that utilizes the AWS region name as a key and contains the values you wish to provide based on the region where the template is deployed. Mapping is convenient when deploying AMIs globally and needing to deploy a separate AMI ID for each location owing to disaster recovery or security concerns that change across geographic regions.

StackSets

AWS Cloud Formation StackSets extend stack capabilities by allowing you to create, update, and delete stacks across multiple accounts and regions in a single action. You define and administer an AWS CloudFormation template using an administrator account and then use the template to supply stacks into selected target accounts across specified regions. For example, you can implement a global AWS CloudTrail or AWS Config policy across several accounts with a single Stack set operation. You can also utilize StackSets to deploy resources across various regions in a single account.

Limitations

Frequently Asked Questions

What is AWS Cloud Formation?

AWS Cloud Formation is a tool that makes it simple for developers and companies to assemble a collection of linked AWS and third-party resources, then provision and manage them logically and predictably.

What are the benefits of AWS Cloud Formation?

AWS Cloud Formation is beneficial in the following ways: Deployment Speed, Scaling up, Safety Controls, Service integration, and Consistency

How can we create and delete AWS stacks?

A stack is a collection of connected resources managed by AWS CloudFormation. A stack of AWS CloudFormation templates describes all resources, and stacks can be generated, updated, and destroyed to build, update, and delete a collection of resources.

Conclusion

We have demonstrated AWS Cloud Formation in this blog and covered various topics like working, concepts, and Custom References. It supports the entire AWS platform, Allowing for simple automation, Templates can be saved and reused, Drift detection, Mapping, and StackSets and its Limitations.

Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem DesignMachine learning and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc; you must look at the problemsinterview experiences, and interview bundle for placement preparations.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!!

Previous article
AWS Control Tower
Next article
AWS Cloud Trail
Live masterclass