Use Resource Orchestration Service (ROS) template to create a stack and deploy a group of resources.
Operation description
A stack is a management unit for ROS resources. You can create a group of resources by creating a stack. For more information about stacks, refer to Overview. Limits:
Each Alibaba Cloud account can create up to 200 stacks.
Each stack can contain up to 200 resources.
This topic provides an example of how to create a stack named MyStack in the China (Hangzhou) region with the stack template TemplateBody set to {"ROSTemplateFormatVersion":"2015-09-01"}.
Try it now
Test
RAM authorization
Action | Access level | Resource type | Condition key | Dependent action |
ros:CreateStack | create | *Stack
Template
| None | None |
Request parameters
Parameter | Type | Required | Description | Example |
DisableRollback | boolean | No | Specifies whether to disable rollback when stack creation failed. Valid values:
| false |
TemplateBody | string | No | The template body. The length must be between 1 and 524,288 bytes. If the content is large, it is recommended to use the HTTP POST method with Body parameters to pass the data in the request body, in order to avoid request failures caused by long URLs. 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 file that contains the stack policy. The URL must point to a policy file hosted on a web server (HTTP or HTTPS) or in Alibaba Cloud OSS bucket (for example, oss://ros/stack-policy/demo or oss://ros/stack-policy/demo?RegionId=cn-hangzhou). The maximum size of the policy file is 16,384 bytes. If the OSS region is not specified in the URL, it defaults to the value of RegionId parameter of the API request. Note You can specify only one of the following parameters: StackPolicyBody or StackPolicyURL. The maximum length of the URL is 1,350 bytes. | oss://ros-stack-policy/demo |
TimeoutInMinutes | integer | No | The timeout period that is allowed to create the stack. Unit: minutes.
| 10 |
StackPolicyBody | string | No | The structure that contains the stack policy body. The length must be between 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 name of the stack. The length of the name is up to 255 characters. The value must start with a letter and can contain letters, digits, hyphens (-), and underscores (_). | MyStack |
RegionId | string | Yes | The region ID of the stack. You can call DescribeRegions to query the most recent region list. | cn-hangzhou |
ClientToken | string | No | Ensures the idempotency of the request. This value must be generated by the client and must be globally unique. The length is up to 64 characters and can contain letters, digits, hyphens (-), and underscores (_). For more information, refer to How to ensure idempotence. | 123e4567-e89b-12d3-a456-42665544**** |
TemplateURL | string | No | The URL of the file that contains the template body. The URL must point to a template hosted on a web server (HTTP or HTTPS) or in Alibaba Cloud OSS bucket (for example, oss://ros/stack-policy/demo or oss://ros/stack-policy/demo?RegionId=cn-hangzhou). The maximum size of the template is 524,288 bytes. If the OSS region is not specified in the URL, it defaults to the value of RegionId parameter of the API request. Note You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, or TemplateScratchId. | oss://ros-template/demo |
RamRoleName | string | No | The name of the RAM role. ROS assumes this role to create the stack and uses the credentials of the role to call API on behalf of the user. ROS always uses this role for operations performed on the stack. As long as users have permissions to operations on the stack, ROS uses this role even if the users do not have permissions to use the role, ensuring that the role grants the least permissions. For more information about how to use a RAM role, refer to Use a stack role. If this value is not specified, ROS uses the existing role that is associated with the stack. If no available role exists, ROS uses a temporary credential that is generated from your account. The name of the RAM role can be up to 64 characters in length. | test-role |
DeletionProtection | string | No | Specifies whether to enable deletion protection on the stack. Valid values:
Note The deletion protection of a nested stack is the same as that of its root stack. | Enabled |
CreateOption | string | No | The option for the stack after the stack is created. Valid values:
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 | The creation option N for the stack. Valid values:
Note
| 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 that is defined in the template. If you do not specify the name and value of a parameter, ROS uses the default value that is specified in the template. The maximum value of N is 200.
The name must be between 1 to 128 characters and cannot start with 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 that is defined in the template. The maximum value of N is 200.
The value must be between 0 to 128 characters and cannot start with 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 that is used to receive stack events. Valid values:
Note This feature is supported in the following regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Hong Kong), and China (Zhangjiakou). The maximum value of N is 5. When the status of a stack changes, ROS sends a notification to the specified URL. When rollback is enabled for a stack, ROS does not send notifications when the CREATE_FAILED or UPDATE_FAILED event occurs but sends notifications when the CREATE_ROLLBACK or ROLLBACK event occurs. ROS does not send notifications when the IN_PROGRESS event occurs. ROS always send notifications whether the stack defines Outputs. The following sample code provides an example on the content of an event notification: | http://my-site.com/ros-event |
string | No | The callback URL that is used to receive stack event N. Valid values:
Note This feature is supported in the following regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Hong Kong), and China (Zhangjiakou). The maximum value of N is 5. When the status of a stack changes, ROS sends a notification to the specified URL. When rollback is enabled for a stack, ROS does not send notifications when the CREATE_FAILED or UPDATE_FAILED event occurs but sends notifications when the CREATE_ROLLBACK or ROLLBACK event occurs. ROS does not send notifications when the IN_PROGRESS event occurs. ROS always send notifications whether the stack defines Outputs. The following sample code provides an example on the content of an event notification: | 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
| usage |
Value | string | No | The value of tag N of the stack. Valid values: 1 to 20. Note The tag of a stack is propagated to each resource that supports the tag feature in the stack. For more information, see Tag propagation. | test |
ResourceGroupId | string | No | The ID of the resource group. If you do not specify this parameter, the stack is added to the default resource group. For more information about resource groups, refer to What is a resource group. | rg-acfmxazb4ph6aiy**** |
Parallelism | integer | No | The maximum number of concurrent operations that can be performed on resources. By default, this parameter is empty. You can set this parameter to an integer greater than or equal to 0. Note
| 1 |
TemplateScratchId | string | No | The ID of the resource scenario. For information about how to obtain the ID of a resource scenario, refer to ListTemplateScratches. 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. You can call DescribeRegions to query the most recent region list. | cn-hangzhou |
For more information about request common parameters, refer to 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.