The Complete CloudFormation Guide: Resources
Table of Contents
- Introduction
- What Are We Doing?
- The Video: Resources
- The Template So Far
- Next Steps
- The Complete CloudFormation Guide Index
Introduction
As of the previous video, the easy parts of putting together our template are out of the way and now we move into the Resources section.
Out of all of the property sections in a template, this is where you'll do 80-90% of your work. It's complex, sure, but remember our simple workflow from the Main Concepts section to keep yourself on track: we're just finding what we want, picking the properties, and adding it to our template. That and the mental model of imagining how things would look and act in the console will keep us on solid ground if overwhelm starts to kick in.
The thing to keep in mind here is thinking about what the console would ask for when you set up a Security Group through it, and then how to take those steps and put them into the template. We'll work through that process here and, in the end, you might be surprised by just how familiar the code you've written looks compared to what's in the console version.
What Are We Doing?
In this video, we'll get into the general structure that ALL resources generally follow in a AWS CloudFormation template, including the Logical ID and its properties. We'll put this into practice ourselves by using a Security Group as an example as we settle into the workflow between our code editor and the AWS Resource and Property Types Reference documentation.
The Video: Resources
The Template So Far
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description": "A template for learning and security groups",
"Metadata": {
"Author": "J Cole Morrison"
},
"Resources": {
"SecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupName": "instance-sg",
"GroupDescription": "Security group for SSH and HTTP access",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "80",
"ToPort": "80",
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": "0.0.0.0/0"
}
]
}
}
}
}
Next Steps
The Next Post - Parameters and Refs
The Previous Post - Our Project Setup
The Complete CloudFormation Guide Index
If you're enjoying this series and finding it useful, be sure to check out the rest of the blog posts in it! The links below will take you to the other posts in The Complete CloudFormation Guide here on Tech Guides and Thoughts so you can continue building your CloudFormation template along with me.
- The Complete CloudFormation Guide
- An Introduction to and History of CloudFormation
- The Main Concepts of CloudFormation
- How CloudFormation Does Updates and Deletes
- Our Project Setup
- Resources
- Parameters and Refs
- Our First Time Launch
- Functions, Pseudo Parameters, and Conditions Part 1
- Functions, Pseudo Parameters, and Conditions Part 2
- Mappings
- Transforms
- Outputs
- Relaunch!
- The Best Next Steps to Take from Here
Enjoy Posts Like These? Sign up to my mailing list!
J Cole Morrison
http://start.jcolemorrison.comDeveloper Advocate @HashiCorp, DevOps Enthusiast, Startup Lover, Teaching at awsdevops.io