All Products
Search
Document Center

Resource Orchestration Service:CreateTemplateScratch

Last Updated:Jul 17, 2024

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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the resource scenario.

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
TemplateScratchTypestringYes

The type of the resource scenario. Valid values:

  • ArchitectureReplication: resource replication
  • ArchitectureDetection: resource detection
  • ResourceImport: resource management
  • ResourceMigration: resource migration
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
DescriptionstringNo

The description of the resource scenario.

Replicate a VPC.
SourceResourcesarray<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.

objectNo

The source resource.

ResourceIdstringYes

The resource ID.

vpc-bp1m6fww66xbntjyc****
ResourceTypestringYes

The resource type.

ALIYUN::ECS::VPC
RegionIdstringNo

The region ID of the resource.

You can call the DescribeRegions operation to query the most recent region list.

Note
  • This parameter takes effect only when TemplateScratchType is set to ArchitectureDetection.

  • The region ID of a global resource is global. For example, the region ID of the ALIYUN::CDN::Domain global resource is global.

cn-beijing
RelatedResourceTypeFilterarrayNo

The related resource type filters.

stringNo

The related resource type filter.

ALIYUN::ECS::VPC
SourceTagobjectNo

The source tag.

ResourceTagsobjectYes

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: {"TagKey": ""}.

You can add up to 10 source tags.

{"a": "b"}
ResourceTypeFilterarrayNo

The resource types for filtering resources.

stringNo

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
SourceResourceGroupobjectNo

The source resource group.

ResourceGroupIdstringYes

The ID of the source resource group.

rg-acfmzawhxxc****
ResourceTypeFilterarrayNo

The resource types for filtering resources.

stringNo

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
PreferenceParametersarray<object>No

The preference parameters of the resource scenario.

objectNo

The preference parameter of the resource scenario.

ParameterKeystringYes

The parameter name.

For more information about the valid values of ParameterKey, 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.

  • You must set ParameterKey to DeletionPolicy when TemplateScratchType is set to ResourceImport.

DeletionPolicy
ParameterValuestringYes

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
LogicalIdStrategystringNo

The policy based on which the logical ID is generated. Valid values:

  • LongTypePrefixAndIndexSuffix (default): long-type prefix + index-type suffix
  • LongTypePrefixAndHashSuffix: long-type prefix + hash-type suffix
  • ShortTypePrefixAndHashSuffix: short-type prefix + hash-type suffix
LongTypePrefixAndIndexSuffix
ClientTokenstringNo

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****
ExecutionModestringNo

The execution mode. Valid values:

  • Async (default)
  • Sync
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
Tagsarray<object>No

The tags of the resource scenario.

objectNo

The tags.

KeystringYes

The tag key of the resource scenario.

Note Tags is optional. If you want to specify Tags, you must specify Key.
usage
ValuestringNo

The tag value of the resource scenario.

test
ResourceGroupIdstringNo

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.

ParameterKeyParameterValue
DeletionPolicyThe 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.
RegionIdThe 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.
ZoneIdThe 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.
VpcIdThe 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****.
VSwitchIdThe 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****.
NamePrefixThe 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.
DisableNameUniqueSpecifies 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.
InstanceDataReplicationSpecifies whether to replicate ECS instance data. Default value: false. 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.
InstancePeriodThe subscription duration of the destination subscription ECS instance. By default, the subscription duration of the source instance is used.
InstancePeriodUnitThe 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:
  • Week
  • Month
  • Year
InstanceAmountThe number of ECS instances to be replicated. This parameter takes effect only when the source resource is a single ECS instance.
RamAttachedPolicyReplicationSpecifies whether to replicate the RAM policy associated with RAM users, user groups, and roles. Default value: false. Valid values:
  • true
  • false
SlbListenerProtocolsThe 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:
  • tcp
  • udp
  • http
  • https
Example: tcp,udp.

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.

ParameterKeyParameterValue
RegionIdsOne 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.

ParameterKeyParameterValue
DeletionPolicyThe 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.
SlbListenerProtocolsThe 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:
  • tcp
  • udp
  • http
  • https
Example: tcp,udp.

Resource migration scenario

The following table describes the valid values of ParameterKey and ParameterValue when you set TemplateScratchType to ResourceMigration.

ParameterKeyParameterValue
RegionIdThe 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.
ZoneIdThe 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.
VpcIdThe 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****.
VSwitchIdThe 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****.
InstanceDataReplicationSpecifies 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

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

84980977-22F0-5421-B30D-B201311D5DCF
TemplateScratchIdstring

The ID of the resource scenario.

ts-7f7a704cf71c49a6****

Examples

Sample success responses

JSONformat

{
  "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 timeSummary of changesOperation
2024-04-24The internal configuration of the API is changed, but the call is not affectedView Change Details
2023-10-19The internal configuration of the API is changed, but the call is not affectedView Change Details
2023-10-10The request parameters of the API has changedView Change Details