All Products
Search
Document Center

Resource Orchestration Service:Fn::GetStackOutput

Last Updated:Mar 15, 2024

The built-in function Fn::GetStackOutput queries the output of a stack.

Declaration

  • JSON

    {
      "Fn::GetStackOutput": [
        Stack,
        OutputName,
        RegionId
      ]
    }
  • YAML

    • Syntax for the full function name:

      Fn::GetStackOutput: Stack, OutputName, RegionId
    • Syntax for the short form:

      !GetStackOutput [Stack, OutputName, RegionId]

Parameters

  • Stack: Required. The parameter specifies the name or ID of your stack. The parameter value must be of the String type.

  • OutputName: Required. The parameter specifies the name of an output in the stack. The parameter value must be of the String type.

  • RegionId: Optional. The parameter specifies the region ID of the stack. The parameter value must be of the String type. If you do not specify this parameter, the region ID of the called stack is used.

Return value

The output that corresponds to the OutputName parameter of the stack. The output type varies based on the output value.

An empty string is returned in the following cases:

  • One of the required parameters is empty.

  • The stack does not exist or is deleted.

  • The stack is running or fails to be deleted.

  • The output does not exist.

Limits

  • Only one-way reference is supported. For example, A->B->C is supported, but A->B->A or A->A is not supported.

  • The maximum reference depth supported is 3. For example, A->B->C is supported, but A->B->C->D->E is not supported.

Note

A, B, C, D, E represents the name of an output in a stack. The maximum reference depth represents the maximum reference depth of OutputName in the Fn::GetStackOutput function.

Sample templates

This section provides sample templates of the following stacks: stack_a, stack_b, and stack_c. The IDs of the stacks are stack_a_id, stack_b_id, and stack_c_id. The output value of stack_a is stack_depth_3. The Fn::GetStackOutput function is invoked to reference the output value of stack_a for stack_b. Then, the Fn::GetStackOutput function is invoked to reference the output value of stack_b for stack_c. As a result, the output value of stack_c is stack_depth_3.

  • stack_a

    ROSTemplateFormatVersion: '2015-09-01'
    Outputs:
    	OutputValueA:
      	Value: 'stack_depth_3'
  • stack_b

    ROSTemplateFormatVersion: '2015-09-01'
    Outputs:
    	OutputValueB:
      	Value: 
        	Fn::GetStackOutPut:
        	- stack_a_id
        	- OutputValueA
  • stack_c

    ROSTemplateFormatVersion: '2015-09-01'
    Outputs:
    	OutputValueC:
      	Value: 
        	Fn::GetStackOutPut:
        	- stack_b_id
        	- OutputValueB

Examples

!GetStackOutput [4a6c9851-3b0f-4f5f-b4ca-a14bf691****, InstanceId]