If you use CloudFormation to provision your infrastructure in AWS. You definitely need these VS Code extensions and CLI tools to speed up your deployment.
For smaller projects in AWS, CloudFormation is still a relevant tool to quickly deploy infrastructure as code. I want to share 4 tools that help you create CloudFormation stacks faster than you could imagine.
Managing and maintaining infrastructure in the Cloud is being automated more often to improve efficiency and more. Since 2011 AWS saw that this could be improved using Infrastructure as Code and they developed a tool called CloudFormation.
Provisioning resources using JSON/YAML templates improved efficiency and removes repeatability a lot!
But that was not enough for some people. Several communities and even AWS started developing frameworks like CDK, Sceptre, Troposphere etc.. These are abstraction layers that use an existing programming language like Python or Typescript to generate CloudFormation templates.
Even though we have so many tools and frameworks up our disposal, they require certain programming skills to be able to start doing what you really want to do, which is: building infrastructure in the Cloud! For bigger projects where you work with a team I would recommend diving deeper into one of the frameworks listed above. The benefits are tremendous:
- Create Objects, use loops and conditions to dynamically create resources
- Combine with IDE and take advantage of validating and testing your code before you deploy
The goal of this article is to keep things simple and the entry-level low so many engineers and beginners in the Cloud can efficiently write infrastructure as code. I will show that ordinary CloudFormation can still be relevant to this day and if you combine it with the right extensions it can become a gamechanger. You’ll think twice next time when you want to provision infrastructure with complex frameworks for small projects.
There might be occasions where you still own JSON templates and want to start using the readability of the YAML structure. Seek no further cause AWS got your back with cfn_flip!
The tool converts AWS CloudFormation templates between JSON and YAML formats. For example, converting JSON to YAML:
cfn-flip -y cfn_template.json cfn_template.yml
AWS Created a tool called CloudFormation Linter which validates CloudFormation YAML/JSON templates against the CloudFormation spec. This includes checking valid values for resource properties and best practices.
The benefit of using this tool is that you can catch errors in your template before you deploy it in the Cloud. This reduces the cycle time when creating or updating CloudFormation templates.
Install the pip package first before you install the extension in VS Code.
Install using pip:
pip install cfn-lint
Install using Homebrew (macOS):
brew install cfn-lint
Finally, you can install the extension in VS Code.
One of the annoyances of creating actual resources is having to figure out which properties are available to configure. This can be time-consuming and you have to jump back and forth in the CloudFormation documentation to copy and paste simple stuff. For this reason, I created an extension in VS Code to alleviate this burden and make you more efficient in writing CloudFormation templates.
The extension is called CloudFormation Resource Snippets.
If you wish to create an autoscaling group for example, you can type
auto and VS Code will try to suggest which YAML snippet you want to insert. When you see the right resource you want to insert, you press enter and it will auto-complete and add all the properties for you. Properties that are required by the resources contain an additional comment
# required to let you know that you have to fill in the details.
This extension is automatically updated every week when AWS releases/updates CloudFormation resources. It supports all resource types which are available in CloudFormation. Intrinsic functions + conditions are supported and it contains a whole bunch of custom parameter types.
I wrote another article that goes into more detail about its features.
Dash is an API Documentation Browser and Code Snippet Manager. With this tool, you can instantly search offline documentation sets for 200+ APIs, 100+ cheat sheets, and more. You can even generate your own docsets or request docsets to be included.
In this case, we want to download the CloudFormation Template Reference Docset in the app.
The benefit of having this is that you don’t need to browse online to find a specific resource type + fetching resource types goes way quicker since the definitions are already offloaded.
To make the app even more useful, we can add the Dash VS Code extension to our editor. This will allow you to quickly find CloudFormation resource types.
If you highlight the resource type and press
ctrl + h it will open the CloudFormation docset in the Dash app. This allows you to quickly find more information about the properties of the specific resource.
Ultimately combining ordinary CloudFormation with the right VS Code extensions can become a game-changer for your next project! If you liked this and you happen to develop in Python. I can recommend you to read my other article in which I share the 10 Best VS Code extensions for Python.
Let me know if you found this useful and if there are other extensions out there that are worth sharing!
👋 Liked this article? Follow me on Twitter to stay updated!