Parameters

Parameters allow you to get input from end users that can be passed to your policy, used to make decisions on what to validate, and used in custom operation logic. A parameter declaration has a name, a type and other optional fields that let you define things like a default value, or a set of potential values. For details, see:

Fields
Usage

Parameters can be referred to in a Policy Template using the syntax $<parameter_name> where parameter_name is the string following the parameter keyword.

Here is an example of a parameter declaration defining a tags parameter which can take a list of tags to be used in the policy template.

parameter "tags" do 

  type "list" 

  label "Tags" 

  description "A list of tags for the policy" 

end 

Fields

The available fields are:

Name

Required?

Type

Description

type

yes

string

Defines whether the parameter is a string, a number or a list of values. The possible values for this field are string, number, and list.

label

yes

string

This is the display name shown to the user. Must not be whitespace-only.

category

no

string

An optional category used to group parameters in the UI

description

no

string

A description shown in the launch UI

default

no

 

Default value for parameter if none is specified

Note:This value must meet the requirements of the other fields (such as max_length, allowed pattern, etc.).

no_echo

no

boolean

Whether the value of the parameter should be hidden in UIs and API responses. The possible values for this field are true and false (default).

allowed_values

no

array

A comma-separated list of allowed values. Not valid when allowed_pattern is specified.

min_length

and

max_length

no

number

The minimum and maximum number of characters in the parameter value. Only valid when type is one of string or list.

min_value

and

max_value

no

number

The smallest and largest numeric value allowed for the parameter. Only valid when type is number.

allowed_pattern

no

regexp

Not valid when 'allowed_values' is specified.

Note:The Ruby Regexp engine (a PCRE engine) is used to process and validate Regexp values, but there are a few unsupported features. These include modifiers other than 'm' and 'i', modifier groups (such as /(?mi)example/), and modifier spans (such as /(?mi:example)/). A helpful tool for developing PCRE regular expressions can be found here.

constraint_description

no

string

Message displayed when any of the constraint is violated. The system generates default error messages, this field allows overriding these to provide a clearer message to the user.

Note:Note the following:

Parameters are displayed in the UI in the same order as they are defined in the template.
If a default value is set for a parameter, this value will be pre-populated in the UI. For example, for a parameter with allowed values of true/false and a default value of true, the resulting checkbox on the UI would be enabled. Additional information on UI behavior is provided below.

Usage

parameter "db_dump_bucket" do 

  type "string" 

  label "Database S3 bucket" 

  category "Database" 

  description "URL to S3 bucket that contains MySQL database dump" 

  min_length 3 

  max_length 63 

  allowed_pattern /[a-z0-9]+[a-z0-9\.-]*/ 

  constraint_description <<-EOS 

    Bucket names must be at least 3 and no more than 63 characters long. Bucket names must be a series of one or more labels. Adjacent labels are separated by a single period (.). Bucket names can contain lowercase letters, numbers, and dashes. Each label must start and end with a lowercase letter or a number. Bucket names must not be formatted as an IP address (e.g., 192.168.5.4). 

    EOS 

end 

Parameters can be used in other declarations using the $ operator, for example:

parameter "tags" do 

  type "list" 

  label "A List of Tags" 

end 

 

# find all instances with the tags from the $tags parameter 

resource "instances", type: 'rs_cm.instances' do 

  tags any($tags

end 

 

# pass the $tags parameter to the Cloud Work Flow 

define get_code($tags) do 

  # use the $tags parameter 

  ...

end 

In the example above, the instances resource declaration uses the value associated with the parameter tags to initialize the instances resource tag field.