Using AWS CloudFormer to create template of existing infrastructure

30 / Mar / 2015 by Ankit Giri 2 comments

AWS CloudFormer is a template creation tool and it creates AWS CloudFormation template from our existing resources in AWS account. We can select any supported AWS resources that are running in our account, and CloudFormer creates a template in an Amazon S3 bucket. We will be using AWS CloudFormer to create template of existing infrastructure.

AWS CloudFormation

AWS CloudFormation can be used with sample templates or our own templates to describe the AWS resources, and any associated dependencies or runtime parameters, required to run an application. We don’t need to figure out the order of provisioning services (or the subtleties of making those dependencies work). CloudFormation takes care of this for you. After the resources are deployed, we can modify and update them in a controlled and predictable way, this applies version control to our infrastructure the same way as we can do with software.
We can deploy and update a template and its collection of resources (called a stack) by using the AWS Console (or AWS CLI or APIs). CloudFormation is available at no additional charge, and we are charged only for the resources needed to run your applications.

In other words, CloudFormation is used create a infrastructure through a template (JSON script):

1) Available on AWS website for different use-cases e.g.two servers with apache installed attached to a load balancer.

2) Customized script as per our requirement.

CloudFormer automates our work by managing selected resources that have dependent resources (for example, an Amazon EC2 instance is associated with an EC2 security group), the tool will automatically select any dependent resources. We can override any of the pre-selected resources or add other resources as necessary . We have full control of the resources to be included in our template. Names are chosen based on the existing resource names (we can edit the names that will be included in the template and we can add output parameters based on the attributes available for any of the resources. The template can be uploaded to a S3 bucket and launched directly via the AWS CloudFormation stack creation wizard. (reverse of CloudFormation)

The CloudFormer tool is used to create a starting point of template. Once created, we can customize it, as following:

  • Add Parameters to enable stacks to be configured at launch time.
  • Add Mappings to allow the template to be customized to the specific environment.
  • Replace static values with “Ref” and “Fn::GetAtt” functions to flow property data between resources where the value of one property is dependent on the value of a property from a different resource.
  • Fill in your Amazon EC2 instance userdata to pass parameters to your EC2 instances at launch time.
  • Customize your Amazon RDS DB instance database names and master passwords.

For more details, visit the AWS CloudFormation User Guide and to run this tool, click here.

Use Case

Suppose, we have a full fledged infrastructure containing EC2 instances, RDS, Elastic Load Balancer and an AutoScaling on top of it. Now, our production requires you to replicate the same infrastructure. Doing this can can take anything between hours to days and the dependant configurations have to be precisely dealt with.

Demo

We would be demonstrating step-by-step approach for the creation of template from our existing infrastructure :

Go to the AWS Management console and select “CloudFormation service”.

Click on the “Create Stack” button.

Select the sample template as “CloudFormer”.

Specify parameters as per requirement.

Tag the template with proper naming convention( for ease of use).

STEP4

 

Finally, click on the “create” button & the stack is ready.

STEP5

 

The highlighted Stack is the one which we have just created. The “URL”  is the link of the CloudFormer Tool ( it is running on an t1.micro instance in our AWS Account.

STEP6

Click on the “create Template button” and proceed further.

STEP8

 

You will see a “Analyzing your account” screen & this step will take some time ( Be patient).

STEP9

Give the template a Description ( as per your convenience).
* Do not select any resource as of now.

STEP10

At first, it will ask you to select the VPC. So, all the related subnets, network interface & security group will be automatically selected ( although we can customize it).

1) VPC
STEP12

Now just keep clicking on “Continue” button. CloudFormer takes care of the dependencies.

In subsequent steps, it will ask you to select the following:

2) VPC Network (VPC Subnets, Internet Gateways, Customer Gateways, DHCP options)
3) VPC Security (Network ACLs, Rote Tables)
4) Network (ELB, Elastic IP , Network Interfaces)
5) Compute (Auto Scaling Groups, EC2 Instances)
6) Storage (EBS Volumes, RDS Instances, DynamoDB Tables, S3 Buckets)
7) Services (SQS, SNS Topics, SimpleDB Domains)
8) Config (Auto Scaling Launch Configurations, RDS Subnet groups, RDS Parameter Groups)
9) Security (EC2 Security Groups, RDS Security Groups, SQS Queue Policies, SNS Tpic Policies, S3 Bucket Policies)
10)Optional Resources (AutoScaling Policies, CloudWatch Alarms)

At last, you will see a summary page with all your selected setting.

STEP22a

CloudFront will display your template, click on “Save Template”.

STEP23

On the next screen, select “Launch Stack”.

STEP24

Now, just use the stack just created to launch the infrastructure.

STEPS1

Tag the instance for easy identification.

STEPS2

On the Review page, click on the “Create” button. You will see the following screen:

Successn

Now, go to the EC2 Dashboard & search for the created instance with the tag ( in our case, it was “instance from cloudformer”).

Hope this was helpful.

FOUND THIS USEFUL? SHARE IT

comments (2)

  1. Aun

    One question. Will this backup data on the disks of EC2 instances as well ? Like If I include 2 instances in template which currently have 2 disks attached and both 90% full, once i spin new environment from this template, the destination environment will have same amount of disk space used, right?

    Reply
  2. Alan

    I cannot seem to duplicate the results of this article. It seems that CloudFormation no longer supports this method. Can you help me find a work around please. Thank you.

    Reply

Leave a Reply

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