All Products
Search
Document Center

Resource Orchestration Service:AssociationProperty and AssociationPropertyMetadata

Last Updated:Jun 16, 2026

In a Resource Orchestration Service (ROS) template, `AssociationProperty` retrieves available resources in the selected region, and `AssociationPropertyMetadata` adds filter conditions for parameters. Together, they let you dynamically select parameter values in the console without switching between multiple consoles.

Parameter description

The `AssociationPropertyMetadata` parameter accepts the following values:

  • You can specify a specific value for the parameter. For example, if you specify "RegionId": "cn-hangzhou", ROS uses the `cn-hangzhou` region.

  • You can specify a variable for the parameter in the format ${ParameterKey}. For example, if you specify "VpcId": "${VpcId}", ROS dynamically retrieves the value of the `VpcId` parameter from the current template.

    Note
    • To specify ${ParameterKey} as a static field, add an exclamation mark (!). For example, ${!Literal} evaluates to the literal string ${Literal}.

    • To use a parameter variable in a Terraform template, add a $ before the $. For example, if you specify "VpcId": "$${VpcId}", ROS dynamically retrieves the value of `VpcId` from the Terraform template.

The required `AssociationPropertyMetadata` varies based on the resource type specified in `AssociationProperty`.

Examples

Example 1: AssociationProperty example

Set `AssociationProperty` to `ALIYUN::ECS::Image::ImageId` to retrieve all image IDs in the selected region.

JSON example:

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "UserName": {
      "Label": "Username",
      "Description": "Enter a username",
      "Default": "anonymous",
      "Type": "String",
      "MinLength": "6",
      "MaxLength": "12",
      "AllowedValues": [
        "anonymous",
        "user-one",
        "user-two"
      ]
    },
    "PassWord": {
      "Label": "Password",
      "NoEcho": "True",
      "Description": "Enter a user password",
      "Type": "String",
      "MinLength": "1",
      "MaxLength": "41",
      "AllowedPattern": "[a-zA-Z0-9]*"
    },
    "ImageId": {
      "Label": "Image",
      "Type": "String",
      "Description": "Select an image",
      "AssociationProperty": "ALIYUN::ECS::Image::ImageId",
      "Default": "centos_7_7_x64_20G_alibase_2020****.vhd"
    }
  }
}

YAML example:

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  UserName:
    Label: Username
    Description: Enter a username
    Default: anonymous
    Type: String
    MinLength: '6'
    MaxLength: '12'
    AllowedValues:
      - anonymous
      - user-one
      - user-two
  PassWord:
    Label: Password
    NoEcho: 'True'
    Description: Enter a user password
    Type: String
    MinLength: '1'
    MaxLength: '41'
    AllowedPattern: '[a-zA-Z0-9]*'
  ImageId:
    Label: Image
    Type: String
    Description: Select an image
    AssociationProperty: ALIYUN::ECS::Image::ImageId
    Default: centos_7_7_x64_20G_alibase_2020****.vhd

Parameter description:

  • UserName: The username. This parameter is a string that must be 6 to 12 characters in length. Valid values:

    • anonymous (default)

    • user-one

    • user-two

  • PassWord: The password. This parameter is a string that must be 1 to 41 characters in length and can contain uppercase letters, lowercase letters, and digits. No default value.

    If `NoEcho` is set to `true`, the parameter value is not returned when you query the stack.

  • ImageId: The image ID. String type.

    When `AssociationProperty` is set to `ALIYUN::ECS::Image::ImageId`, the ROS console validates the specified image ID during stack creation and lists other available image IDs in the selected region in a drop-down list.

Example 2: AssociationPropertyMetadata example

Specify `AssociationProperty` with the corresponding `AssociationPropertyMetadata` (`RegionId`, `VpcId`, and `ZoneId`) to retrieve the vSwitch for a specific virtual private cloud (VPC) and zone. In this example, `RegionId` is set to the static field `cn-hangzhou`, while `VpcId` and `ZoneId` use the variables `${VpcId}` and `${EcsZone}`. These variables refresh dynamically based on the selected values for `ALIYUN::ECS::VPC::VPCId` and `ZoneId`, associating the vSwitch with the VPC and zone.

Note

