Cloudformation - Deploy cloud resources with just few clicks

Cloudformation - Deploy cloud resources with just few clicks

When we work on building an application, we often tend to use various aws cloud services through console or CLI. In case if we need to migrate the application to other aws accounts or client's accounts, we need to provision those resources again and re-work on deploying the application. This overall process may be time-consuming if you have many resources and there is an interlinked connection between these resources. You may end up missing one or the other step and the application may not work as expected. Even with concrete documentation, it still can be tedious while working with different aws services to be migrated. To overcome this problem and migrate the application with ease we have a service in aws called cloudformation.

 

What is cloudformation?

AWS CloudFormation gives you an easy way to model a collection of related AWS and third-party resources, provision them quickly and consistently, and manage them throughout their life cycles, by treating infrastructure as code. A CloudFormation template describes your desired resources and their dependencies so you can launch and configure them together as a stack. You can use a template to create, update, and delete an entire stack as a single unit, as often as you need to, instead of managing resources individually. You can manage and provision stacks across multiple AWS accounts and AWS Regions.

 

How does it work?

01

 

Does it work with serverless applications?

Yes. Fortunately all the resources we need like s3, api gateway, lambda, dynamoDB, etc can be very well defined in cloudformation. All the definitions like lambda function handler needs to be kept in s3 to be accessible for public or valid AWS account owners. All the shared resources from the primary aws account get created on your demo account by running the stacks. When you run the cloudformation stack, it's vital to provide access role permission to provide the required aws services.

 

Cloudformation components

  1. Cloudformation Stack - To run the set of instructions for provisioning the cloud resources
  2. YAML / JSON Template - To define all the required cloud resources and generate output with endpoints to be used in other resource definitions.
  3. S3 (Simple storage service) - To store the Yaml/ Json templates and resource definitions like lambda function definition
  4. IAM - To provide permissions for role to execute stack

 

Sample YML Code:

01

In the code above, first we define the aws template version and description which is used for any template. Furthermore, Resources contains different AWS services which we need to use and their configurations as per the need. The output is to get those services information or urls after those resources are provisioned on the cloud.

 

Time efficiency and Cost effectiveness

As resources are provisioned using Infrastructure as code , it's very quick to move your application resources on different AWS accounts or client’s accounts by a few clicks.If your application requires additional availability, you might replicate it in multiple regions so that if one region becomes unavailable, your users can still use your application in other regions. The challenge in replicating your application is that it also requires you to replicate your resources. Not only do you need to record all the resources that your application requires, but you must also provision and configure those resources in each region. Overall cost for allocating people to deploy and provision resources is very less.

 

Error traceability and scalability

It's quite easy to trace or update the configuration required for the resources required in your application as infrastructure is defined in code. Also if you need to allocate more resources in the application and replicate the same on other instances is easily possible. Even if there are updates in the standards of the configuration then the same can be updated in the code.

Thanks for your time and please let me know if you find this article helpful.

 

If you need the best AWS cloud consulting services or DevOps as a service, we are here to help. Contact us today to learn more!

Author Profile Picture
Siddhesh Shirodkar
Software Developer
Developing Leadership Skills and Taking Accountability How-To Guide

Developing Leadership Skills and Taking Accountability: How-To Guide

SHAHED ISLAM
TEAM Together, Everyone, Achieves More

T (Together) E (Everyone) A (Achieves) M (More)

SIMON CORREIA
Secret Skills Needed By a Perfect Team

Secret skills of a Perfect Team

LAVINA FARIA