If you have a habit creating your AWS resources manually, things can get very messy very quickly. At some point you realize that you have no idea if a resource is still in use and just to be safe you leave it alone.
I found myself in this situation and decided to take advantage Infrastructure as Code paradigm using AWS CloudFormation. To start simple I decided to migrate my automated CV response application to a CloudFormation stack. Going forward this is a much efficient way to write blog posts too. Instead of writing step by step instructions I can simply post the CloudFormation stack in JSON or YAML.
Basically this approach allows you to define, manage and provision all the resources that define your system.
entire infrastructure can be easily recreated in a different account.
Resources can easily be identified. Tags can be used to identify which stack the resources belong to.
Resources can easily be clean up. Deleting a stack will delete all the resource it created.
Stack: All the resources used to create an infrastructure.
StackSet: A StackSet is a container for AWS CloudFormation stacks that lets you provision stacks across AWS accounts and regions by using a single AWS CloudFormation template.
Even though you get familiar with the concepts finding where tostart can be intimidating sometimes. When it comes to CloudFormation, there are a lot of sample templates that you can start and build upon.
In the example above I'm using a stock AWS Linux AMI in London region.
Step 4: Clock Choose file to locate your file and upload your template.
Step 6: Click Next on Configure Stack Options view and in the final review step of the wizard click Create Stack.
At this point you can observe the progress of your stack being created.
If you delete the stack, it will in turn delete everything it created which is the EC2 instance in this example.
I always like the launch stack buttons that I see every now and then. I think there's something magical about clicking a button and watching an entire infrastructure being created right before your eyes!
Basically clicking the Launch Stack URL opens the wizard we just used with the fields populated with the values in the template.
Step 1: Upload the template to S3 and make it publicly accessible.
In this example I uploaded the Launch Stack button image to my GitHub repository so that I can link to it.