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.
CloudFormation Resources
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.
The AWS CloudFormation workshop
🔗 https://cfn101.workshop.aws/
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.
More hands-on CloudFormation
🔗 https://dev.to/tiamatt/hands-on-aws-cloudformation-part-1-it-all-starts-here-5153
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.
Organizing your templates
🔗 https://dev.to/aws-builders/how-to-organize-cloudformation-stacks-to-minimize-blast-radius-1lee
Gert Leenders explains ways to organize your stacks to reflect the volatility of your resources.
Sample AWS CloudFormation templates
🔗 https://github.com/awslabs/aws-cloudformation-templates
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.
The official AWS documentation
🔗 https://docs.aws.amazon.com/cloudformation/
Official documentation that goes into more detail, like how to use CloudFormation at the command line and how to configure each and every resource type supported in your template.
What is AWS CDK?
Are you interested in managing your infrastructure with TypeScript, JavaScript, Python, Java, and C#/.Net? Check out the AWS CDK. The AWS CDK lets you define your cloud infrastructure in familiar programming languages (as opposed to JSON and YAML with CloudFormation) and provisions your cloud resources through CloudFormation.
Hopefully, these resources have been helpful to you. Feel free to share your own suggestions in the comments!
Top comments (2)
Thank you for sharing, great resources
Cool resources, thanks for sharing