CreateStack

更新时间:
复制 MD 格式

Creates a stack from a ROS template to deploy a group of resources.

Operation description

A stack is the management unit for ROS resources (Overview). Limits:

  • Each Alibaba Cloud account can create up to 200 stacks.

  • Each stack can contain up to 200 resources.

The following example creates a stack named MyStack in the China (Hangzhou) region with TemplateBody set to {"ROSTemplateFormatVersion":"2015-09-01"}.

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:CreateStack

create

*Stack

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

Template

acs:ros:{#regionId}:{#accountId}:template/{#TemplateId}

None None

Request parameters

Parameter

Type

Required

Description

Example

DisableRollback

boolean

No

Specifies whether to disable rollback when stack creation fails.

Valid values:

  • true: disables rollback.

  • false (default): enables rollback.

false

TemplateBody

string

No

The template body. Length: 1 to 524,288 bytes. Use HTTP POST with Body parameters for large content to avoid URL length limits.

Note

You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, or TemplateScratchId.

{"ROSTemplateFormatVersion":"2015-09-01"}

StackPolicyURL

string

No

The URL of the stack policy file. Supports HTTP, HTTPS, and OSS URLs (for example, oss://ros/stack-policy/demo or oss://ros/stack-policy/demo?RegionId=cn-hangzhou). Maximum file size: 16,384 bytes. If no OSS region is specified, the RegionId value is used.

Note

You can specify only one of the following parameters: StackPolicyBody or StackPolicyURL.

Maximum URL length: 1,350 bytes.

oss://ros-stack-policy/demo

TimeoutInMinutes

integer

No

The stack creation timeout. Unit: minutes.

  • Default value: 60.

  • Valid values: 10 to 1440.

10

StackPolicyBody

string

No

The stack policy body. Length: 1 to 16,384 bytes.

Note

You can specify only one of the following parameters: StackPolicyBody or StackPolicyURL.

{"Statement": [{"Action": "Update:*", "Resource": "*", "Effect": "Allow", "Principal": "*"}]}

StackName

string

Yes

The stack name. Maximum length: 255 characters. Must start with a letter and can contain letters, digits, hyphens (-), and underscores (_).

MyStack

RegionId

string

Yes

The region ID of the stack. Call DescribeRegions to query available regions.

cn-hangzhou

ClientToken

string

No

Ensures request idempotency. Must be client-generated and globally unique. Maximum length: 64 characters. Can contain letters, digits, hyphens (-), and underscores (_).

How to ensure idempotence

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

TemplateURL

string

No

The URL of the template file. Supports HTTP, HTTPS, and OSS URLs (for example, oss://ros/stack-policy/demo or oss://ros/stack-policy/demo?RegionId=cn-hangzhou). Maximum template size: 524,288 bytes. If no OSS region is specified, the RegionId value is used.

Note

You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, or TemplateScratchId.

oss://ros-template/demo

RamRoleName

string

No

The RAM role name. ROS assumes this role for all stack API calls, even when the user has direct permissions, ensuring least-privilege access. Use a stack role.

If not specified, ROS uses the role associated with the stack, or a temporary credential from your account if no role exists.

Maximum length: 64 characters.

test-role

DeletionProtection

string

No

Specifies whether to enable deletion protection on the stack. Valid values:

  • Enabled: enables deletion protection.

  • Disabled (default): allows stack deletion via the ROS console or the DeleteStack API.

Note

The deletion protection of a nested stack is the same as that of its root stack.

Enabled

CreateOption

string

No

The post-creation behavior for the stack. Valid values:

  • KeepStackOnCreationComplete (default): retains the stack and resources after creation. Counts toward the stack quota.

  • AbandonStackOnCreationComplete: deletes the stack but retains resources after creation. Does not count toward the stack quota. The stack is retained if creation fails.

  • AbandonStackOnCreationRollbackComplete: deletes the stack after a creation rollback. Does not count toward the stack quota. The stack is retained in other rollback scenarios.

  • ManuallyPay: requires manual payment for subscription resources during stack creation. Supported resource types: ALIYUN::ECS::InstanceGroup, ALIYUN::RDS::DBInstance, ALIYUN::SLB::LoadBalancer, ALIYUN::VPC::EIP, and ALIYUN::VPC::VpnGateway.

  • RetryOnNoStock: automatically retries resource creation on insufficient inventory. Supported resource type: ALIYUN::RDS::DBInstance.

Note

You can specify only one of the following parameters: CreateOption or CreateOptions.

KeepStackOnCreationComplete

CreateOptions

array

No

The creation options for the stack.

string

No

Creation option N. Valid values:

  • KeepStackOnCreationComplete (default): retains the stack and resources after creation. Counts toward the stack quota.

  • AbandonStackOnCreationComplete: deletes the stack but retains resources after creation. Does not count toward the stack quota. The stack is retained if creation fails.

  • AbandonStackOnCreationRollbackComplete: deletes the stack after a creation rollback. Does not count toward the stack quota. The stack is retained in other rollback scenarios.

  • ManuallyPay: requires manual payment for subscription resources during stack creation. Supported resource types: ALIYUN::ECS::InstanceGroup, ALIYUN::RDS::DBInstance, ALIYUN::SLB::LoadBalancer, ALIYUN::VPC::EIP, and ALIYUN::VPC::VpnGateway.

  • RetryOnNoStock: automatically retries resource creation on insufficient inventory. Supported resource type: ALIYUN::RDS::DBInstance.

Note
  • You can specify only one of the following parameters: CreateOption or CreateOptions.

  • Creation options cannot be repeated. The KeepStackOnCreationComplete option is mutually exclusive with the AbandonStackOnCreationComplete and AbandonStackOnCreationRollbackComplete options.

  • The maximum value of N is 4.

KeepStackOnCreationComplete

TemplateId

string

No

The template ID. This parameter applies to shared and private templates.

Note

You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, or TemplateScratchId.

5ecd1e10-b0e9-4389-a565-e4c15efc****

TemplateVersion

string

No

The version of the template. This parameter takes effect only when you specify TemplateId.

v1

Parameters

array<object>

No

The parameters that are defined in the template.

object

No

ParameterKey

string

Yes

The name of parameter N defined in the template. If you do not specify the name and value of a parameter, ROS uses the default value in the template.

The maximum value of N is 200. The name must be 1 to 128 characters and cannot start with aliyun or acs:. The name cannot contain http:// or https://.

Note

Parameters is an optional parameter. To specify Parameters, you must specify both Parameters.N.ParameterKey and Parameters.N.ParameterValue.

InstanceId

ParameterValue

string

Yes

The value of parameter N defined in the template.

The maximum value of N is 200. The value must be 0 to 128 characters and cannot start with aliyun or acs:. The value cannot contain http:// or https://.

Note

Parameters is an optional parameter. To specify Parameters, you must specify both Parameters.N.ParameterKey and Parameters.N.ParameterValue.

i-xxxxxx

NotificationURLs

array

No

The callback URL for stack events. Valid values:

  • HTTP POST URL. Maximum length: 1,024 bytes.

  • EventBridge receives stack status change notifications. View events in the EventBridge console.

Note

Supported regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Hong Kong), and China (Zhangjiakou).

Maximum value of N: 5. ROS sends notifications on stack status changes, except for IN_PROGRESS events. With rollback enabled, CREATE_ROLLBACK and ROLLBACK events replace CREATE_FAILED and UPDATE_FAILED notifications. Notifications always include Outputs. Example notification:

{
   "Outputs": [
       {
           "Description": "No description given",
           "OutputKey": "InstanceId",
           "OutputValue": "i-xxx"
       }
   ],
   "StackId": "80bd6b6c-e888-4573-ae3b-93d29113****",
   "StackName": "test-notification-url",
   "Status": "CREATE_COMPLETE"
}

http://my-site.com/ros-event

string

No

The callback URL for stack event N. Valid values:

  • HTTP POST URL. Maximum length: 1,024 bytes.

  • EventBridge receives stack status change notifications. View events in the EventBridge console.

Note

Supported regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Hong Kong), and China (Zhangjiakou).

Maximum value of N: 5. ROS sends notifications on stack status changes, except for IN_PROGRESS events. With rollback enabled, CREATE_ROLLBACK and ROLLBACK events replace CREATE_FAILED and UPDATE_FAILED notifications. Notifications always include Outputs. Example notification:

{
   "Outputs": [
       {
           "Description": "No description given",
           "OutputKey": "InstanceId",
           "OutputValue": "i-xxx"
       }
   ],
   "StackId": "80bd6b6c-e888-4573-ae3b-93d29113****",
   "StackName": "test-notification-url",
   "Status": "CREATE_COMPLETE"
}

http://example.com/ros-event

Tags

array<object>

No

The tags of the stack.

object

No

Key

string

Yes

The key of tag N of the stack.

Valid values: 1 to 20.

Note
  • Tags is an optional parameter. To specify Tags, you must specify Tags.N.Key.

  • Stack tags propagate to each resource that supports tagging. Tag propagation.

usage

Value

string

No

The value of tag N of the stack.

Valid values: 1 to 20.

Note

Stack tags propagate to taggable resources. Tag propagation.

test

ResourceGroupId

string

No

The ID of the resource group. If not specified, the stack is added to the default resource group.

What is a resource group

rg-acfmxazb4ph6aiy****

Parallelism

integer

No

The maximum number of concurrent operations on resources.

Default: empty. Accepts integers greater than or equal to 0.

Note
  • If greater than 0, the specified value is used. If 0 or empty, no limit applies to ROS stacks; Terraform stacks use the Terraform default (typically 10).

  • The specified value persists with the stack and affects subsequent operations such as updates.

1

TemplateScratchId

string

No

The ID of the resource scenario.

Call ListTemplateScratches to query resource scenario IDs.

Note

You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, or TemplateScratchId.

ts-aa9c62feab844a6b****

TemplateScratchRegionId

string

No

The region ID of the resource scenario. Default value: the value of RegionId.

Call DescribeRegions to query available regions.

cn-hangzhou

This operation uses Common parameters.

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

B288A0BE-D927-4888-B0F7-B35EF84B6E6F

StackId

string

The stack ID.

4a6c9851-3b0f-4f5f-b4ca-a14bf691****

Examples

Success response

JSON format

{
  "RequestId": "B288A0BE-D927-4888-B0F7-B35EF84B6E6F",
  "StackId": "4a6c9851-3b0f-4f5f-b4ca-a14bf691****"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.