All Products
Search
Document Center

Resource Orchestration Service:CreateTemplateScratch

Last Updated:Oct 27, 2025

Creates templatescratch: scenario.

Operation description

Limits

Only specific resource types support the resource scenario feature. For more information, refer to Resource types that support scenarios.

Description

Resource Orchestration Service (ROS) provides the resource scenario feature. You can select a resource scope in the UI and perform operations such as replication or management of a group of resources, helping simplify resource management. For more information about resource scenarios, refer to 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 scenario lets you 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, refer to Resource replication scenario.

Resource profiling scenario

If the relationships between resources that you want to create are complicated, you can create a resource profiling scenario to preview the overall resource architecture or the architecture starting from a specific resource. This helps simplify resource management. For more information, refer to Resource detection scenario.

Resource management scenario

If you need to import a collection of existing resources into a new resource stack for unified management, you can create a resource management scenario. For more information, refer to 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, refer to Resource migration scenario.

This topic provides an example of how to create a resource replication scenario in the China (Hangzhou) region to replicate a virtual private cloud (VPC) with the ID of vpc-bp1m6fww66xbntjyc****.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ros:CreateTemplateScratch

create

*TemplateScratch

acs:ros:{#regionId}:{#accountId}:templatescratch/*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the resource scenario.

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

cn-hangzhou

TemplateScratchType

string

Yes

The type of the resource scenario. Valid values:

  • ArchitectureReplication: resource replication

  • ArchitectureDetection: resource profiling

  • ResourceImport: resource management

  • ResourceMigration: resource migration

Note

When you specify different values for the TemplateScratchType parameter, the optional parameters in the supplementary description of request parameters are also different. For more information, refer to Supplementary description of request parameters section below.

ArchitectureReplication

Description

string

No

The description of the resource scenario.

复制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 specify a CLB instance ID, the system will detect and identify its associated resources such as ECS instances, vSwitches, and VPCs.

If TemplateScratchType is set to ArchitectureDetection, you can specify up to 20 source resources.

In other cases, up to 200 source resources are supported.

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 DescribeRegions 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, ALIYUN::CDN::Domain is a global resource, and its region ID is global.

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 tags.

ResourceTags

object

Yes

The source tags that consist of key-value pairs. If you want to specify only a tag key, set the tag value to an empty string, for example: {"TagKey": ""}.

You can add up to 10 source tags. If you set TemplateScratchType to ArchitectureDetection, you can add up to 5 source tags.

{"a": "b"}

ResourceTypeFilter

array

No

The resource types filter.

string

No

The filter for resource types. If a list of resource types is specified, only resources of the specified types that contain the specified tags will be scanned. If not specified, all resources that contain the specified tags will be 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 filter for resource types. If a list of resource types is specified, only resources of the specified types that contain the specified tags will be scanned. If not specified, all resources that contain the specified tags will be scanned.

You can specify up to 20 resource types.

ALIYUN::ECS::VPC

PreferenceParameters

array<object>

No

Configuration parameters for resource scenario

object

No

ParameterKey

string

Yes

The parameter key.

For more information about the valid values, refer to Supplementary description of request parameters section in 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

ParameterValue

string

Yes

Parameter value. The value is an assignment to the ParameterKey.

For more information about the valid values, refer to Supplementary description of request parameters section in this topic.

Note

PreferenceParameters is optional. If you specify PreferenceParameters, you must specify ParameterKey and ParameterValue.

Retain

LogicalIdStrategy

string

No

Logical ID generation strategy. Valid values:

  • LongTypePrefixAndIndexSuffix: long-type prefix + index-type suffix

  • LongTypePrefixAndHashSuffix: long-type prefix + hash-type suffix

  • ShortTypePrefixAndHashSuffix: short-type prefix + hash-type suffix

Note

Default value: LongTypePrefixAndIndexSuffix. If TemplateScratchType is set to ArchitectureDetection, the default value is LongTypePrefixAndHashSuffix.

LongTypePrefixAndIndexSuffix

ClientToken

string

No

Ensures the idempotency of the request. This value must be generated by the client and must be globally unique.

It must be no more than 64 characters in length and can contain letters, digits, hyphens (-), and underscores (_).

For more information, refer to How to ensure idempotence.

123e4567-e89b-12d3-a456-42665544****

ExecutionMode

string

No

The execution mode. Valid values:

  • Async (default): asynchronous mode

  • Sync: synchronous mode

Note

If the resource scope is large, the synchronous execution takes a long time. We recommend that you specify ClientToken to avoid timeout issues.

Sync

Tags

array<object>

No

The tags of the resource scenario.

object

No

Key

string

Yes

The key of tag N that you want to add to the resource scenario.

Note

Tags is optional. If you specify Tags, you must specify Tags.N.Key.

usage

Value

string

No

The value of tag N that you want to add to the resource scenario.

test

ResourceGroupId

string

No

The ID of the resource group to which you want to assign the snapshot policy. If you leave this parameter empty, the resource scenario is added to the default resource group.

rg-acfmxazb4ph6aiy****

Additional notes on request parameters

For more information, refer to Common parameters.

When you specify different values for the TemplateScratchType parameter, the valid values of ParameterKey and ParameterValue also differ.

Resource replication scenario

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

ParameterKeyParameterValue
DeletionPolicyThe resource deletion policy. 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. If you retain specific resources when the Delete Stack dialog box appears, the resources are retained.
RegionIdThe ID of the destination region to which you want to replicate resources. If you do not specify a destination region, the current region is used by default. 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 do not specify a destination zone, the zone of the source resources is used for the replicated resources. If you replicate resources across regions and you do not specify a destination zone, the system filters 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 do not specify a destination VPC, the VPC of the source resources is used for the replicated resources. If you replicate resources across regions and you do not specify a destination VPC, 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 do not specify a destination vSwitch, the vSwitch of the source resources is used for the replicated resources. If you replicate resources across regions and you do not specify a destination vSwitch, 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, it 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, a custom image is created for the source instance and new instances are created based on the custom image. If you replicate the data across regions, a custom image is created for the source instance and replicated to the destination region. New instances are created based on the custom image.
  • false: does not replicate ECS instance data. | | 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:* Week

  • Month

  • Year | | 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:* true

  • false | | AlbLoadBalancerEdition | The edition of the ALB instance. The features and billing rules vary based on the edition. Valid values:* Basic: Basic Edition

  • Standard: Standard Edition

  • StandardWithWaf: Web Application Firewall (WAF)-enabled EditionExample: Standard. | | AlbAddressType | The type of the address of the ALB instance. Valid values:* Internet: The ALB instance has a public IP address. The Domain Name System (DNS) domain name is resolved to the public IP address. Therefore, the ALB instance can be accessed over the Internet.

  • Intranet: The ALB instance has only a private IP address. The DNS domain name is resolved to the private IP address. Therefore, the ALB instance can be accessed only within the VPC where the ALB instance is deployed.Example: Internet. | | AlbAddressIpVersion | The IP version. Valid values:* IPv4: IPv4

  • DualStack: dual stackExample: IPv4. | | AlbZoneMappings | The mappings between zones and vSwitches. You can specify at most 10 zones. If the selected region supports two or more zones, select at least two zones to ensure the high availability of your service. The value is a JSON string that has the same structure as the ZoneMappings parameter in the ALB CreateLoadBalancer operation. Example: [{"ZoneId": "cn-bejing-g": "VSwitchId": "vsw-gersdf****"}, {"ZoneId": "cn-bejing-f": "VSwitchId": "vsw-fersdf****"}] | | SlbListenerProtocols | The listener protocol of a CLB instance. Specifies the listener protocols to be included in the replication. You can set one or more protocols, separated by commas. By default, no restriction is applied. Valid values:* tcp

  • udp

  • http

  • httpsExample: tcp,udp. |

Note

When you set ParameterKey to InstanceDataReplication and ParameterValue to true, stop the source instance before you replicate resources to ensure data consistency.

Resource profiling 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 (,). The global region global is supported. If you do not specify a region, the region of the 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 resource deletion policy. 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. If you retain specific resources when the Delete Stack dialog box appears, the resources are retained.
SlbListenerProtocolsThe listener protocol of a CLB instance. Specifies the listener protocols to be included in the management. You can set one or more protocols, separated by commas. By default, no restriction is applied. Valid values: Valid values:* tcp
  • udp

  • http

  • httpsExample: 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 do not specify a destination region, the current region is used by default. Example: cn-shanghai.
ZoneIdThe ID of the destination zone to which you want to migrate resources. If you replicate resources in the same region and you do not specify a destination zone, the zone of the source resources is used for the replicated resources. If you replicate resources across regions and you do not specify a destination zone, 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 replicate resources in the same region and you do not specify a destination VPC, the VPC of the source resources is used for the replicated resources. If you replicate resources across regions and you do not specify a destination VPC, 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 replicate resources in the same region and you do not specify a destination vSwitch, the vSwitch of the source resources is used for the replicated resources. If you replicate resources across regions and you do not specify a destination vSwitch, the system automatically creates a vSwitch in the destination region. Example: vsw-bp11ufkwqwggtm1cj****.
InstanceDataReplicationSpecifies whether to migrate ECS instance data. Valid values: true: migrates ECS instance data. If you migrate the data in the same region, a custom image is created for the source instance and new instances are created based on the custom image. If you migrate the data across regions, a custom image is created for the source instance and replicated to the destination region. New instances are created based on the custom image. false: does not migrate ECS instance data.

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

84980977-22F0-5421-B30D-B201311D5DCF

TemplateScratchId

string

The ID of the resource scenario.

ts-7f7a704cf71c49a6****

Examples

Success response

JSON format

{
  "RequestId": "84980977-22F0-5421-B30D-B201311D5DCF",
  "TemplateScratchId": "ts-7f7a704cf71c49a6****"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.