Jump to: navigation, search

Heat/YAMLTemplates

< Heat
Revision as of 02:02, 28 November 2012 by Stevebake (talk)

The CloudFormation template syntax is based on JSON. This has shortcomings for templates maintained by hand, most notably:

  • lack of support for block (multi-line) strings
  • lack of commenting syntax (useful for documenting templates, and commenting out disabled sections).

So that Heat is not held back by this design decision, a new template format is proposed which will be supported alongside the existing CloudFormation format.

This format will be a YAML based syntax. The initial version of this new format will be a YAML document which parses to the same document structure as the current CloudFormation format. Future format changes will most likely focus on making it easier to write templates by hand.

Here are some examples of the new format.

This is an empty file:

#!highlight yaml


Which is equivalent to this skeleton template:

#!highlight yaml
HeatTemplateFormatVersion: '2012-12-12'
Parameters: {}
Mappings: {}
Resources: {}
Outputs: {}


Here is a JSON Parameters snippet

#!highlight json
  "Parameters" : {

    "KeyName" : {
      "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
      "Type" : "String"
    },

    "InstanceType" : {
      "Description" : "WebServer EC2 instance type",
      "Type" : "String",
      "Default" : "m1.large",
      "AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
      "ConstraintDescription" : "must be a valid EC2 instance type."
    }


Along with an equivalent representation in the YAML syntax, including an inline comment:

#!highlight yaml
Parameters:
  KeyName:
    Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
    Type: String
  InstanceType:
    Description: WebServer EC2 instance type
    Type: String
    Default: m1.large
# there is an assumption that the Nova instance supports the following instance types
    AllowedValues: [t1.micro, m1.small, m1.large, m1.xlarge, m2.xlarge,
      m2.2xlarge, m2.4xlarge, c1.medium, c1.xlarge, cc1.4xlarge]
    ConstraintDescription: must be a valid EC2 instance type.