GetAtt

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.

The get_att method is the CloudFormation Fn::GetAtt equivalent.

Example Snippet

resource("MyElb", "AWS::ElasticLoadBalancing::LoadBalancer",
  AvailabilityZones: ["eu-west-1a"],
  Listeners: [{
    LoadBalancerPort: "80",
    InstancePort: "80",
    Protocol: "HTTP"
  }]
)
resource("MyElbIngressGroup", "AWS::EC2::SecurityGroup",
  GroupDescription: "ELB ingress group",
  SecurityGroupIngress: [{
    IpProtocol: "tcp",
    FromPort: "80",
    ToPort: "80",
    SourceSecurityGroupOwnerId: get_att("MyElb.SourceSecurityGroup.OwnerAlias"),
    SourceSecurityGroupName: get_att("MyElb.SourceSecurityGroup.GroupName")
  }]
)

Example Output

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

Back to Intrinsic Functions List.