All Products
Search
Document Center

Resource Orchestration Service:Use OOS Parameter Store to create parameters for ROS templates

Last Updated:Dec 25, 2023

To efficiently query parameters in Resource Orchestration Service (ROS) templates, you can create the parameters in Parameter Store of CloudOps Orchestration Service (OOS) and specify the parameter names in the ROS templates.

Background information

OOS Parameter Store allows you to store common parameters and encryption parameters. Encryption parameters encrypt the stored values by using Key Management Service (KMS). This topic describes how to create parameters by using OOS Parameter Store, reference the parameters in a ROS template, and then use the template to create a stack. In this example, a group of Elastic Compute Service (ECS) instances are used. The following table describes the parameters that are created.

Parameter

Name

Category

Type

Value

ImageId

my_image

Common parameter

String

centos_7_9_x64_20G_alibase_2020****.vhd

SecurityGroupIds

security_group_ids

Common parameter

StringList

sg-group1,sg-group2

Password

Password

Encryption parameter

String

MyPassword1

For more information about the parameters, see ALIYUN::ECS::InstanceGroup.

Note

When you create the parameters that you want to reference in a template, you must select the region where you want to create a stack by using the template. For example, if you want to use a template to create a stack in the China (Hangzhou) region, you must select the China (Hangzhou) region when you create the parameters.

Step 1: Create parameters in the OOS console

  1. Log on to the OOS console.

  2. In the left-side navigation pane, click Parameter Store.

  3. In the top navigation bar, select the region in which you want to create the parameters.

    Note

    The region that you select for the parameters must be the same as the region in which you want to create the stack. In this example, the China (Hangzhou) region is selected.

  4. Create the ImageId common parameter.

    1. On the Parameter Store page, click the Common Parameters tab and then click Create Common Parameter.

    2. On the Create Common Parameter page, configure Parameter Name, Value, and Parameter Type.

      In this example, the parameters are set to the following values:

      • Parameter Name: my_image

      • Parameter Type: String

      • Value: centos_7_9_x64_20G_alibase_2020****.vhd

    3. Click Create.

      After the parameter is created, you can click the name of the parameter on the Common Parameters tab to view the parameter details. On the Description tab, you can view the parameter details, such as the name, version, type, and value.

  5. Create the SecurityGroupIds common parameter.

    1. On the Parameter Store page, click the Common Parameters tab and then click Create Common Parameter.

    2. On the Create Common Parameter page, configure Parameter Name, Value, and Parameter Type.

      In this example, the parameters are set to the following values:

      • Parameter Name: security_group_ids

      • Parameter Type: StringList

      • Value: sg-group1,sg-group2

    3. Click Create.

      After the parameter is created, you can click the name of the parameter on the Common Parameters tab to view the parameter details. On the Description tab, you can view the parameter details, such as the name, version, type, and value.

  6. Create the Password encryption parameter.

    1. On the Parameter Store page, click the Encryption Parameters tab and then click Create Encryption Parameter.

    2. On the Create Encryption Parameter page, configure Parameter Name, Value, and KMS Key ID.

      In this example, the parameters are set to the following values:

      • Parameter Name: Password

      • KMS Key ID: Default Service CMK

      • Value: MyPassword1

    3. Click Create.

      After the parameter is created, you can click the name of the Password parameter on the Encryption Parameters tab to view the parameter details. On the Description tab, you can click Show next to Value to view the value of the Password parameter.

Step 2: Create a ROS template

After the parameters are created, create a ROS template and reference the parameters in the Parameters or Resources section of the template.

  • Reference the parameters in the Parameters section

    For a common parameter, set the Type parameter to ALIYUN::OOS::Parameter::Value. For an encryption parameter, set the Type parameter to ALIYUN::OOS::SecretParameter::Value.

    The following code provides an example on how to reference the ImageId parameter value of the latest version:

    Parameters:
      ImageId:
        Type: ALIYUN::OOS::Parameter::Value
        Default: my_image

    If you want to reference the parameter value of version 1, replace my_image in the code with my_image:1.

  • Reference the parameters in the Resources section

    You can reference the parameters in the Properties section of a resource. Format: {{resolve:<Parameter type>:<Parameter key>:<Parameter version>}}.

    • Parameter type

      Required. The category of the parameter. Valid values:

      • oos: common parameter

      • oos-secret: encryption parameter

    • Parameter name

      Required. The name of the parameter.

    • Parameter version

      Optional. The version of the parameter. If you do not specify the parameter version, the latest version is used.

    The following code provides an example on how to reference the ImageId parameter value of the latest version and the Password parameter value of version 2:

    Resources:
      ECS:
        Type: ALIYUN::ECS::Instance
        Properties:
          ImageId: '{{resolve:oos:my_image}}'
          Password: '{{resolve:oos-secret:Password:2}}'
          ...: null

When you reference parameters in a template, most functions are available in the template, except for the Ref, Fn::GetAtt, Fn::GetStackOutput, and Fn::Calculate functions. For more information about the functions, see Functions. Unavailable functions include Ref, Fn::GetAtt, Fn::GetStackOutput, and Fn::Calculate.

In this example, the following template is created:

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  InstanceType:
    Type: String
    Default: ecs.c6.large
  ImageId:
    Type: ALIYUN::OOS::Parameter::Value
    Default: my_image
  Vpc:
    Type: String
  VSwitch:
    Type: String
Resources:
  ECS:
    Type: ALIYUN::ECS::InstanceGroup
    Properties:
      ImageId:
        Ref: ImageId
      InstanceType:
        Ref: InstanceType
      VpcId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      SecurityGroupIds: '{{resolve:oos:security_group_ids:1}}'
      Password: '{{resolve:oos-secret:Password}}'
      MaxAmount: 1
Outputs:
  InstanceIds:
    Value:
      Fn::GetAtt:
        - ECS
        - InstanceIds

ROS converts the types of parameters referenced in ROS templates based on the parameter types defined in OOS. OOS parameters support the String and StringList types. If parameters of the StringList type are referenced in ROS templates, ROS converts the parameters into the List type for the templates. For example, if you use the SecurityGroupIds parameter whose type is StringList and whose value is sg-group1,sg-group2 to create a resource of the ALIYUN::ECS::InstanceGroup type, the value of the SecurityGroupIds parameter is converted into ["sg-group1", "sg-group2"].

Step 3: Create a stack in the ROS console

In the ROS console, use the template that you created in Step 2 to create a stack. In this example, the template is used to create a group of ECS instances. For more information, see Create a stack.

After the stack is created, you can perform the following operations to check whether the parameters are referenced as expected in the template: In the left-side navigation pane of the ROS console, click Stacks. On the Stacks page, find the stack and click the stack name. On the page that appears, click the Parameters tab to view the parameters and the parameter values.