💾 Archived View for cfdocs.wetterberg.nu › intrinsic-function-reference-getatt.gemini captured on 2024-03-21 at 15:25:32. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
The `Fn::GetAtt` intrinsic function returns the value of an attribute from a resource in the template. For more information about `GetAtt` return values for a particular resource, refer to the documentation for that resource in the Resource and property reference.
Resource and property reference
{ "Fn::GetAtt" : [ "logicalNameOfResource", "attributeName" ] }
Syntax for the full function name:
Fn::GetAtt: [ logicalNameOfResource, attributeName ]
Syntax for the short form:
!GetAtt logicalNameOfResource.attributeName
`logicalNameOfResource`
The logical name (also called *logical ID*) of the resource that contains the attribute that you want.
`attributeName`
The name of the resource-specific attribute whose value you want. See the resource's reference page for details about the attributes available for that resource type.
The attribute value.
This example snippet returns a string containing the DNS name of the load balancer with the logical name `myELB`.
1. "Fn::GetAtt" : [ "myELB" , "DNSName" ]
1. !GetAtt myELB.DNSName
The following example template returns the `SourceSecurityGroup.OwnerAlias` and `SourceSecurityGroup.GroupName` of the load balancer with the logical name `myELB`.
{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "myELB": { "Type": "AWS::ElasticLoadBalancing::LoadBalancer", "Properties": { "AvailabilityZones": [ "eu-west-1a" ], "Listeners": [ { "LoadBalancerPort": "80", "InstancePort": "80", "Protocol": "HTTP" } ] } }, "myELBIngressGroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "GroupDescription": "ELB ingress group", "SecurityGroupIngress": [ { "IpProtocol": "tcp", "FromPort": 80, "ToPort": 80, "SourceSecurityGroupOwnerId": { "Fn::GetAtt": [ "myELB", "SourceSecurityGroup.OwnerAlias" ] }, "SourceSecurityGroupName": { "Fn::GetAtt": [ "myELB", "SourceSecurityGroup.GroupName" ] } } ] } } } }
AWSTemplateFormatVersion: 2010-09-09 Resources: myELB: Type: AWS::ElasticLoadBalancing::LoadBalancer Properties: AvailabilityZones: - eu-west-1a Listeners: - LoadBalancerPort: '80' InstancePort: '80' Protocol: HTTP myELBIngressGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: ELB ingress group SecurityGroupIngress: - IpProtocol: tcp FromPort: 80 ToPort: 80 SourceSecurityGroupOwnerId: !GetAtt myELB.SourceSecurityGroup.OwnerAlias SourceSecurityGroupName: !GetAtt myELB.SourceSecurityGroup.GroupName
For the `Fn::GetAtt` logical resource name, you cannot use functions. You must specify a string that is a resource's logical ID.
For the `Fn::GetAtt` attribute name, you can use the `Ref` function.