The built-in function Fn::GetAtt returns the value of a property from a resource in a template.
Return the value of a property from 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 name of the property whose value you want to query from the resource in the stack.
Return value
The value of the property. That is, the value of the attributeName
parameter.
Examples
In this example, the value of the ImageId property is returned from the resource named MyEcsInstance.
!GetAtt MyEcsInstance.ImageID
{
"Fn::GetAtt": [
"MyEcsInstance",
"ImageID"
]
}
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
Return the value of a property from the outputs of 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
NoteIf you use the YAML syntax for the short form to query the value of a property from the outputs of a nested stack, you can specify a name that contains periods (
.
) for the nested stack. The name of the property whose value you want to query from the outputs of 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 name of the property whose value you want to query from the outputs of the nested stack.
Return value
The property value that is returned from the outputs of the nested stack.
Examples
For more information, see ALIYUN::ROS::Stack.