All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ROS::Stack

Last Updated:Jun 03, 2026

ALIYUN::ROS::Stack creates a nested stack. You can nest stacks up to five levels deep.

A nested stack can contain other nested stacks, forming a stack hierarchy. The root stack is the top-level parent to which all nested stacks belong, and its template is called the top-level template. Use ALIYUN::ROS::Stack to nest a stack as a resource in a top-level template.

In a nested stack template, you can pass an output of one stack as an input to another. To retrieve a nested stack output, use Fn::GetAtt with the nested stack name and output name in the Outputs.NestedStackOutputName format. 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 template body file.

The template body file can be up to 524,288 bytes. The URL can be up to 1,024 bytes.

The URL must point to a template on an HTTP or HTTPS web server or in an Object Storage Service (OSS) bucket, such as oss://ros/template/demo or oss://ros/template/demo?RegionId=cn-hangzhou.

If the region ID of the OSS bucket is not specified, the stack's region ID is used.

Specify one of TemplateURL, TemplateBody, or TemplateId. If all three are specified, TemplateBody takes precedence.

TemplateBody

Map

No

Yes

The template body content for template delivery.

The content is raw data. Functions in the template content apply only to child templates.

Specify one of TemplateURL, TemplateBody, or TemplateId. If all three are specified, TemplateBody takes precedence.

TemplateId

String

No

Yes

The template ID.

Specify one of TemplateURL, TemplateBody, or TemplateId. If all three are specified, TemplateBody takes precedence.

TemplateVersion

String

No

Yes

The name of the template version.

None.

TimeoutMins

Number

No

Yes

The timeout period for creating or updating the parent stack.

Unit: minutes.

Default value: 60.

Parameters

Map

No

Yes

Key-value pairs representing the parameters passed to ROS when the nested stack is created.

Each key-value pair corresponds to a parameter defined in the nested stack template. Required when the nested stack has input parameters.

ResourceGroupId

String

No

No

The ID of the resource group.

None.

Tags

List

No

Yes

The tags.

You can specify up to 20 tags. Tags properties.

Tags syntax

"Tags": [
  {
    "Key": String,
    "Value": String
  }
]

Tags properties

Property

Type

Required

Editable

Description

Constraint

Key

String

Yes

No

The tag key.

The tag key can be up to 128 characters. It cannot start with aliyun or acs: and cannot contain http:// or https://.

Value

String

No

No

The tag value.

The tag value can be up to 128 characters. It cannot start with aliyun or acs: and cannot contain http:// or https://.

Return values

Fn::GetAtt

Use the following code to obtain the output of a nested stack:

{
  "Fn::GetAtt": [
    "<nested_stack>",
    "Outputs.<nested_stack_output_name>"
  ]
}

