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 the ID of an Elastic Compute Service (ECS) instance as an output, the 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 (*).
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