All Products
Search
Document Center

Resource Orchestration Service:Fn::GetAtt

Last Updated:Mar 15, 2024

The built-in function Fn::GetAtt returns the property value of a resource from a template.

Query the property value of a resource in a regular stack

Declaration

  • JSON

    {
      "Fn::GetAtt": [
        "logicalNameOfResource",
        "attributeName"
      ]
    }
  • YAML

    • Syntax for the full function name:

      Fn::GetAtt:
        - logicalNameOfResource
        - attributeName
    • Syntax for the short form:

      !GetAtt logicalNameOfResource.attributeName

Parameters

  • logicalNameOfResource: the logical name of the resource in the stack. The logical name is a name that you define for a resource in the template for easy identification.

  • attributeName: the property name of the resource in the stack.

Return value

The property value of the resource in the stack. That is, the value of the attributeName parameter.

Examples

In this example, the value of the ImageId property of the resource named MyEcsInstance is returned.

!GetAtt MyEcsInstance.ImageID
{
  "Fn::GetAtt": [
    "MyEcsInstance",
    "ImageID"
  ]
}
Note

If you use the syntax for the short form to reference a resource output in a stack template, you can specify a name that contains periods (.) for the resource. To prevent errors, we recommend that you do not specify logical names that contain periods (.) for resources.

Resources:
  Foo.Moo.MyInstance:
    Type: ALIYUN::ECS::InstanceGroup
Outputs:
  ImageId:
    Value: !GetAtt Foo.Moo.MyInstance.ImageID

Query the property value of a resource in a nested stack

Declaration

  • JSON

    {
      "Fn::GetAtt": [
        "nestedStackName",
        "Outputs.attributeName"
      ]
    }
  • YAML

    • Syntax for the full function name:

      Fn::GetAtt:
       - nestedStack
       - Outputs.attributeName
    • Syntax for the short form:

      !GetAtt nestedStack.Outputs.attributeName
      Note

      If you use the YAML syntax for the short form to query the output of a nested stack, you can specify a name that contains periods (.) for the nested stack. The property name that you want to query from a nested stack cannot contain periods (.).

Parameters

  • nestedStack: the name of the nested stack. For more information about nested stacks, see Use nested stacks.

  • Outputs.attributeName: Outputs. is a fixed prefix. attributeName specifies the property name that you want to query from the nested stack.

Return value

The property value that is queried from the nested stack.

Examples

For more information, see ALIYUN::ROS::Stack.