If you use Ref to reference a nested stack resource, 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 YAML and JSON examples create a child stack containing a virtual private cloud (VPC), a vSwitch, and a security group. The child stack template is stored at oss://ros/template/vpc.txt.

  • YAML format

    ROSTemplateFormatVersion: '2015-09-01'
    Description: One VPC, vSwitch, security group.
    Parameters:
      ZoneId:
        Type: String
        Description: The available zone
      SecurityGroupName:
        Type: String
        Description: The security group name
        Default: my-sg-name
      VpcName:
        Type: String
        Description: The VPC name
        MinLength: 2
        MaxLength: 128
        ConstraintDescription: '[2, 128] English or Chinese letters'
        Default: my-vpc-name
      VpcCidrBlock:
        Type: String
        AllowedValues:
          - 192.168.0.0/16
          - 172.16.0.0/12
          - 10.0.0.0/8
        Default: 10.0.0.0/8
      VSwitchCidrBlock:
        Type: String
        Description: The vSwitch subnet which must be within VPC
        Default: 10.0.10.0/24
      UpdateVersion:
        Type: Number
        Default: 0
    Resources:
      Vpc:
        Type: ALIYUN::ECS::VPC
        Properties:
          CidrBlock:
            Ref: VpcCidrBlock
          VpcName:
            Ref: VpcName
      VSwitch:
        Type: ALIYUN::ECS::VSwitch
        Properties:
          CidrBlock:
            Ref: VSwitchCidrBlock
          ZoneId:
            Ref: ZoneId
          VpcId:
            Fn::GetAtt:
              - Vpc
              - VpcId
      SecurityGroup:
        Type: ALIYUN::ECS::SecurityGroup
        Properties:
          SecurityGroupName:
            Ref: SecurityGroupName
          VpcId:
            Ref: Vpc
      WaitConditionHandle:
        Type: ALIYUN::ROS::WaitConditionHandle
        Properties:
          UpdateVersion:
            Ref: UpdateVersion
    Outputs:
      SecurityGroupId:
        Value:
          Fn::GetAtt:
            - SecurityGroup
            - SecurityGroupId
      VpcId:
        Value:
          Fn::GetAtt:
            - Vpc
            - VpcId
      VSwitchId:
        Value:
          Fn::GetAtt:
            - VSwitch
            - VSwitchId
    
  • JSON format

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Description": "One VPC, vSwitch, security group.",
      "Parameters": {
        "ZoneId": {
          "Type": "String",
          "Description": "The available zone"
        },
        "SecurityGroupName": {
          "Type": "String",
          "Description": "The security group name",
          "Default": "my-sg-name"
        },
        "VpcName": {
          "Type": "String",
          "Description": "The VPC name",
          "MinLength": 2,
          "MaxLength": 128,
          "ConstraintDescription": "[2, 128] English or Chinese letters",
          "Default": "my-vpc-name"
        },
        "VpcCidrBlock": {
          "Type": "String",
          "AllowedValues": [
            "192.168.0.0/16",
            "172.16.0.0/12",
            "10.0.0.0/8"
          ],
          "Default": "10.0.0.0/8"
        },
        "VSwitchCidrBlock": {
          "Type": "String",
          "Description": "The vSwitch subnet which must be within VPC",
          "Default": "10.0.10.0/24"
        },
        "UpdateVersion": {
          "Type": "Number",
          "Default": 0
        }
      },
      "Resources": {
        "Vpc": {
          "Type": "ALIYUN::ECS::VPC",
          "Properties": {
            "CidrBlock": {
              "Ref": "VpcCidrBlock"
            },
            "VpcName": {
              "Ref": "VpcName"
            }
          }
        },
        "VSwitch": {
          "Type": "ALIYUN::ECS::VSwitch",
          "Properties": {
            "CidrBlock": {
              "Ref": "VSwitchCidrBlock"
            },
            "ZoneId": {
              "Ref": "ZoneId"
            },
            "VpcId": {
              "Fn::GetAtt": [
                "Vpc",
                "VpcId"
              ]
            }
          }
        },
        "SecurityGroup": {
          "Type": "ALIYUN::ECS::SecurityGroup",
          "Properties": {
            "SecurityGroupName": {
              "Ref": "SecurityGroupName"
            },
            "VpcId": {
              "Ref": "Vpc"
            }
          }
        },
        "WaitConditionHandle": {
          "Type": "ALIYUN::ROS::WaitConditionHandle",
          "Properties": {
            "UpdateVersion": {
              "Ref": "UpdateVersion"
            }
          }
        }
      },
      "Outputs": {
        "SecurityGroupId": {
          "Value": {
            "Fn::GetAtt": [
              "SecurityGroup",
              "SecurityGroupId"
            ]
          }
        },
        "VpcId": {
          "Value": {
            "Fn::GetAtt": [
              "Vpc",
              "VpcId"
            ]
          }
        },
        "VSwitchId": {
          "Value": {
            "Fn::GetAtt": [
              "VSwitch",
              "VSwitchId"
            ]
          }
        }
      }
    }

