Working with AWS CloudFormation is FUN!!!

Working with CloudFormation to code your Infrastructure is fun and easy. Thanks to the visual designer that comes with the tool which work like most IDE (e.g. NetBeans, Eclipse) to develop a program.

The designer has a drag and drop interface, i.e canvas and an editor (text) section. The latter has a Template tab and Components tab which is subdivided into Parameters, Mappings, Conditions, Metadata, and Outputs sections.

The canvas has all the list of resource types you need and this helps you get more familiar with AWS and how they can be interrelated to other services.

Likewise, the editor section also has an automatic suggestion of intrinsic functions and resource reference parameters for the field values in your template using the CTRL+Space key.

Clueless how to start? Upload a sample template and reviewing it will help you understand and architect your infrastructure easier if you’re just starting to learn the tool.

One style I do to learn coding (e.g. python) was to fork a code and deconstruct it. Thanks to AWS, they have bunch of sample templates to copy and deploy. The tool comes with built-in sample templates and some of which is linked here.

Here’s a sample solution I copied from AWS list of template which is linked here.

* Template Name – WordPress scalable and durable.

* Description: Installs and deploys WordPress on to Amazon EC2 instances in an Auto Scaling group with a multi-AZ Amazon RDS database instance for storage.

With some modification – positioning of the resources, the stack will look like this:

The code which is in json format can be found here.

So, once template is validated, keyed-in parameter values (e.g. instance-type, database name, password), a summary is presented for you to review before hitting the create button.  The stack should be completed in  a few minutes.

Aside from making template from scratch or samples, you can create a template of your existing infrastructure.  You can use the CloudFormer tool to build it. This is like reverse engineering your Infrastructure. This means you can capture and redeploy applications you already have running.

To do this, click Launch CloudFormer and create an AWS CloudFormation stack that runs the CloudFormer tool. After the stack creation is complete, navigate to the CloudFormer URL available on the Outputs tab.

Finally, BEST PRACTICES are recommended to help you use CloudFormation effectively and securely.

Happy coding.

Leave a Reply

Your email address will not be published.