Automatically generate AWS CloudFormation templates with VS Code

If you use AWS CloudFormation to provision your infrastructure, it can be time-consuming to constantly visit the AWS documentation in order to find the right property of each resource type.

To solve this problem, I created a VS Code extension that adds autocompletion for every available AWS resource type in a CloudFormation template.

The VS Code extension is called CloudFormation Snippets

AWS CloudFormation template generator features

The VS Code extension contains the following features:

  1. Supports all resources that are defined by CloudFormation
  2. Support for CloudFormation resource type snippets in JSON format! This means you can now generate CloudFormation resource type snippets in both YAML and JSON formats!
    • To get started: Open up a JSON file, type an AWS Resource prefix in the same manner as you do for the YAML snippets and it will show the autocomplete!
  3. CloudFormation autocompletion for every resource (includes properties) in both YAML and JSON formats.
  4. The CloudFormation snippets are automatically updated every week after AWS updates their CloudFormation Resource Specification.
  5. Intrinsic functions + conditions are supported.
  6. Contains a whole bunch of parameter types.
  7. Has builtin support for placeholders. This means you can quickly jump from property to property in each resource by using Tab
  8. Every resource type contains the matching documentation URL in its description.
  9. Support for Gitpod by publishing this extension to the Open VSX Registry

VS Code extension usage instructions

Here is a small demo that shows what happens when you’re trying to add a new CloudFormation resource with the VS Code extension enabled:

AWS CloudFormation Snippets example in VS Code

Steps described in further detail:

  • Step 1. Install the extension in your VS Code editor
  • Step 2. Create a template file in .yml format to start working on AWS CloudFormation
  • Step 3. Make sure that the file type is listed as YAML in the VS Code editor (Bottom right-hand corner).
  • Step 4. Type cfn to get the AWS CloudFormation template fragment.
  • Step 5. Start adding resources in the resource section of the template by using the prefix name e.g. autoscaling-autoscalinggroup equals resource type AWS::AutoScaling::AutoScalingGroup

Note: If the autocomplete doesn’t get invoked automatically in step 5. Then you can invoke IntelliSense manually by pressing ctrl + space. Search for the prefix of the resource type that you want to add and press Enter.

AWS CloudFormation Attributes (GetAtt) Cheat Sheet

It can be difficult to find out which attributes are available for each AWS CloudFormation resource type. Therefore I made an AWS CloudFormation Attributes cheat sheet that lists the attributes in a single table overview to easily find the attributes.

More helpful VS Code extensions for AWS CloudFormation

If you’re looking to optimise your VS Code with more useful extensions, then have a look at the other article I wrote to help you level up your CloudFormation templating game!

Also have a look at a VS Code extension I made for AWS CDK

If you’re working with AWS CDK, then you might be interested in my other VS Code extension that I created which adds L1 construct snippets from AWS CDK into VS Code.

Danny Steenman

A Senior AWS Cloud Engineer with over 9 years of experience migrating workloads from on-premises to AWS Cloud.

I have helped companies of all sizes shape their cloud adoption strategies, optimizing operational efficiency, reducing costs, and improving organizational agility.

Connect with me today to discuss your cloud aspirations, and let’s work together to transform your business by leveraging the power of AWS Cloud.

I need help with..
stacked cubes
Improving or managing my CDK App.Maximize the potential of your AWS CDK app by leveraging the expertise of a seasoned CDK professional.
Reducing AWS Costs.We can start by doing a thorough assessment of your current AWS infrastructure, identifying areas with potential for cost reduction and efficiency improvement.
Verifying if my infrastructure is reliable and efficient.We’ve created a comprehensive AWS Operations Checklist that you can utilize to quickly verify if your AWS Resources are set up reliably and efficiently.