The following YAML and JSON examples create a parent stack:

  • YAML format

    ROSTemplateFormatVersion: '2015-09-01'
    Description: One ECS instance.
    Parameters:
      ImageId:
        Default: centos_7
        Type: String
        Description: Image Id, represents the image resource to startup the ECS instance
      InstanceType:
        Type: String
        Description: The ECS instance type,
        Default: ecs.xn4.small
      ZoneId:
        Type: String
        Description: 'The available zone '
      InstanceChargeType:
        Type: String
        AllowedValues:
          - PrePaid
          - PostPaid
        Default: PostPaid
        Description: The instance charge type
      SecurityGroupName:
        Type: String
        Description: The security group name
        Default: my-sg-name
      NetworkInterfaceName:
        Type: String
        Description: The Network interface name
        Default: my-eni-name
      VpcName:
        Type: String
        Description: The VPC name
        MinLength: 2
        MaxLength: 128
        ConstraintDescription: '[2, 128] English or Chinese letters'
        Default: my-vpc-name
      IoOptimized:
        AllowedValues:
          - none
          - optimized
        Description: IO optimized, optimized is for the IO optimized instance type
        Type: String
        Default: optimized
      SystemDiskCategory:
        AllowedValues:
          - cloud
          - cloud_efficiency
          - cloud_ssd
        Description: 'System disk category: average cloud disk(cloud), efficient cloud disk(cloud_efficiency) or SSD cloud disk(cloud_ssd)'
        Type: String
        Default: cloud_ssd
      VpcCidrBlock:
        Type: String
        AllowedValues:
          - 192.168.0.0/16
          - 172.16.0.0/12
          - 10.0.0.0/8
        Default: 10.0.0.0/8
      VSwitchCidrBlock:
        Type: String
        Description: The VSwitch subnet which must be within VPC
        Default: 10.0.10.0/24
      UpdateVersion:
        Type: Number
        Default: 0
    Resources:
      NetworkStack:
        Type: ALIYUN::ROS::Stack
        Properties:
          TemplateURL: oss://ros/template/vpc.txt
          TimeoutMins: 5
          Parameters:
            ZoneId:
              Ref: ZoneId
            SecurityGroupName:
              Ref: SecurityGroupName
            VpcName:
              Ref: VpcName
            VpcCidrBlock:
              Ref: VpcCidrBlock
            VSwitchCidrBlock:
              Ref: VSwitchCidrBlock
            UpdateVersion:
              Ref: UpdateVersion
      WebServer:
        Type: ALIYUN::ECS::Instance
        Properties:
          ImageId:
            Ref: ImageId
          InstanceType:
            Ref: InstanceType
          InstanceChargeType:
            Ref: InstanceChargeType
          SecurityGroupId:
            Fn::GetAtt:
              - NetworkStack
              - Outputs.SecurityGroupId
          VpcId:
            Fn::GetAtt:
              - NetworkStack
              - Outputs.VpcId
          VSwitchId:
            Fn::GetAtt:
              - NetworkStack
              - Outputs.VSwitchId
          IoOptimized:
            Ref: IoOptimized
          ZoneId:
            Ref: ZoneId
          SystemDisk_Category:
            Ref: SystemDiskCategory
          DiskMappings:
            - Category: cloud_ssd
              Size: 20
    Outputs:
      InstanceId:
        Value:
          Fn::GetAtt:
            - WebServer
            - InstanceId
      PublicIp:
        Value:
          Fn::GetAtt:
            - WebServer
            - PublicIp
      SecurityGroupId:
        Value:
          Fn::GetAtt:
            - NetworkStack
            - Outputs.SecurityGroupId
      VpcId:
        Value:
          Fn::GetAtt:
            - NetworkStack
            - Outputs.VpcId
      VSwitchId:
        Value:
          Fn::GetAtt:
            - NetworkStack
            - Outputs.VSwitchId
      NetworkStackArn:
        Value:
          Ref: NetworkStack
    
  • JSON format

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Description": "One ECS instance.",
      "Parameters": {
        "ImageId": {
          "Default": "centos_7",
          "Type": "String",
          "Description": "Image Id, represents the image resource to startup the ECS instance"
        },
        "InstanceType": {
          "Type": "String",
          "Description": "The ECS instance type,",
          "Default": "ecs.xn4.small"
        },
        "ZoneId": {
          "Type": "String",
          "Description": "The available zone "
        },
        "InstanceChargeType": {
          "Type": "String",
          "AllowedValues": [
            "PrePaid",
            "PostPaid"
          ],
          "Default": "PostPaid",
          "Description": "The instance charge type"
        },
        "SecurityGroupName": {
          "Type": "String",
          "Description": "The security group name",
          "Default": "my-sg-name"
        },
        "NetworkInterfaceName": {
          "Type": "String",
          "Description": "The Network interface name",
          "Default": "my-eni-name"
        },
        "VpcName": {
          "Type": "String",
          "Description": "The VPC name",
          "MinLength": 2,
          "MaxLength": 128,
          "ConstraintDescription": "[2, 128] English or Chinese letters",
          "Default": "my-vpc-name"
        },
        "IoOptimized": {
          "AllowedValues": [
            "none",
            "optimized"
          ],
          "Description": "IO optimized, optimized is for the IO optimized instance type",
          "Type": "String",
          "Default": "optimized"
        },
        "SystemDiskCategory": {
          "AllowedValues": [
            "cloud",
            "cloud_efficiency",
            "cloud_ssd"
          ],
          "Description": "System disk category: average cloud disk(cloud), efficient cloud disk(cloud_efficiency) or SSD cloud disk(cloud_ssd)",
          "Type": "String",
          "Default": "cloud_ssd"
        },
        "VpcCidrBlock": {
          "Type": "String",
          "AllowedValues": [
            "192.168.0.0/16",
            "172.16.0.0/12",
            "10.0.0.0/8"
          ],
          "Default": "10.0.0.0/8"
        },
        "VSwitchCidrBlock": {
          "Type": "String",
          "Description": "The VSwitch subnet which must be within VPC",
          "Default": "10.0.10.0/24"
        },
        "UpdateVersion": {
          "Type": "Number",
          "Default": 0
        }
      },
      "Resources": {
        "NetworkStack": {
          "Type": "ALIYUN::ROS::Stack",
          "Properties": {
            "TemplateURL": "oss://ros/template/vpc.txt",
            "TimeoutMins": 5,
            "Parameters": {
              "ZoneId": {
                "Ref": "ZoneId"
              },
              "SecurityGroupName": {
                "Ref": "SecurityGroupName"
              },
              "VpcName": {
                "Ref": "VpcName"
              },
              "VpcCidrBlock": {
                "Ref": "VpcCidrBlock"
              },
              "VSwitchCidrBlock": {
                "Ref": "VSwitchCidrBlock"
              },
              "UpdateVersion": {
                "Ref": "UpdateVersion"
              }
            }
          }
        },
        "WebServer": {
          "Type": "ALIYUN::ECS::Instance",
          "Properties": {
            "ImageId": {
              "Ref": "ImageId"
            },
            "InstanceType": {
              "Ref": "InstanceType"
            },
            "InstanceChargeType": {
              "Ref": "InstanceChargeType"
            },
            "SecurityGroupId": {
              "Fn::GetAtt": [
                "NetworkStack",
                "Outputs.SecurityGroupId"
              ]
            },
            "VpcId": {
              "Fn::GetAtt": [
                "NetworkStack",
                "Outputs.VpcId"
              ]
            },
            "VSwitchId": {
              "Fn::GetAtt": [
                "NetworkStack",
                "Outputs.VSwitchId"
              ]
            },
            "IoOptimized": {
              "Ref": "IoOptimized"
            },
            "ZoneId": {
              "Ref": "ZoneId"
            },
            "SystemDisk_Category": {
              "Ref": "SystemDiskCategory"
            },
            "DiskMappings": [
              {
                "Category": "cloud_ssd",
                "Size": 20
              }
            ]
          }
        }
      },
      "Outputs": {
        "InstanceId": {
          "Value": {
            "Fn::GetAtt": [
              "WebServer",
              "InstanceId"
            ]
          }
        },
        "PublicIp": {
          "Value": {
            "Fn::GetAtt": [
              "WebServer",
              "PublicIp"
            ]
          }
        },
        "SecurityGroupId": {
          "Value": {
            "Fn::GetAtt": [
              "NetworkStack",
              "Outputs.SecurityGroupId"
            ]
          }
        },
        "VpcId": {
          "Value": {
            "Fn::GetAtt": [
              "NetworkStack",
              "Outputs.VpcId"
            ]
          }
        },
        "VSwitchId": {
          "Value": {
            "Fn::GetAtt": [
              "NetworkStack",
              "Outputs.VSwitchId"
            ]
          }
        },
        "NetworkStackArn": {
          "Value": {
            "Ref": "NetworkStack"
          }
        }
      }
    }