• It is a JSON or YAML formatted text file.
  • save them with any extension, such as
    • .json
    • .yaml
    • .template
    • .txt
  • CloudFormation uses them for building AWS resources.
  • Example template with EC2 instance needs
    • instance type
    • the AMI ID
    • block device mappings
    • and its Amazon EC2 key pair name.
  • Whenever you create a stack, you also specify a template that AWS CloudFormation uses to create whatever you described in the template.
  • For JSON, it follows the ECMA-404 JSON standard
  • For XAML, supports the YAML Version 1.1 specification with exceptions, as
    • The binary, omap, pairs, set, and timestamp tags
    • Aliases
    • Hash merges

JSON formatted template layout

{

  “AWSTemplateFormatVersion” : “version date”,

  “Description” : “JSON string”,

  “Metadata” : {

    template metadata

  },

  “Parameters” : {

    set of parameters

  },

  “Mappings” : {

    set of mappings

  },

  “Conditions” : {

    set of conditions

  },

  “Transform” : {

    set of transforms

  },

  “Resources” : {

    set of resources

  },

  “Outputs” : {

    set of outputs

  } }

XAML formatted template layout

AWSTemplateFormatVersion: “version date”

Description:

  String

Metadata:

  template metadata

Parameters:

  set of parameters

Mappings:

  set of mappings

Conditions:

  set of conditions

Transform:

  set of transforms

Resources:

  set of resources

Outputs: set of outputs

Template Sections

  • Templates has many sections.
  • The Resources section is the only required section.
  • Some sections in a template can be in any order.
  • Various templates sections are
    • Resources (required) – stack resources and their properties
    • Format Version (optional) – template format version that template conforms to.
    • Description (optional) – text string describing the template. Must always follow template format version section.
    • Metadata (optional) – Objects that provide additional information about the template.
    • Parameters (optional) – Values to pass to template at runtime
    • Mappings (optional) – A mapping of keys and associated values to specify conditional parameter values, similar to a lookup table.
    • Conditions (optional) – Conditions controlling resource creation or resource property assignment during stack creation or update.
    • Transform (optional) – For serverless applications, specifying version of AWS Serverless Application Model to use.
    • Outputs (optional) – Describes values returned whenever viewing stack’s properties.

Menu