Creates a scenario.

Description

You can call this operation to create a scenario that allows you to specify a resource scope on a visualized interface and easily replicate and manage the resources that you specify. For more information about scenarios, see Overview.

This topic provides an example on how to create a scenario of the resource replication type in the China (Hangzhou) region. In this example, a virtual private cloud (VPC) named vpc-bp1m6fww66xbntjyc**** is replicated by using the scenario.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateTemplateScratch

The operation that you want to perform. Set the value to CreateTemplateScratch.

RegionId String Yes cn-hangzhou

The ID of the region in which you want to create the scenario.

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

TemplateScratchType String Yes ArchitectureReplication

The type of the scenario. Valid values:

  • ResourceImport: resource management
  • ArchitectureReplication: resource replication
  • ResourceMigration: resource migration
Description String No Replicate a VPC.

The description of the scenario.

SourceResources Array No

The source resources.

ResourceId String Yes vpc-bp1m6fww66xbntjyc****

The ID of the resource.

ResourceType String Yes ALIYUN::ECS::VPC

The resource type.

SourceTag Object No

The source tag.

ResourceTags Map Yes {"a": "b"}

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.

ResourceTypeFilter Array of String No ALIYUN::ECS::VPC

The filter for resource types. If you specify this parameter, only the resources of the specified types 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.

SourceResourceGroup Object No

The source resource group.

ResourceGroupId String Yes rg-acfmzawhxxc****

The ID of the source resource group.

ResourceTypeFilter Array of String No ALIYUN::ECS::VPC

The filter for resource types. If you specify this parameter, only the resources of the specified types and in the specified resource groups are scanned. If you do not specify this parameter, all resources in the specified resource groups are scanned.

You can specify up to 20 resource types.

PreferenceParameters Array No

The parameters that you want to configure for the scenario.

ParameterKey String Yes DeletionPolicy

The name of the parameter.

For more information about the valid values of the ParameterKey parameter, see the "Additional information about request parameters" section of this topic.

Note
  • The PreferenceParameters parameter is optional. If you want to specify the PreferenceParameters parameter, you must specify both the ParameterKey and ParameterValue parameters.
  • If you set the TemplateScratchType parameter to ResourceImport, you must set the ParameterKey parameter to DeletionPolicy.
ParameterValue String Yes Retain

The value of the parameter. The value of the ParameterValue parameter varies based on the value of the ParameterKey parameter.

For more information about the valid values of the ParameterValue parameter, see the "Additional information about request parameters" section of this topic.

Note The PreferenceParameters parameter is optional. If you want to specify the PreferenceParameters parameter, you must specify both the ParameterKey and ParameterValue parameters.
LogicalIdStrategy String No LongTypePrefixAndIndexSuffix

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

  • LongTypePrefixAndIndexSuffix: long-type prefix + index-type suffix
  • LongTypePrefixAndHashSuffix: long-type prefix + hash-type suffix
  • ShortTypePrefixAndHashSuffix: short-type prefix + hash-type suffix
ClientToken String No 123e4567-e89b-12d3-a456-42665544****

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that the value is unique among different requests. The token can be up to 64 characters in length, and can contain letters, digits, hyphens (-), and underscores (_).

For more information, see Ensure idempotence.

ExecutionMode String No Sync

The execution mode. Default value: Async. Valid values:

  • Async: asynchronous mode
  • Sync: synchronous mode
Note If a wide scope of resources exist, the synchronous mode takes a longer period of time than the asynchronous mode. If you set the ExecutionMode parameter to Sync, we recommend that you configure the ClientToken parameter to prevent a timeout error.
Tags.N.Key String Yes usage

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

Note The Tags parameter is optional. If you specify the Tags parameter, you must specify the Tags.N.Key parameter.
Tags.N.Value String No test

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

Additional information about request parameters

For more information about common request parameters, see Common parameters.

In request parameters, the values of the ParameterKey and ParameterValue parameters vary based on the scenario types.

  • The following table describes the values of the ParameterKey and ParameterValue parameters in a resource replication scenario.

ParameterKey

ParameterValue

DeletionPolicy

The policy based on which resources are deleted. Valid values:

  • Retain: retains resources. If you delete a stack after you replicate resources to the stack, the resources are retained.
  • Delete: deletes resources. If you delete a stack after you replicate resources to the stack, the resources are deleted by default. If you choose to retain specific resources when the Delete Stack dialog box appears, the resources are retained.

RegionId

The ID of the destination region to which you want to replicate resources. If you do not specify this parameter, the ID of the current region is used by default.

Example: cn-shanghai.

ZoneId

The ID of the destination zone to which you want to replicate resources. If you do not specify this parameter, the following rules apply: If you replicate resources in the same region, the replicated resources are deployed in the zone where the source resources reside. If you replicate resources across regions, the replicated resources are deployed in the zone that is available for all the resources.

Example: cn-shanghai-b.

VpcId

The ID of the destination VPC to which you want to replicate resources. If you do not specify this parameter, the following rules apply: If you replicate resources in the same region, the replicated resources are deployed in the VPC to which the source resources belong. If you replicate resources across regions, a new VPC is created in the destination region.

Example: vpc-bp1hye0s8b69xokfu****.

VSwitchId

The ID of the destination vSwitch to which you want to replicate resources. If you do not specify this parameter, the following rules apply: If you replicate resources in the same region, the replicated resources are associated with the vSwitch that is used for the source resources. If you replicate resources across regions, a new vSwitch is created in the destination region.

Example: vsw-bp11ufkwqwggtm1cj****.

InstanceDataReplication

Specifies whether to replicate data of the Elastic Compute Service (ECS) instance. Valid values:

  • true: replicates data of the ECS instance. If you replicate the data in the same region, a custom image is created for the source instance and a new instance is 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. A new custom image is generated in the destination region and a new instance is created based on the image.
  • false: does not replicate data of the ECS instance.
Note If you set the ParameterKey parameter to InstanceDataReplication and the ParameterValue parameter to true, you must stop the source instance before you replicate resources. This helps ensure data consistency.
  • The following table describes the values of the ParameterKey and ParameterValue parameters in a resource management scenario.
    Note In the resource management scenario, you must set the ParameterKey parameter to DeletionPolicy.

    ParameterKey

    ParameterValue

    DeletionPolicy

    The policy based on which resources are deleted. Valid values:

    • Retain: retains resources. If you delete a stack after you use the stack to manage resources, the resources are retained.
    • Delete: deletes resources. If you delete a stack after you use the stack to manage resources, the resources are deleted by default. If you choose to retain specific resources when the Delete Stack dialog box appears, the resources are retained.

Response parameters

Parameter Type Example Description
RequestId String 84980977-22F0-5421-B30D-B201311D5DCF

The ID of the request.

TemplateScratchId String ts-7f7a704cf71c49a6****

The ID of the scenario.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateTemplateScratch
&RegionId=cn-hangzhou
&TemplateScratchType=ArchitectureReplication
&SourceResources=[{"ResourceId":"vpc-bp1m6fww66xbntjyc****","ResourceType":"ALIYUN::ECS::VPC"}]
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateTemplateScratchResponse>
    <RequestId>84980977-22F0-5421-B30D-B201311D5DCF</RequestId>
    <TemplateScratchId>ts-7f7a704cf71c49a6****</TemplateScratchId>
</CreateTemplateScratchResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

For a list of error codes, see Service error codes.