Creates a resource scenario.
Operation description
Limits
Only specific resource types support the resource scenario feature. For more information, see Resource types that support the scenario feature.
Description
Resource Orchestration Service (ROS) provides the resource scenario feature that allows you to specify the scope of a collection of resources on a user interface (UI) and perform operations, such as replication and management, on the resources. This helps you manage resources in a simplified manner. For more information about resource scenarios, see Overview .
Resource replication scenario
If you want to replicate a collection of resources and dependencies between the resources, you can create a resource replication scenario. This type of resource scenario allows you to replicate all existing resources within the specified scope and generate a collection of resources that have the same architecture as the existing resources. For more information, see Resource replication scenario.
Resource detection scenario
If the relationships between resources that you want to create are complicated, you can create a resource detection scenario to preview the overall resource architecture or the architecture of a specific resource. This facilitates resource management. For more information, see Resource detection scenario.
Resource management scenario
If you want to import a collection of existing resources to a stack and manage the resources in a centralized manner, you can create a resource management scenario. For more information, see Resource management scenario.
Resource migration scenario
If you want to migrate a collection of resources and dependencies between the resources, you can create a resource migration scenario. When you migrate the resources, ROS generates a stack. You can view the migration progress on the Stacks tab of the scenario details page. After you migrate the resources, you can delete source resources. For more information, see Resource migration scenario.
This topic provides an example on how to create a resource replication scenario in the China (Hangzhou) region to replicate a resource. In this example, a virtual private cloud (VPC) whose ID is vpc-bp1m6fww66xbntjyc****
is replicated.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
ros:CreateTemplateScratch | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
RegionId | string | Yes | The region ID of the resource scenario. You can call the DescribeRegions operation to query the most recent region list. | cn-hangzhou |
TemplateScratchType | string | Yes | The type of the resource scenario. Valid values:
Note
The valid values of the ParameterKey and ParameterValue request parameters vary based on the value of TemplateScratchType. For more information, see the "Additional information about request parameters" section of this topic.
| ArchitectureReplication |
Description | string | No | The description of the resource scenario. | Replicate a VPC. |
SourceResources | array<object> | No | The source resources. When you set TemplateScratchType to ArchitectureDetection, you can specify SourceResources to detect the architecture data of all resources associated with the specified source resources. For example, if you set SourceResources to the ID of a Classic Load Balancer (CLB) instance, the architecture data of all resources, such as the Elastic Compute Service (ECS) instance, vSwitch, and VPC, associated with the CLB instance is detected. If you set TemplateScratchType to ArchitectureDetection, you can specify up to 20 source resources. In other cases, you can specify up to 200 source resources. | |
object | No | The source resource. | ||
ResourceId | string | Yes | The resource ID. | vpc-bp1m6fww66xbntjyc**** |
ResourceType | string | Yes | The resource type. | ALIYUN::ECS::VPC |
RegionId | string | No | The region ID of the resource. You can call the DescribeRegions operation to query the most recent region list. Note
| cn-beijing |
RelatedResourceTypeFilter | array | No | The related resource type filters. | |
string | No | The related resource type filter. | ALIYUN::ECS::VPC | |
SourceTag | object | No | The source tag. | |
ResourceTags | object | Yes | The source tags that consist of key-value pairs. If you want to specify only the tag key, you must leave the tag value empty. Example: You can add up to 10 source tags. | {"a": "b"} |
ResourceTypeFilter | array | No | The resource types for filtering resources. | |
string | No | The resource type for filtering resources. If you specify this parameter, only the resources of the specified type and have the specified tags are scanned. If you do not specify this parameter, all resources that have the specified tags are scanned. You can specify up to 20 resource types. | ALIYUN::ECS::VPC | |
SourceResourceGroup | object | No | The source resource group. | |
ResourceGroupId | string | Yes | The ID of the source resource group. | rg-acfmzawhxxc**** |
ResourceTypeFilter | array | No | The resource types for filtering resources. | |
string | No | The resource type for filtering resources. If you specify this parameter, only the resources of the specified type and in the specified resource group are scanned. If you do not specify this parameter, all resources in the specified resource group are scanned. You can specify up to 20 resource types. | ALIYUN::ECS::VPC | |
PreferenceParameters | array<object> | No | The preference parameters of the resource scenario. | |
object | No | The preference parameter of the resource scenario. | ||
ParameterKey | string | Yes | The parameter name. For more information about the valid values of ParameterKey, see the "Additional information about request parameters" section of this topic. Note
| DeletionPolicy |
ParameterValue | string | Yes | The parameter value. The value is an assignment to the parameter key. For more information about the valid values of ParameterValue, see the "Additional information about request parameters" section of this topic. Note
PreferenceParameters is optional. If you specify PreferenceParameters, you must specify ParameterKey and ParameterValue.
| Retain |
LogicalIdStrategy | string | No | The policy based on which the logical ID is generated. Valid values:
| LongTypePrefixAndIndexSuffix |
ClientToken | string | No | The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence. | 123e4567-e89b-12d3-a456-42665544**** |
ExecutionMode | string | No | The execution mode. Valid values:
Note
If you have a wide scope of resources, Sync takes longer. If you set ExecutionMode to Sync, we recommend that you specify ClientToken to prevent the execution timeout.
| Sync |
Tags | array<object> | No | The tags of the resource scenario. | |
object | No | The tags. | ||
Key | string | Yes | The tag key of the resource scenario. Note
Tags is optional. If you want to specify Tags, you must specify Key.
| usage |
Value | string | No | The tag value of the resource scenario. | test |
ResourceGroupId | string | No | The ID of the resource group. | rg-acfmxazb4ph6aiy**** |
Additional information about request parameters
For more information about common request parameters, see Common parameters.
The valid values of ParameterKey and ParameterValue vary based on the value of TemplateScratchType
.
Resource replication scenario
The following table describes the valid values of ParameterKey and ParameterValue when you set TemplateScratchType to ArchitectureReplication.
ParameterKey | ParameterValue |
---|---|
DeletionPolicy | The deletion policy for resources. Valid values:Retain: retains resources when you delete the stack to which the resources are replicated.Delete: deletes resources by default when you delete the stack to which the resources are replicated. In the Delete Stack dialog box, you can select specific resources to retain them. |
RegionId | The ID of the destination region to which you want to replicate resources. If you leave this parameter empty, the region ID of the source resources is used.Example: cn-shanghai. |
ZoneId | The ID of the destination zone to which you want to replicate resources. If you replicate resources in the same region and you leave this parameter empty, the zone of the source resources is used for the replicated resources. If you replicate resources across regions and you leave this parameter empty, the system filters the zones that are supported by all resources.Example: cn-shanghai-b. |
VpcId | The ID of the destination VPC to which you want to replicate resources. If you replicate resources in the same region and you leave this parameter empty, the VPC of the source resources is used for the replicated resources. If you replicate resources across regions and you leave this parameter empty, the system automatically creates a VPC in the destination region.Example: vpc-bp1hye0s8b69xokfu****. |
VSwitchId | The ID of the destination vSwitch to which you want to replicate resources. If you replicate resources in the same region and you leave this parameter empty, the vSwitch of the source resources is used for the replicated resources. If you replicate resources across regions and you leave this parameter empty, the system automatically creates a vSwitch in the destination region.Example: vsw-bp11ufkwqwggtm1cj****. |
NamePrefix | The prefix of the resource name. By default, a resource name does not contain a prefix. The prefix must be 2 to 32 characters in length. |
DisableNameUnique | Specifies whether to disable automatic enforcement of name uniqueness. By default, automatic enforcement of name uniqueness is enabled. For resources that have the feature enabled, such as the Bucket resource, eight-character random codes are automatically appended to the resource names to ensure the name uniqueness of replicated resources. |
InstanceDataReplication | Specifies whether to replicate ECS instance data. Default value: false. Valid values:
|
InstancePeriod | The subscription duration of the destination subscription ECS instance. By default, the subscription duration of the source instance is used. |
InstancePeriodUnit | The unit of the subscription duration of the destination subscription ECS instance. By default, the subscription duration unit of the source instance is used. Valid values:
|
InstanceAmount | The number of ECS instances to be replicated. This parameter takes effect only when the source resource is a single ECS instance. |
RamAttachedPolicyReplication | Specifies whether to replicate the RAM policy associated with RAM users, user groups, and roles. Default value: false. Valid values:
|
SlbListenerProtocols | The destination listener protocols of the CLB instance to be replicated. You can specify one or more listener protocols. Separate multiple listener protocols with commas (,). By default, no listener protocol is used. Valid values:
|
Note If you set ParameterKey to InstanceDataReplication and ParameterValue to true, we recommend that you replicate resources after the source instance is stopped. This ensures data consistency.
Resource detection scenario
The following table describes the valid values of ParameterKey and ParameterValue when you set TemplateScratchType to ArchitectureDetection.
ParameterKey | ParameterValue |
---|---|
RegionIds | One or more region IDs. Separate multiple region IDs with commas (,). A value of global that specifies the global region is supported. If you leave this parameter empty, the region of the resource scenario is used. |
Resource management scenario
The following table describes the valid values of ParameterKey and ParameterValue when you set TemplateScratchType to ResourceImport.
Note For a resource management scenario, you must set ParameterKey to DeletionPolicy.
ParameterKey | ParameterValue |
---|---|
DeletionPolicy | The deletion policy for resources. Valid values:Retain: retains resources when you delete the stack that you use to manage the resources.Delete: deletes resources by default when you delete the stack that you use to manage the resources. In the Delete Stack dialog box, you can select specific resources to retain them. |
SlbListenerProtocols | The destination listener protocols of the CLB instance to be managed. You can specify one or more listener protocols. Separate multiple listener protocols with commas (,). By default, no listener protocol is used. Valid values:
|
Resource migration scenario
The following table describes the valid values of ParameterKey and ParameterValue when you set TemplateScratchType to ResourceMigration.
ParameterKey | ParameterValue |
---|---|
RegionId | The ID of the destination region to which you want to migrate resources. If you leave this parameter empty, the region ID of the source resources is used.Example: cn-shanghai. |
ZoneId | The ID of the destination zone to which you want to migrate resources. If you migrate resources in the same region and you leave this parameter empty, the zone of the source resources is used for the migrated resources. If you migrate resources across regions and you leave this parameter empty, the system filters the zones that are supported by all resources.Example: cn-shanghai-b. |
VpcId | The ID of the destination VPC to which you want to migrate resources. If you migrate resources in the same region and you leave this parameter empty, the VPC of the source resources is used for the migrated resources. If you migrate resources across regions and you leave this parameter empty, the system automatically creates a VPC in the destination region.Example: vpc-bp1hye0s8b69xokfu****. |
VSwitchId | The ID of the destination vSwitch to which you want to migrate resources. If you migrate resources in the same region and you leave this parameter empty, the vSwitch of the source resources is used for the migrated resources. If you migrate resources across regions and you leave this parameter empty, the system automatically creates a vSwitch in the destination region.Example: vsw-bp11ufkwqwggtm1cj****. |
InstanceDataReplication | Specifies whether to replicate ECS instance data. Valid values:true: replicates ECS instance data. If you replicate the data in the same region, the system creates a custom image for the source instance and creates an instance based on the image. If you replicate the data across regions, the system creates a custom image for the source instance, replicates the image to the destination region, and then creates an instance based on the image.false: does not replicate ECS instance data. |
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "84980977-22F0-5421-B30D-B201311D5DCF",
"TemplateScratchId": "ts-7f7a704cf71c49a6****"
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-04-24 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
2023-10-19 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
2023-10-10 | The request parameters of the API has changed | View Change Details |