edit-icon download-icon

Outputs

Last Updated: May 16, 2018

In Outputs, you can define the values to be returned when the stack query interface is called. For example, you can define the output of an ECS instance ID, and then call the stack query interface to view this instance ID.

Syntax

Outputs consist of the output ID and description. The output descriptions are included in parentheses. If you define multiple outputs, use commas (,) to separate them. The following code segment describes the syntax structure of Outputs.

  1. "Outputs" : {
  2. "Output 1 ID": {
  3. "Description": "Output description".
  4. "Condition": "Whether the condition of the resource attribute is to be outputted".
  5. "Value": "Output value expression".
  6. },
  7. "Output 2 ID": {
  8. "Description": "Output description".
  9. "Condition": "Whether the condition of the resource attribute is to be outputted".
  10. "Value": "Output value expression".
  11. }
  12. }

Output ID

Output ID is the output identifier and must be unique in the template.

Description (optional)

Describes the String type of output values.

Value (required)

Values returned when the stack query interface is called.

Condition (optional)

Condition is used to determine whether to create a resource and output the resource information. The resource is created and the resource information is outputted only when the value specified by Condition is true.

As shown in the following example, whether to create WebServer is determined by the value of MaxAmount.

  1. {
  2. "ROSTemplateFormatVersion" : "2015-09-01",
  3. "Parameters": {
  4. "MaxAmount": {
  5. "Type": "Number",
  6. "Default": 1
  7. }
  8. },
  9. "Conditions": {
  10. "CreateWebServer": {"Fn::Not": {"Fn::Equals": [0, {"Ref": "MaxAmount"}]}}
  11. }
  12. "Resources" : {
  13. "WebServer": {
  14. "Type": "ALIYUN::ECS::InstanceGroup",
  15. "Condition": "CreateWebServer",
  16. "Properties": {
  17. "ImageId" : "m-25l0rcfjo",
  18. "InstanceType": "ecs.t1.small"
  19. "MaxAmount": {"Ref": "MaxAmount"}
  20. }
  21. }
  22. }
  23. "Outputs": {
  24. "WebServerIP": {
  25. "Condition": "CreateWebServer",
  26. "Value": {
  27. "Fn::GetAtt": ["WebServer", "PublicIps"]
  28. }
  29. }
  30. }
  31. }

Example

In the following example, Outputs contain resource ID, which is the InstanceId value of WebServer, and resource ID, which is the PublicIp value of WebServer.

  1. "Outputs": {
  2. "InstanceId": {
  3. "Value" : {"Fn::GetAtt": ["WebServer","InstanceId"]}
  4. },
  5. "PublicIp": {
  6. "Value" : {"Fn::GetAtt": ["WebServer","PublicIp"]}
  7. }
  8. }
Thank you! We've received your feedback.