As a passionate advocate for automation, I have been using AWS CloudFormation since the first day I started migrating my applications to AWS. I need to manage my time efficiently and should not repeat myself. By applying automation in infrastructure provisioning and keeping my architecture as a code, I can save, test, and re-use my work later.
Managing your infrastructure as code is one of the key DevOps practices, and AWS CloudFormation is your service on AWS to realize it. In this post, I explain 11 reasons for using AWS CloudFormation and automating the provisioning of your infrastructure.
Save your time, bring quality to your process by starting to prepare your CloudFormation templates today!
1 - You can avoid human errors
I remember my OS classes at the university. At those times, we configured everything manually in Linux, and we often forgot to apply a command when we repeated the same thing. It was a nightmare. You always forget some steps when you do things manually, even if you document them well.
It was not a big issue at my university years as I could retake the class if I had failed (glad that I did not). However, when you have a workload in production, it can become a disaster because you can lose customers, business, or reputation that is far more crucial than the preceding two.
Now you have AWS CloudFormation. You prepare your templates, validate, try, fail, correct in a repeating process until you succeed in your development/test environment. Then you can apply the same template in your staging environment for the last time, and after being sure that it will work, you can apply it to your production environment.
2 - You can keep your architecture as code in your repository
When you use AWS CloudFormation, your infrastructure becomes a template or a collection of templates that can be kept in your code repository.
I sometimes use a dedicated repository for my templates in AWS CodeCommit, but you can keep them alongside with your project in the same repository as a best practice. When you need to remember, review, or revert to your previous architecture for some reason, you can locate it in your repository history.
You can even create a CI/CD pipeline for your architecture using AWS CodePipeline and deploy changes to your AWS environment by Git pushes. Recently, we did this for one of my clients as he needed to update AppSync resolvers and schema more efficiently.
3 - You can re-use your templates later to replicate the same environment
I hate repeating myself. Using AWS CloudFormation can avoid this, and you can become more efficient by reusing the work you did before.
Let’s say that you are a startup and need an AWS environment for the development of your new project. You can do it yourself or hire an AWS specialist like me to do the provisioning, or your developer can tell you that she knew AWS and does it herself. But whoever does this, let’s assume that he/she provisions all AWS resources manually using the AWS Management Console. You become happy at that time because your development process goes well. Then, three months pass, and now you need a staging environment. Guess what? You have to repeat every work done before in the new environment as well. Besides, it is a high probability that the errors encountered will be repeated, too. They often come as a package when you do things manually.
Alternatively, whoever provisions your development environment, can prepare an AWS CloudFormation template and use it to create a new stack for your new environment within minutes. You do not repeat or pay for the work done before. Maybe you still pay but not as much as before!
4 - You can save costs by deleting unused stacks and re-create them later
Our next benefit is also related to previous ones. Let’s say that you made progress in the development of your application but need to give a break due to some reason. If you use CloudFormation, you can easily take backups, delete your stack and recreate it later when you decide to continue. It saves you money because you will not pay for your resources when they are idle. As it is simple, you will not hesitate to tear them down.
Similarly, you might have a project in production provisioning AWS environments for your clients and need to tear them down after they no longer need them. You can use AWS CloudFormation templates for automating this process, too.
5 - It is easy to learn if you can read/write YAML or JSON
You might find using the AWS Management Console handy, and I really understand that. When you are trying a new service, AWS often provides a Get Started
feature for it, and it is a viable option at the beginning. However, after deciding to use the service, you should switch to AWS CloudFormation templates because of the reasons I listed here, and CloudFormation is very easy to learn.
If you know YAML or JSON, you can start writing your templates right away. Even if you do not, especially YAML is easy to learn. It mainly consists of key-value pairs with some indentation rules.
I started preparing templates in JSON because I was familiar with it as a full-stack developer programming Javascript applications. Later, I found YAML more readable, and today, I mostly use YAML.
6 - Your templates are self-explanatory
While working with a new client for the first time, if the provisioning was made using AWS CloudFormation before, all I need is the template or templates to understand what they have on AWS because templates are self-explanatory.
Also, when I research for some service and if the AWS team provided a reference architecture template, it helps me a lot. I can use it to start trying and can read the contents to understand what they did. A CloudFormation template is a blueprint for your architecture and self-explanatory to everyone knowing how to read it.
7 - It is free and a managed service
You do not pay for using AWS CloudFormation. You pay for the resources you provision as you do when you provision them manually. So, the cost is not a parameter in this comparison.
Besides, AWS CloudFormation is a managed AWS service. You do not need to maintain the architecture behind it. This allows you to focus on only provisioning new resources by saving time from maintaining a centralized system for automated provisioning.
8 - It is integrated with nearly all AWS services
When AWS launches a new service, they often provide AWS CloudFormation integration, or they do this soon enough. Besides, AWS has good documentation for supported services.
For example, AWS Serverless Application Model (SAM) is an extension of AWS CloudFormation that simplifies the creation of serverless resources. You can use SAM to define your serverless resources like AWS Lambda functions easily with AWS CloudFormation. CloudFormation has many integrations like this.
9 - You have more control over the process
When you use the AWS Management Console, you are mostly limited to what is provided from there. Some AWS services such as Elastic Beanstalk use AWS CloudFormation templates behind the scenes, so do AWS Amplify, Mobile Hub, etc. But, all these services make assumptions on your behalf to simplify the development of your applications on AWS. Sometimes, you need more control over what you provision and how you do it.
You can extend Elastic Beanstalk environments by using .ebextensions
. However, they are simply CloudFormation Cfn::Init
features. Besides, if your architecture is getting more complex, the benefits of Elastic Beanstalk become less-apparent.
When you use AWS CloudFormation, you have more control over provisioning and extending your architecture. Even if you use Elastic Beanstalk, you can create environments using CloudFormation templates to benefit from their re-usability advantages.
10 - You become good at it as you progress and benefit more
As you use AWS CloudFormation more, you become good at it and start using its advanced features like custom resources, wait handlers, update policies. As you build more, you will start decoupling your templates into multiple sub-templates by using the nested stacks feature.
Most probably, this will be sooner than you think.
11 - When you become better, you will find it faster and simpler than manual provisioning
After you become good at AWS CloudFormation, you will realize that it is faster than manually creating everything one by one using the AWS Management Console.
You can simply prepare a template, and your stack will be ready in a few minutes instead of providing all inputs required by the GUI. The process will be faster, and your work will be reusable in the future.
Conclusion
Using AWS CloudFormation is a must if you would like to achieve operational excellence on AWS. It has many benefits, and you can find more advantages of using it than I listed here.
If you never used CloudFormation before, you should start considering to use it today. The work done will immediately pay off as it will be reusable in the future and will bring quality to your provisioning process.
Thanks for reading!
Would you like to learn AWS CloudFormation?
If you would like to learn AWS CloudFormation to manage your infrastructure as code and automate the provisioning of your AWS resources, I would be happy to help you with my courses on Udemy. I divided the topics into two courses according to your knowledge level.
If you are a beginner to AWS CloudFormation, AWS CloudFormation Step by Step: Beginner to Intermediate will teach you its basics and most of the associate-level features. After finishing it, or if you know all those topics, you can enroll in my next-level CloudFormation course, AWS CloudFormation Step by Step: Intermediate to Advanced, which covers more advanced, professional-level features.
Besides, for all my available courses, please check out our Online Courses page. Hope to see you in them!