All Products
Search
Document Center

Resource Orchestration Service:Outputs

Last Updated:Sep 23, 2024

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 specifies 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 specifies 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.
  • An output name identifies an output. Output names must be unique in a template.

  • Description: Optional. The description of the output.

  • Value: Required. The value that is returned for a resource property when the GetStack operation is called.

  • Condition: Optional. 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.

  • Label: Optional. The alias of the output.

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

  • Console.Url: Optional. The console URL that is displayed on the Stack Information tab of the stack details page.

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 such as the list, dictionary, function, and constant types are returned. 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.1.1
    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