Parameter Groups

Parameter Groups and Parameter Labels control how parameter form fields are displayed in the CloudFormation Console. This allows you to group parameter form fields in a friendly manner. They’re added to the CloudFormation template under the Metadata.AWS::CloudFormation::Interface key. The structure looks like this:

Metadata:
  AWS::CloudFormation::Interface:
    ParameterGroups:
      -
        Label:
          default: EC2 Instance Settings
        Parameters:
          - InstanceType
          - KeyName
      -
        Label:
          default: Security Group Settings
        Parameters:
          - VpcId
    ParameterLabels:
      InstanceType:
        default: What instance type would you like?
      KeyName:
        default: The ssh keypair used to log into the instance
      VpcId:
        default: Vpc to create the security group in

DSL Method: parameter_group

Lono has a parameter_group method that makes it easier to use Parameter Groups and Labels. Example:

parameter_group("EC2 Instance Settings") do
  parameter("InstanceType", "t3.micro", Label: "What instance type would you like?")
  parameter("KeyName", Label: "The ssh keypair used to log into the instance")
end

parameter_group("Security Group Settings") do
  parameter("VpcId", Description: "IE: vpc-111", Label: "Vpc to create the security group in")
end

This generates:

---
Parameters:
  InstanceType:
    Default: t3.micro
    Type: String
  KeyName:
    Type: String
  VpcId:
    Description: 'IE: vpc-111'
    Type: String
Metadata:
  AWS::CloudFormation::Interface:
    ParameterGroups:
    - Label:
        default: EC2 Instance Settings
      Parameters:
      - InstanceType
      - KeyName
    - Label:
        default: Security Group Settings
      Parameters:
      - VpcId
    ParameterLabels:
      InstanceType:
        default: What instance type would you like?
      KeyName:
        default: The ssh keypair used to log into the instance
      VpcId:
        default: Vpc to create the security group in

Lono Seed

The lono seed command also uses the information created from the parameter group metadata. It generates a configs file with the parameters grouped in a friendly order. Example:

$ lono seed demo
Creating starter config files for demo
Building CloudFormation templates for blueprint demo:
  output/demo/templates/demo.yml
      create  config/blueprints/demo/params/dev.env
$

Here’s the contents of the params file.

config/blueprints/demo/params/dev.env:

# Parameter Group: EC2 Instance Settings
# InstanceType=t3.micro
KeyName= # (required)

# Parameter Group: Security Group Settings
VpcId=vpc-111 # (required)

Back to DSL Basics Docs.