• Resource Template Service

rts
  1. Help Center
  2. Resource Template Service
  3. User Guide
  4. Template Grammar
  5. Parameters

Parameters

Parameters

Parameters are specified in the parameters field. Using parameters can improve the flexibility and reusability of the template. When creating the stack, you can replace some parameter values ​​in the template according to the actual situation.

You can use defined parameters in resources and outputs fields by invoking internal function get_param.

An example is provided as follows:

parameters:
  name:
    type: string
    label: 
    description: 
    default: Parameter default value
  • type: Indicates the type of the parameter, including string, number, and so on.
  • label: Indicates the name of the label that the parameter displays on the console.
  • description: Indicates an explanation of this parameter.
  • default: Indicates the default value of the parameter.

Parameter Group

A parameter group is specified in parameter_groups field. This field is used to classify entered parameters and specify parameter sequence. This field is optional.

Give a simple example:

heat_template_version: 2014-10-16
description: Create a serious of random strings
parameters:
  name:
    type: string
    default: random1
  length:
    type: number
    default: 4
  length1:
    type: number
    default: 5
  length2:
    type: number
    default: 4
parameter_groups:
  - label: length
    parameters:
      - length
      - length2
      - length1
resources:
  random1:
    type: OS::Heat::RandomString
    properties:
      length: 5
  random2:
    type: OS::Heat::RandomString
    properties:
      length: 5

The parameter group includes three parameters: lengthlength1, and length2. Set label to length and define these parameters in Parameters area. After the template uploading, parameters are divided into two types: length Parameters and Other Parameters in Specify Details page, as shown in Figure 1.

Figure 1 Specifying stack details

Parameter Constraints

In the edited or uploaded template, you can set the custom_constraint property of the parameter to automatically get a list of available values for the parameter on the Specify Details page. You only need to select a value in the drop-down box to save you the time to configure the parameters.

The custom_constraint property currently supports the following types:

  • glance.image
  • cinder.volume
  • neutron.network
  • neutron.router
  • neutron.subnet
  • nova.flavor
  • nova.keypair

For example, the template for creating ECS used in Creating Resources from a Template sets the custom_constraint property of the image, key_name, flavor, and networks parameters. When you enter the parameters on the Specify Details page, a list of available values for the four parameters are displayed.

Valid Value of Parameter

Valid-value constraints can be applied to numeric or string-type parameters, which specify a set of parameter values that a parameter may appear at. When deployed, user-supplied values must match an element in the list of valid values.

The syntax is as follows:

allowed_values: [<value 1>, <value 2>, ...]

Or the following format:

allowed_values:
  - <value 1>
  - <value 2>
  - ...