HOW TO Provision Cloud Resources using CloudFormation?

“Are you preparing for AWS Certified SysOps Administrator – Associate certification exam?  Are you ready to pass this exam? In this blog, we are writing a series of articles on topics which are covered in the AWS certified SysOps associate certification exam. You can subscribe to us for receiving further updates on this topic.

The SysOps Associate certification exam is the hardest exam at the associate certification level. We would recommend you pass both the AWS associate certification exam and developer associated certification exam first before taking take this exam.

CloudFormation in AWS

The AWS Certified SysOps Administrator – Associate exam validates technical expertise in deployment, management, and operations on the AWS platform.

The AWS Certified Administrator – Associate Level exam validates the candidate’s ability to:

  • Deliver the stability and scalability needed by a business on AWS
  • Provision systems, services, and deployment automation on AWS
  • Ensure data integrity and data security on AWS technology
  • Provide guidance on AWS best practices
  • Understand and monitor metrics on AWS
figure0_sysopsblueprint

Domains covered by the AWS Certified SysOps associate exam

Figure #0.  Domains covered by the AWS Certified SysOps associate exam

You can download the related AWS Certified SysOps Administrator – Associate Level Exam Blueprint for more detail about it.

In this article, we are going to explain about the topic that addresses the demonstrate the ability to provisioning cloud resources and manage implementation automation.

Context

Nowadays all could be defined using software. It is known as “Infrastructure as Code”. It is the process of managing and provisioning infrastructure resources trough machine-readable definition files, rather than physical hardware configuration or interactive configuration tools.

A SysOps should adopt and enhance the automation of almost all your management and deployment duties. The infrastructure automation enables speed through faster execution when configuring your infrastructure and aims at providing visibility to help other teams across the enterprise work quickly and more efficiently.

For facilitate the infrastructure deployment automation labor, AWS offers a service called AWS Cloudformation. A SysOps cloud be more agile, strategic-focused and obtain a lot of benefits after automates their cloud resources provisioning and manage their implementation automation. Automation of infrastructure processes promises significant efficiency, operations, and financial advantages.

What is AWS CloudFormation?

AWS CloudFormation gives developers and SysOps administrators an effortless way to create and manage a collection of related AWS resources, provisioning and updating them in an orderly and predictable fashion.

AWS CloudFormation automates and simplifies the task of repeatedly and predictably creating groups of related resources that power your applications. It helps you leverage AWS products such as Amazon EC2, Amazon Elastic Block Store, Amazon SNS, Elastic Load Balancing, and Auto Scaling to build highly reliable, highly scalable, cost-effective applications in the cloud without worrying about creating and configuring the underlying AWS infrastructure. You can use AWS CloudFormation’s sample templates or create your own templates files to describe the AWS resources, and any associated dependencies or runtime parameters, required to run your application.

You can deploy and update a template and its associated collection of resources (It’s called a stack) by using the AWS Management Console, AWS Command Line Interface, or APIs. CloudFormation is available at no additional charge, and you pay only for the AWS resources needed to run your applications.

How to create a Cloud Formation template

You can create a new stack from inside the AWS Management Console in a few simple steps. With the right template, you can deploy at once all the AWS resources you need for an application. You can use AWS CloudFormation Designer to create or modify an existing template:

Step 1. Give the stack a name: Provide a unique name for the stack.

Step 2. Select a template: Select a template from your local file system or from an Amazon S3 URL. This may be one of the sample AWS CloudFormation templates, your own custom template, a template you are managing in a source control repository, or a template you got from a third party.

Creating a stack – selecting or creating a template file
Creating a stack – selecting or creating a template file

 Figure #1 Creating a stack – selecting or creating a template file

A template is a declaration of the AWS resources that make up a stack. The template is stored as a text file whose format complies with the JavaScript Object Notation (JSON) or YAML standard.

Step 3. Specify any parameters: If the template allows you to configure the deployment, fill in any parameters or go with the specified defaults. In this sample, we’ve chosen a sample template file to show the next step.

Specifying details of a stack – using a sample template file
Specifying details of a stack – using a sample template file

Figure #2 Specifying details of a stack – using a sample template file

You can choose an IAM role that CloudFormation uses to create, modify, or delete resources in the stack. If you don’t choose a role, CloudFormation uses the permissions defined in your account

Step 4. Click “Create”: Start the deployment. You can see the current state of the deployment, with all the resource names and stack events in the AWS Management Console.

Stack dashboard - Current state of deployment
Stack dashboard – Current state of deployment