For parameters such as `EcsZone` that have `AllowedValues` configured, add `AutoChangeType` to `AssociationPropertyMetadata` and set it to `false`. This displays the `AllowedValues` as a drop-down list in the ROS console.

JSON example:

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "VpcId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
    },
    "EcsZone": {
      "Type": "String",
      "AllowedValues": [
        "cn-hangzhou-i",
        "cn-hangzhou-j",
        "cn-hangzhou-k",
        "cn-hangzhou-h"
      ],
      "AssociationPropertyMetadata": {
        "AutoChangeType": false
      }
    },
    "VSwitchId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::VPC::VSwitch::VSwitchId",
      "AssociationPropertyMetadata": {
        "RegionId": "cn-hangzhou",
        "VpcId": "${VpcId}",
        "ZoneId": "${EcsZone}"
      }
    }
  }
}

YAML example:

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  VpcId:
    Type: String
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
  EcsZone:
    Type: String
    AllowedValues:
      - cn-hangzhou-i
      - cn-hangzhou-j
      - cn-hangzhou-k
      - cn-hangzhou-h
    AssociationPropertyMetadata:
      AutoChangeType: false
  VSwitchId:
    Type: String
    AssociationProperty: ALIYUN::VPC::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      RegionId: cn-hangzhou
      VpcId: ${VpcId}
      ZoneId: ${EcsZone}

Example 3: Terraform automatic transformation example

