All Products
Search
Document Center

Resource Orchestration Service:Outputs

Last Updated:Jan 23, 2025

In the Outputs section, you can define the values that Resource Orchestration Service (ROS) returns when the GetStack operation is called. For example, if you define an Elastic Compute Service (ECS) instance ID as an output, the ECS instance ID is returned when the GetStack operation is called.

Syntax

The declaration of an output includes an output name and an output description. Each output can have multiple values that are returned in an array. The following sample code provides an example on the syntax of the Outputs section:

Outputs:
  Name of Output 1:
    Description: the description of the output.
    Condition: the condition that determines whether to return a specific resource property.
    Value: the expression of the output value.
    Label: the alias of the output.
  Name of Output 2:
    Description: the description of the output.
    Condition: the condition that determines whether to return a specific resource property.
    Value:
      - Expression 1 of the output value.
      - Expression 2 of the output value.
      - ...
    Label: the alias of the output.
  • Name: the name of the output. An output name identifies an output and must be unique in a template.

  • Description: the description of the output. This field is optional.

  • Value: the value that is returned for a resource property when the GetStack operation is called. This field is required.

  • Condition: the condition that specifies whether to create a resource and return its information. The resource is created and its information is returned only when the specified condition is true. This field is optional.

  • Label: the alias of the output. This field is optional.

  • NoEcho: specifies whether to mask the parameter value that is returned. If you set NoEcho to true, ROS returns the parameter value masked as asterisks (*). This field is optional.

  • Console.Url: the console URL that is displayed on the Stack Information tab of the stack details page. This field is optional.

Note

In the value of an output, you can define functions and literals such as numbers, strings, dictionaries, and lists. You can also define Ref to reference values and Fn::GetAtt to query resource property values.

Examples

In the following example, two outputs are used. The ID of the first output is the InstanceId property of WebServer. The ID of the second output is the PublicIp and PrivateIp properties of WebServer.

Outputs:
  InstanceId:
    Value:
      Fn::GetAtt:
        - WebServer
        - InstanceId
  PublicIp & PrivateIp:
    Value:
      - Fn::GetAtt:
          - WebServer
          - PublicIp
      - Fn::GetAtt:
          - WebServer
          - PrivateIp

In the following example, WebServer is created only when the condition that is specified by MaxAmount is true.

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  MaxAmount:
    Type: Number
    Default: 1
Conditions:
  CreateWebServer:
    Fn::Not:
      Fn::Equals:
        - 0
        - Ref: MaxAmount
Resources:
  WebServer:
    Type: ALIYUN::ECS::InstanceGroup
    Condition: CreateWebServer
    Properties:
      ImageId: m-25l0r****
      InstanceType: ecs.t1.small
      MaxAmount:
        Ref: MaxAmount
Outputs:
  WebServerIP:
    Condition: CreateWebServer
    Value:
      Fn::GetAtt:
        - WebServer
        - PublicIps

In the following example, output values of multiple types are returned, such as the list, dictionary, function, and constant types. Console.Url that specifies the URL of the service console is used as an output.

ROSTemplateFormatVersion: '2015-09-01'
Metadata: {}
Parameters:
  DictObjectParameter:
    Default:
      k2: v2
      k1: v1
    Type: Json
  NumberParameter:
    Default: 3.14
    Type: Number
  StringParameter:
    Default: ecs.c1.large
    Type: String
  ArrayListParameter:
    Default:
      - xiaomi
      - xiaofeng
      - xiaoliang
    Type: Json
  EcsInstancePublicIp:
    Default: 1.1.X.X
    Type: String
Resources: {}
Outputs:
  Console.Url:
    Description: Console Url Demo Value
    Value:
      Fn::Sub:
        - http://${EcsPublicIp}/elasticsearch-demo
        - EcsPublicIp:
            Ref: EcsInstancePublicIp
  ArrayList:
    Description: ArrayList Output Value
    Value:
      Ref: ArrayListParameter
  DictObject:
    Description: DictObject Output Value
    Value:
      Ref: DictObjectParameter
  Number:
    Description: Number Output Value
    Value:
      Ref: NumberParameter
  String:
    Description: String Output Value
    Value:
      Ref: StringParameter

In the following example, an output value is defined to return multiple web server URLs separated by commas (,).

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  WebServerAddress:
    Type: String
    Default: 192.168.1.1
    Label:
       
      en: WebServerAddress
Outputs:
  WebServerAddress:
    Description:
       
      en: Web Server url.
    Value:
      Fn::Sub:
        - http://${WebServerAddress}:80,http://${WebServerAddress}:8080,http://${WebServerAddress}:8881
        - WebServerAddress:
            Ref: WebServerAddress