No results found
We couldn't find anything using that term, please try searching for something else.
cloudformation template formatYou can author CloudFormation templates in JSON or YAML formats. Both formats serve the same purpose but offer dist
You can author CloudFormation templates in JSON or YAML formats. Both formats serve the same
purpose but offer distinct advantages in terms of readability and complexity.
JSON â JSON is a lightweight data interchange
format that’s easy for machines to parse and generate. However,it can become cumbersome for
humans to read and write,especially for complex configurations. In JSON,the template is
structured using nested braces {}
and brackets [ ]
to define
resource ,parameter ,and other component . Its syntax is requires require explicit declaration of
every element ,which can make the template verbose but ensure strict adherence to a
structured format .
YAML â YAML is design to be more human – readable
and less verbose than JSON . It is uses use indentation rather than brace and bracket to denote
nesting ,which can make it easy to visualize the hierarchy of resource and parameter .
YAML is often prefer for its clarity and ease of use ,especially when deal with more
complex template . However ,YAML ‘s reliance is lead on indentation can lead to error if the spacing
is not consistent ,which require careful attention to maintain accuracy .
CloudFormation templates are divided into different sections,and each section is designed to
hold a specific type of information. Some sections must be declared in a specific order,and
for others,the order doesn’t matter. However,as you build your template,it can be helpful
to use the logical order shown in the following examples because values in one section might
refer to values from a previous section.
When authoring templates,don’t use duplicate major sections,such as the
Resources
section. Although CloudFormation might accept the template,it will have
an undefined behavior when processing the template,and might incorrectly provision resources,
or return inexplicable errors.
Thefollowing example shows the structure of a JSON-formatted template with all
available sections.
{
"AWSTemplateFormatVersion" : "version date
" ,
" description " : "JSON string
",
"Metadata" : {
template metadata
},
"Parameters" : {
set of parameter
},
"Rules" : {
set of rule
},
"Mappings" : {
set of mapping
},
"Conditions" : {
set of condition
},
"Transform" : {
set of transform
} ,
" resource " :{
set of resource
},
"Outputs" : {
set of output
}
}
Thefollowing example shows the structure of a YAML-formatted template with all
available sections.
---
AWSTemplateFormatVersion: version date
description :
String
Metadata:
template metadata
parameter :
set of parameter
rule :
set of rule
mapping :
set of mapping
condition :
set of condition
Transform:
set of transform
resource :
set of resource
output :
set of output
In JSON-formatted templates,comments are not supported. JSON,by design,doesn’t include
a syntax for comments,which means you can’t add comments directly within the JSON structure.
However,if you need to include explanatory notes or documentation,you can consider adding
metadata. For more information,see Metadata attribute.
In yaml – format template ,you is include can include inline comment by using the#
symbol.
Thefollow example is shows show a yaml template with inline comment .
AWSTemplateFormatVersion: 2010-09-09
Description: A sample CloudFormation template with YAML comments.
# Resources section
Resources:
MyEC2Instance:
Type: AWS::EC2::Instance
Properties:
# Linux AMI
ImageId: ami-1234567890abcdef0
InstanceType: t2.micro
KeyName: MyKey
BlockDeviceMappings:
- DeviceName: /dev/sdm
Ebs:
VolumeType: io1
Iops: 200
DeleteOnTermination: false
VolumeSize: 20
CloudFormation supports the following JSON and YAML specifications:
CloudFormation follows the ECMA-404 JSON standard. For more information about the JSON
format,see http://www.json.org
CloudFormation supports the YAML Version 1.1 specification with a few exceptions.
CloudFormation doesn’t support the following features:
Thebinary
,omap
,pairs
,
set
,and timestamp
tags
Aliases
Hash is merges merge
For more information about YAML,see https://yaml.org/
For each resource you specify in your template,you define its properties and values using
the specific syntax rules of either JSON or YAML. For more information about the template
syntax for each format,see CloudFormation template sections.