Figure #3 Stack dashboard – Current state of deployment

You can also visualize your templates as diagrams and edit them using a drag-and-drop interface with the AWS CloudFormation Designer.

The template file structure

AWS CloudFormation templates are JSON or YAML-formatted text files that describe your AWS infrastructure and are comprised of five types of elements:

  • An optional list of template parameters (input values supplied at stack creation time)
  • An optional list of output values (e.g. the complete URL to a web application)
  • An optional list of data tables used to lookup static configuration values (e.g., AMI names)
  • The list of AWS resources and their configuration values
  • A template file format version number
A sample template file – WordPress sample
A sample template file – WordPress sample

Figure #4 A sample template file – WordPress sample

Templates include several major sections. The Resources section is the only required section. Some sections in a template can be in any order. However, as you build your template, it might be helpful to use the logical ordering of the following list, as values in one section might refer to values from a previous section. The list gives a brief overview of each section.

  • Format Version (optional): Specifies the AWS CloudFormation template version that the template conforms to.
  • Description (optional): A text string that describes the template.
  • Metadata (optional): Objects that provide additional information about the template.
  • Parameters (optional): Specifies values that you can pass in to your template at runtime (when you create or update a stack).
  • Mappings (optional): A mapping of keys and associated values that you can use to specify conditional parameter values, like a lookup table.
  • Conditions (optional): Defines conditions that control whether certain resources are created or whether certain resource properties are assigned a value during stack creation or update.
  • Transform (optional): For serverless applications (also referred to as Lambda-based applications), specifies the version of the AWS Serverless Application Model (AWS SAM) to use.
  • Resources (required): Specifies the stack resources and their properties, such as an Amazon Elastic Compute Cloud instance or an Amazon Simple Storage Service bucket.
  • Outputs (optional): Describes the values that are returned whenever you view your stack’s properties

The Resources section contains the definitions of the AWS resources you want to create with the template. Each resource is listed separately and specifies the properties that are necessary for creating that resource. With parameters, you can customize aspects of your template at the run time, when the stack is built.

AWS CloudFormation provides a set of application bootstrapping scripts that enable you to install packages, files, and services on your EC2 instances by simply describing them in your CloudFormation template.

You can use AWS CloudFormation to modify and update the resources in your existing stacks in a controlled and predictable way. By using templates to manage your stack changes, you have the ability to apply version control to your AWS infrastructure just as you do with the software running on it.

 If you are preparing for the AWS certifications exam and looking for any help, please send us a mail to call to our customer support team. And benchmark your AWS knowledge with one or more of the highly demanded AWS foundation certifications.

Important Points to Remember for the AWS Certified SysOps Administrator – Associate Certification exam

  • CloudFormation is a web service for creating a collection of related AWS resources and provision them automatically
  • In a template file, the only section required is the Resources section.
  • Use IAM to Control Access to the Cloudformation templates and resources
  • CloudFormation is available at free, and you just pay for the AWS resources deployed
  • You could use a version control system like GIT for maintaining template files versioning
  • CloudFormation provides a set of application bootstrapping scripts that enable you to install packages to your AWS resources

Glossary

Term Brief description
Template Is a JSON or YAML-format, a text-based file that describes all the AWS resources you need to deploy to run your application and the collection of AWS resources related and their properties(stack).A sample template includes six top-level sections: AWSTemplateFormatVersion, Description, Parameters, Mappings, Resources, and Outputs; however, only the Resources section is required. 
Stack It’s a collection of AWS resources related to deployment using Cloud Formation. They are created and managed as a single unit when AWS CloudFormation instantiates a template. 
JSON format It is an open standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs and array data types (or any other serializable value). 

Summary

 

In this article, we have explained about the Cloudformation definitions related, how to create a template file and how to automate your AWS resources deployment using AWS Cloudformation, implementing the “infrastructure as code” paradigm.

References:

[1] Cloudformation Faqs, https://aws.amazon.com/cloudformation/faqs/
[2] AWS Cloudformation Documentation, https://aws.amazon.com/documentation/cloudformation/
[3] AWS Certified SysOps Administrator – Associate Certification.
https://aws.amazon.com/certification/certified-sysops-admin-associate/

 

 

 

About Pavan Gumaste

Pavan Rao is a programmer / Developer by Profession and Cloud Computing Professional by choice with in-depth knowledge in AWS, Azure, Google Cloud Platform. He helps the organisation figure out what to build, ensure successful delivery, and incorporate user learning to improve the strategy and product further.

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top