Query the valid values of parameters defined in a template based on resource property constraints.
Background information
AssociationProperty and AssociationPropertyMetadata can filter parameters, but the filtered parameters may not meet your requirements in specific scenarios.
For example, different services support different ZoneId values. Use a parameter constraint query to obtain the ZoneId values defined in your template.
Supported properties
-
If a resource property is referenced by a parameter through the Ref function, call the GetTemplateParameterConstraints operation to obtain the property value. The following table lists the supported properties and resource types.
-
You can call the GetFeatureDetails operation to obtain resource types whose properties support parameter constraint queries.
The target template must contain the Parameters section.
|
Resource type |
Property |
Description |
|
ALIYUN::ADB::DBCluster |
|
None. |
|
ALIYUN::ALB::LoadBalancer |
|
None. |
|
ALIYUN::AMQP::Instance |
|
None. |
|
ALIYUN::ApiGateway::Instance |
|
None. |
|
ALIYUN::CDDC::DedicatedHost |
|
None. |
|
ALIYUN::CEN::CenBandwidthPackage |
|
None. |
|
ALIYUN::ClickHouse::DBCluster |
|
None. |
|
ALIYUN::CloudPhone::InstanceGroup |
|
None. |
|
ALIYUN::CS::AnyCluster |
|
None. |
|
ALIYUN::CS::ClusterNodePool |
|
None. |
|
ALIYUN::CS::KubernetesCluster |
|
None. |
|
ALIYUN::CS::ManagedEdgeKubernetesCluster |
|
None. |
|
ALIYUN::CS::ManagedKubernetesCluster |
|
None. |
|
ALIYUN::CS::ServerlessKubernetesCluster |
|
None. |
|
ALIYUN::DRDS::DrdsInstance |
|
None. |
|
ALIYUN::DTS::SubscriptionInstance |
|
None. |
|
ALIYUN::DTS::SynchronizationJob |
|
None. |
|
ALIYUN::ECD::Desktops |
|
None. |
|
ALIYUN::ECS::DedicatedHost |
|
None. |
|
ALIYUN::ECS::Disk |
|
None. |
|
ALIYUN::ECS::Instance |
|
None. |
|
ALIYUN::ECS::InstanceGroup |
|
None. |
|
ALIYUN::ECS::InstanceGroupClone |
|
None. |
|
ALIYUN::ECS::PrepayInstance |
|
None. |
|
ALIYUN::ECS::PrepayInstanceGroupClone |
|
None. |
|
ALIYUN::ECS::VSwitch |
|
None. |
|
ALIYUN::EHPC::Cluster |
|
None. |
|
ALIYUN::ElasticSearch::Instance |
|
You can query specifications only by zone. |
|
ALIYUN::EMR::Cluster |
|
None. |
|
ALIYUN::Flink::Instance |
|
None. |
|
ALIYUN::GA::Accelerator |
|
None. |
|
ALIYUN::GA::BandwidthPackage |
|
None. |
|
ALIYUN::GPDB::DBInstance |
|
None. |
|
ALIYUN::GPDB::ElasticDBInstance |
|
None. |
|
ALIYUN::GWS::Instance |
|
None. |
|
ALIYUN::MONGODB::Instance |
|
None. |
|
ALIYUN::MONGODB::PrepayInstance |
|
None. |
|
ALIYUN::MONGODB::ServerlessInstance |
|
None. |
|
ALIYUN::MONGODB::ShardingInstance |
|
None. |
|
ALIYUN::NAS::FileSystem |
|
None. |
|
ALIYUN::POLARDB::DBCluster |
|
None. |
|
ALIYUN::PrivateLink::VpcEndpointService |
|
None. |
|
ALIYUN::RDS::DBInstance |
|
Note
|
|
ALIYUN::RDS::DBInstanceClone |
|
Note
|
|
ALIYUN::RDS::PrepayDBInstance |
|
Note
|
|
ALIYUN::RDS::ReadOnlyDBInstance |
|
Note
|
|
ALIYUN::REDIS::Instance |
|
None. |
|
ALIYUN::REDIS::PrepayInstance |
|
None. |
|
ALIYUN::SLB::AnyTunnel |
|
None. |
|
ALIYUN::SLB::LoadBalancer |
|
None. |
|
ALIYUN::TSDB::HiTSDBInstance |
|
None. |
|
ALIYUN::VPC::EIP |
|
None. |
|
ALIYUN::VPC::EIPPro |
|
None. |
|
ALIYUN::VPC::NatGateway |
|
None. |
|
ALIYUN::VPC::RouterInterface |
|
None. |
Parameter dependencies
When you use a template to create ECS resources in ROS, you must specify parameters such as ZoneInfo and InstanceType.
Supported ECS instance types vary by zone. A specific value of the InstanceType parameter may become unavailable after you specify the ZoneInfo parameter.
To use only a specific value of the InstanceType parameter, you can use the Metadata section to configure the dependency between InstanceType and ZoneInfo.
For more information, see Metadata.
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
ZoneInfo:
Type: String
InstanceType:
Type: String
Resources:
ECS:
Type: ALIYUN::ECS::Instance
Properties:
ZoneId:
Ref: ZoneInfo
InstanceType:
Ref: InstanceType
ImageId: ubuntu
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- InstanceType
- ZoneInfo
Manually configure parameter constraints for Terraform templates
Add ResourcesForParameterConstraints to ALIYUN::ROS::Interface in the Metadata section or the .metadata file to configure parameter constraints.
Define the resources and properties relevant to the parameter constraints. For more information about the syntax of ResourcesForParameterConstraints, see Resources.
The Mappings, Conditions, and Rules sections in a template automatically take effect during parameter constraint queries. For more information, see (Optional) Mappings, (Optional) Conditions, and (Optional) Rules.
ROSTemplateFormatVersion: '2015-09-01'
Transform: Aliyun::Terraform-v1.1
Workspace:
.metadata: |-
{
"ALIYUN::ROS::Interface": {
"ResourcesForParameterConstraints": {
"instance": {
"Type": "ALIYUN::ECS::Instance",
"Properties": {
"ImageId": {
"Ref": "image_id"
},
"InstanceType": {
"Ref": "instance_type"
},
"ZoneId": {
"Ref": "zone_id"
}
}
}
},
"Hidden": [
"image_id"
]
}
}
main.tf: |-
variable "image_id" {
type = string
default = "ubuntu_18_04_64_20G_alibase_2019****.vhd"
}
variable "instance_type" {
type = string
}
variable "zone_id" {
type = string
}
resource "alicloud_vpc" "vpc" {
cidr_block = "172.16.X.X/16"
}
resource "alicloud_security_group" "group" {
vpc_id = alicloud_vpc.vpc.id
}
resource "alicloud_vswitch" "vswitch" {
vpc_id = alicloud_vpc.vpc.id
cidr_block = "172.16.X.X/24"
zone_id = var.zone_id
}
resource "alicloud_instance" "instance" {
availability_zone = var.zone_id
security_groups = [alicloud_security_group.group.id]
instance_type = var.instance_type
image_id = var.image_id
vswitch_id = alicloud_vswitch.vswitch.id
}
In this Terraform template, four resources are defined. The zone_id and instance_type parameters are constrained and associated with alicloud_instance.
ResourcesForParameterConstraints defines only the ALIYUN::ECS::Instance resource type (corresponding to alicloud_instance), associating it with image_id, instance_type, and zone_id to constrain these parameters. The image_id parameter is hidden.