What if instead of manually configuring your infrastructure resources, one by one, in a web browser or at the command line, you could manage it all in code? What if you could manage whole environments across the globe, at scale? You can, with Infrastructure as Code (IaC). Here, we'll cover IaC, AWS CloudFormation, and five resources to help you get started.
Infrastructure as Code is the management of infrastructure resources and their dependencies with code. It allows you to manage and provision whole environments reliably and at scale, automatically. Historically infrastructure was managed manually, with scripts, or run books, and became out of date quickly if changes were made directly to those resources. When you treat your infrastructure as code, just as you would your application code, you get the same benefits: you can provision the same environment multiple times, it can be version controlled, it's less brittle, it can be reused, and it can be tested. And just like your application code, you edit the source code to make changes to your infrastructure. Infrastructure as code also lets you take advantage of the cloud's pay-as-you-go pricing, provisioning and de-provisioning resources as needed, scaling up or down as needed.
AWS CloudFormation is one such tool that allows you to manage and provision AWS infrastructure predictably and repeatedly with code. With a CloudFormation template, you can define a set of AWS resources and manage that collection of resources together as one stack. By treating your infrastructure as code, you can manage the CloudFormation template in version control, just like you do your application code. With CloudFormation, you can automate your best practices, scale your infrastructure across the globe, and integrate with other AWS services to control access, improve automation, testing, and controls.
If you’re looking to start managing your AWS infrastructure resources in code, CloudFormation is a good place to start. Here are five resources that I found helpful as I was getting started with CloudFormation.
This is a self-guided workshop that walks you through the foundational features and concepts of using CloudFormation to provision an Amazon EC2 instance and related services and configuration. It introduces Nested Stacks and Layered Stacks for reusing templates and stacks and also covers the basics of packaging and deployment as your stacks become more complex.
A five-part series by Samira Yusifova, covering the foundational concepts of CloudFormation. She even explains what the dependent resources are and why you'll need them, including CIDR blocks, Internet Gateways, public and private subnets, and VPCs.
Gert Leenders explains ways to organize your stacks to reflect the volatility of your resources.
These sample templates can help you learn how to solve a specific problem and serve as a good starting point for your templates. Both the AWS team and community contribute and maintain these samples.
Hopefully, these resources have been helpful to you. Feel free to share your own suggestions in the comments!