Overview

Valex Cloud Orchestration supports two popular template syntaxes. This article explains the similarities and differences between Heat Orchestration Templates (HOT) and AWS CloudFormation (CF) templates, enabling you to choose and modify templates with confidence.

Heat Orchestration Templates (HOT)

  • Format:
    Typically written in YAML.
  • Template Version:
    Includes a header like heat_template_version: 2016-04-08 to indicate the version.
  • Sections:
    • parameters: Define input parameters with type and default values.
    • resources: Describe the resources to be created (e.g., servers, networks, volumes).
    • outputs: Declare the information to be returned after deployment.
  • Intrinsic Functions:
    Functions like get_param, get_attr, and str_replace enable dynamic referencing and manipulation.
  • Example:
    heat_template_version: 2016-04-08
    description: Simple example template
    parameters:
      image_id:
        type: string
        description: Image ID for the instance
    resources:
      my_instance:
        type: OS::Nova::Server
        properties:
          name: myInstance
          image: { get_param: image_id }
          flavor: m1.small
    outputs:
      instance_id:
        description: ID of the created instance
        value: { get_attr: [my_instance, id] }

AWS CloudFormation (CF) Templates

  • Format:
    Can be written in JSON or YAML.
  • Template Version:
    Uses AWSTemplateFormatVersion: '2010-09-09' as a header.
  • Sections:
    • Parameters: Similar to HOT, but with CF-specific syntax for defining types and constraints.
    • Resources: Describe resources using AWS resource types and properties.
    • Outputs: Define output values to be returned after stack creation.
  • Intrinsic Functions:
    Functions such as Fn::GetAtt, Ref, and Fn::Join are used for dynamic references.
  • Example (YAML):
    AWSTemplateFormatVersion: '2010-09-09'
    Description: Simple example template in CF format
    Parameters:
      ImageId:
        Type: String
        Description: Image ID for the instance
    Resources:
      MyInstance:
        Type: AWS::EC2::Instance
        Properties:
          ImageId: !Ref ImageId
          InstanceType: t2.micro
    Outputs:
      InstanceId:
        Description: ID of the created instance
        Value: !GetAtt MyInstance.InstanceId

Key Differences & Similarities

  • Version Declaration:
    HOT uses heat_template_version while CF templates use AWSTemplateFormatVersion.
  • Function Names:
    HOT uses functions like get_param and get_attr, whereas CF uses !Ref and !GetAtt (or the full function names in JSON).
  • Resource Types:
    While resource types in HOT are specific to our orchestration service (e.g., OS::Nova::Server), CF templates use AWS-specific types. Despite these differences, the overall structure—parameters, resources, and outputs—remains similar.

Best Practices

  • Choose the Right Syntax:
    Use HOT if you prefer native integration and the extended functionalities offered by our orchestration engine. Use CF format if you are familiar with AWS CloudFormation or need compatibility with AWS-style templates.
  • Validation:
    Always validate your templates using the built-in syntax checker in the cloud panel to catch errors before deployment.
  • Documentation:
    Comment your templates thoroughly to document the purpose of each section and resource.
Hjälpte svaret dig? 60 användare blev hjälpta av detta svar (236 Antal röster)