When `AssociationProperty` is set to `Auto`, ROS automatically generates `AssociationProperty` and `AssociationPropertyMetadata` fields based on the original Terraform data structure.

  • Complete sample template code

    variable "user_information" {
      type = object({
        name    = string
        address = string
      })
      description = <<EOT
      {
        "AssociationProperty": "Auto",
        "AssociationPropertyMetadata": {
          "Overwrite": {
            "name": {
              "Label": {
                "zh-cn": "Name",
                "en": "Name"
              }
            }
          }
        }
      }
      EOT
    }
    
    variable "region_ids" {
      type    = list(string)
      description = <<EOT
      {
        "AssociationProperty": "Auto",
        "AssociationPropertyMetadata": {
          "Overwrite": {
            "*": {
              "AssociationProperty": "ALIYUN::ECS::RegionId"
            }
          }
        }
      }
      EOT
    }
    
    variable "docker_ports" {
      type = list(object({
        internal = number
        external = number
        protocol = string
      }))
      description = <<EOT
      {
        "AssociationProperty": "Auto",
        "AssociationPropertyMetadata": {
          "Overwrite": {
            "protocol": {
              "AllowedValues": ["TCP", "UDP", "ICMP"]
            },
            "internal": {
              "Label": {
                "zh-cn": "Internal Port",
                "en": "Internal Port"
              }
            }
          }
        }
      }
      EOT
    }
    
    variable "complex_type_demo" {
      type = list(object({
        b = list(string)
        c = list(object({
          d = list(string)
        }))
        e = list(list(string))
        f = list(list(object({
          g = list(string)
        })))
      }))
      description = <<EOT
      {
        "AssociationProperty": "Auto",
        "AssociationPropertyMetadata": {
            "Overwrite": {
                "b": {
                    "MaxLength": 3,
                    "AssociationPropertyMetadata": {
                        "Something": "123"
                    },
                    "Label": {
                        "zh-cn": "B",
                        "en": "B"
                    }
                },
                "b.*": {
                    "AssociationProperty": "ALIYUN::ECS::RegionId"
                },
                "c": {
                    "Label": {
                        "zh-cn": "C",
                        "en": "C"
                    }
                },
                "c.d": {
                    "Label": {
                        "zh-cn": "C/D",
                        "en": "C/D"
                    }
                },
                "c.d.*": {
                    "AssociationProperty": "ALIYUN::ECS::RegionId"
                },
                "e": {
                    "Label": {
                        "zh-cn": "E",
                        "en": "E"
                    }
                },
                "e.*": {
                    "MaxLength": 3
                },
                "e.*.*": {
                    "AssociationProperty": "ALIYUN::ECS::RegionId"
                },
                "f.g": {
                    "Label": {
                        "zh-cn": "F/G",
                        "en": "F/G"
                    }
                },
                "f.g.*": {
                    "AssociationProperty": "ALIYUN::ECS::RegionId"
                }
            }
        }
      }
      EOT
    }
  • Sample template code after the user_information parameter is transformed

    {
      "AssociationPropertyMetadata":{
        "Parameters":{
          "address":{
            "Type":"String"
          },
          "name":{
            "Type":"String",
            "Label":{
              "en":"Name",
              "zh-cn":"Name"
            }
          }
        }
      }
    }
  • Sample template code after the region_ids parameter is transformed

    {
      "AssociationPropertyMetadata":{
        "Parameter":{
          "AssociationProperty":"ALIYUN::ECS::RegionId",
          "Type":"String"
        }
      },
      "AssociationProperty":"List[Parameter]"
    }
  • Sample template code after the docker_ports parameter is transformed

    {
      "AssociationPropertyMetadata":{
        "Parameters":{
          "internal":{
            "Type":"Number",
            "Label":{
              "en":"Internal Port",
              "zh-cn":"Internal Port"
            }
          },
          "protocol":{
            "Type":"String",
            "AllowedValues":[
              "TCP",
              "UDP",
              "ICMP"
            ]
          },
          "external":{
            "Type":"Number"
          }
        }
      },
      "AssociationProperty":"List[Parameters]"
    }
  • Sample template code after the complex_type_demo parameter is transformed

    {
      "AssociationPropertyMetadata":{
        "Parameter":{
          "AssociationPropertyMetadata":{
            "Parameters":{
              "b":{
                "AssociationPropertyMetadata":{
                  "Parameter":{
                    "AssociationProperty":"ALIYUN::ECS::RegionId",
                    "Type":"String"
                  },
                  "Something":"123"
                },
                "AssociationProperty":"List[Parameter]",
                "Type":"Json",
                "Label":{
                  "en":"B",
                  "zh-cn":"B"
                },
                "MaxLength":3
              },
              "c":{
                "AssociationPropertyMetadata":{
                  "Parameter":{
                    "AssociationPropertyMetadata":{
                      "Parameters":{
                        "d":{
                          "AssociationPropertyMetadata":{
                            "Parameter":{
                              "AssociationProperty":"ALIYUN::ECS::RegionId",
                              "Type":"String"
                            }
                          },
                          "AssociationProperty":"List[Parameter]",
                          "Type":"Json",
                          "Label":{
                            "en":"C/D",
                            "zh-cn":"C/D"
                          }
                        }
                      }
                    },
                    "Type":"Json"
                  }
                },
                "AssociationProperty":"List[Parameter]",
                "Type":"Json",
                "Label":{
                  "en":"C",
                  "zh-cn":"C"
                }
              },
              "e":{
                "AssociationPropertyMetadata":{
                  "Parameter":{
                    "AssociationPropertyMetadata":{
                      "Parameter":{
                        "AssociationProperty":"ALIYUN::ECS::RegionId",
                        "Type":"String"
                      }
                    },
                    "AssociationProperty":"List[Parameter]",
                    "Type":"Json",
                    "MaxLength":3
                  }
                },
                "AssociationProperty":"List[Parameter]",
                "Type":"Json",
                "Label":{
                  "en":"E",
                  "zh-cn":"E"
                }
              },
              "f":{
                "AssociationPropertyMetadata":{
                  "Parameter":{
                    "AssociationPropertyMetadata":{
                      "Parameter":{
                        "AssociationPropertyMetadata":{
                          "Parameters":{
                            "g":{
                              "AssociationPropertyMetadata":{
                                "Parameter":{
                                  "AssociationProperty":"ALIYUN::ECS::RegionId",
                                  "Type":"String"
                                }
                              },
                              "AssociationProperty":"List[Parameter]",
                              "Type":"Json",
                              "Label":{
                                "en":"F/G",
                                "zh-cn":"F/G"
                              }
                            }
                          }
                        },
                        "Type":"Json"
                      }
                    },
                    "AssociationProperty":"List[Parameter]",
                    "Type":"Json"
                  }
                },
                "AssociationProperty":"List[Parameter]",
                "Type":"Json"
              }
            }
          },
          "Type":"Json"
        }
      },
      "AssociationProperty":"List[Parameter]"
    }

More examples

You can also use `AssociationProperty` and `AssociationPropertyMetadata` to: