DEV Community

Ben Fellows for AWS Community Builders

Posted on

Simplifying CloudFormation Deployment

CloudFormation (CFN) is a great templating framework or DSL that you can use to define infrastructure in either YAML or JSON.

Over the years I've watched it develop from something that was relatively difficult to implement to now being widely accepted and easier, but still with some caveats. When I started doing enterprise cloud migrations (~2012) to AWS I was using tools like Ansible to solve the problem of automating IAM, EC2s, RDS and VPC. In addition to this we didn't have several of the tools we have now available for migrating to AWS.

I started using CFN templates to create IAM policies, EC2 templates and Roles and also VPCs. Some of the challenges back then was around the JSON formatting and injecting parameter's values into deployment. This is why I used tools like Ansible and the AWS CLI to wrap around CFN templates. This would give me control around what AMIs I could use for an EC2 for example or what AccountID I could use in a parameter for a Cross Account IAM Role.

** Conditionals

Another issue I found was that when launching a CFN template you are always going to have the issue of conditionals based on Parameter values. For example for an EC2 template if you launch it in a public subnet you might want to have a Public IP, but if you launch it in a private subnet you will only want a private IP.

** User data

User data in EC2 launches can be another problem that is not solved by templates alone. For example you can provide user data to run a command or run a script on initial launch.

Overall the biggest challenge for people who are new to using CloudFormation is learning the syntax and types of resources you need and the parameters available. The documentation provides this, but it can be challenging reading through lines and lines of documentation.

One of the ideas I had was being able to help people learn about AWS CloudFormation and supporting them in being able to create their own templates.

You can try https://app.teemops.com/ to get an idea of what I'm talking about - it allows you to use a basic UI to generate a template and launch it in your own AWS account, saving you hours of frustration learning. The source code is all available on https://github.com/teemops/tui if you want to run locally and play with.

At the moment I only support EC2 and Autoscaling groups, but the idea is to support as many AWS resources as possible. Give it a try and I look forward to feedback.

Top comments (0)