ALIYUN::ROS::Stack is used to create a nested stack. Up to five levels can be nested.
A nested stack can contain other nested stacks. This results in a hierarchy of stacks. The root stack is the top-level stack to which all the nested stacks belong. The template of the root stack is called the top-level template. The ALIYUN::ROS::Stack type nests a stack as a resource in a top-level template.
In a nested stack template, you can use output from one stack as input to another stack. To obtain the output of the nested stack, you can use the Fn::GetAtt function and set the function parameters to the name of the nested stack and the output value in the Outputs.NestedStackOutputName format. For more information, see Use nested stacks.
Syntax
{
"Type": "ALIYUN::ROS::Stack",
"Properties": {
"TemplateURL": String,
"TemplateBody": String,
"TemplateId": String,
"TemplateVersion": String,
"TimeoutMins": Number,
"Parameters": Map,
"ResourceGroupId": String,
"Tags": List
}
}
Properties
Property | Type | Required | Editable | Description | Constraint |
TemplateURL | String | No | Yes | The URL of the file that contains the template body. | The file that contains the template body can be up to 524,288 bytes in size. The URL can be up to 1,024 bytes in length. The URL must point to a template that is located in an HTTP or HTTPS web server or an Object Storage Service (OSS) bucket. Examples for OSS URLs: If the region ID of the OSS bucket is not specified, the value of RegionId is used by default. You must specify one of |
TemplateBody | Map | No | Yes | The template content that is used to facilitate template delivery. | The content is raw data. Functions in the template body are not resolved in the parent stack. You must specify one of |
TemplateId | String | No | Yes | The template ID. | You must specify one of |
TemplateVersion | String | No | Yes | The name of the template version. | None |
TimeoutMins | Number | No | Yes | The timeout period for creating or updating a stack. | Unit: minutes. Default value: 60. |
Parameters | Map | No | Yes | A set of key-value pairs that represent the properties passed to Resource Orchestration Service (ROS) when the nested stack is created. | Each key in this property corresponds to a parameter name defined in the template of the nested stack, and each value corresponds to a value that you want to set for the parameter. This property is required if the nested stack requires input parameters. |
ResourceGroupId | String | No | No | The ID of the resource group to which the instance belongs. | None |
Tags | List | No | Yes | The tags that you want to add to the resources. | You can add up to 20 tags. |
Return values
Fn::GetAtt
You can use the following code to obtain the output of the nested stack:
{
"Fn::GetAtt": [
"<nested_stack>",
"Outputs.<nested_stack_output_name>"
]
}
If you use Ref
to reference resources in a nested stack, the Alibaba Cloud Resource Name (ARN) of the nested stack is returned. Example: arn:acs:ros::cn-hangzhou:12345****:stacks/test-nested-stack-Demo-jzkyq7mn****/e71c1e04-1a57-46fc-b9a4-cf7ce0d3****
.
Examples
The following code provides an example on how to create a virtual private cloud (VPC), a vSwitch, and a security group in a nested stack and save the sub-stack templates to the oss://ros/template/vpc.txt directory:
The following sample code shows the examples of parent stacks: