This lab walks you through the steps to understand a sample CloudFormation template and update the CloudFormation stack as per the requirements.
You will practice using Amazon Machine Images to launch Amazon EC2 Instances and change the instance type as part of the update, replace port 22 with port 80 and finally display the private IP of the EC2 instance as output. All these updates will be created as Change set.
Duration: 90 minutes
AWS Region: US East (N. Virginia) us-east-1
CloudFormation is a service provided by AWS for designing our own infrastructure using code i.e infrastructure as code.
Currently, CloudFormation supports two languages JSON and YAML. You can write your code with one of the languages.
CloudFormation comes with great features being able to update your infrastructure whenever you want and also having the ability to delete the stack in case you don’t need it.
A fascinating feature of cloudFormation is that it saves more time in building infrastructure and helps in focusing on the development.
It is also possible to replicate our infrastructure in a short amount of time.
It eliminates human error and works according to the code you have written. It consists of two main components, Stack and Templates.
It consists of various sections like
AWS Template Format Version
Resources (Required Field)
It is not mandatory that the template requires all the above-mentioned sections. By using only the Resources section, we will be able to create a template.
The resources section plays an important role in the template creation.
For example, to create an EC2 instance, a template shall consist of various parameters such as key name, image id, instance type.
It is also possible to create two resources in the same template and refer to one from another i.e. attaching an elastic IP with an EC2 instance.
A stack consists of a collection of resources.
In other words, the stack consists of one or more templates.
The advantage of the stack is that it is easy to create, delete or update the collection of resources.
The advanced stacks have a nested stack which holds a collection of stacks.
A company is having its application on t2.micro instance. Company is expecting high traffic, so it wants Cloud System Administrator to increase the capacity of server to handle the load.
System Administrator also has a requirement to disable the SSH access and provide only HTTP access to the server.
How does Cloud SysAdmin handle it?
Create Cloudformation Template with below details
EC2 Instance - t2.micro
SSH Port open.
Upload Cloudformation Template to S3 bucket.
Create a CloudFormation Stack using Template from S3.
Provision an EC2 Instances.
Update the Cloudformation Stack to :
Increase server capacity from t2.micro to t2.medium
Remove SSH Port access
Provide HTTP Port Access
Execute the Changes and chek if the server capacity has been increased.
Launching Lab Environment
Copy the S3 Object URL of the Sample template to create CloudFormation stack
Create a CloudFormation stack using a template present in an S3 bucket.
Create a Change set for the CloudFormation stack
Check the updates and changes applied
Validation of the lab.
Deleting AWS Resources.