To add comments in CloudFormation, you use the #
symbol in YAML.
Here's a breakdown:
- YAML Comments: In CloudFormation templates written in YAML, comments begin with a
#
character. Any text following the#
on the same line is ignored by the CloudFormation parser.
Here's an example:
# This is a comment explaining the purpose of this section
Resources:
MyEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-xxxxxxxxxxxxxxxxx # Replace with your desired AMI ID
InstanceType: t2.micro
In the example above, lines starting with #
are treated as comments and are ignored when CloudFormation creates or updates resources. The comment clarifies the purpose of the following Resources
section, and another comment explains the AMI ID property.