AWS DevOps Blog

Adding Comments inside AWS CloudFormation Templates

AWS CloudFormation simplifies provisioning on AWS. You can apply software engineering best practices such as version control, code reviews, unit tests, and continuous integration to the AWS CloudFormation templates, the same way you apply those best practices to your application code.

For example, with application code, you can add descriptive comments to help you document various portions of the code. Similarly, you can add descriptive comments to resources specified in the AWS CloudFormation templates.

One way to do that is to use the metadata attribute. AWS CloudFormation supports this attribute on all types of resources. Inside the metadata, you can add any description relevant for your scenario. Here is an example template snippet:

{

   "Description" : "This is a sample template.",

   "Resources" : {

      "Bucket98004" : {

         "Type" : "AWS::S3::Bucket",

         "Metadata" : {

            "Comment" : "Image bucket for ZIP code 98004",  

            "Version" : "1.2.1_1"

...

}

— Chetan Dandekar, Senior Product Manager, Amazon Web Services.