AWS CloudFormation provides several built-in functions that help you manage your stacks.

Among them, 2 of the most used are Fn::GetAtt and Ref . I’ve gotten feedbacks when teaching that these 2 look so similar and when should you use which one? I had a similar confusion at first.


This is how you declare a Ref function:

  • JSON
    • { “Ref” : “logicalName” }
  • YAML
    • Ref: logicalName

Ref is used to refer to the logical name of another resource. Ref function returns a value that’s predefined for each resource.

  • For example if your EC2 instances had a logical name of EC2 :
    • Ref: EC2 will return the InstanceId
  • Ref on AWS::EC2::EIP will return the IP address

Here’s a short list of predefined values that will be returned when you use a Ref function:

AWS::EC2::Subnet : Subnet ID


AWS::S3::Bucket: Name of the bucket

AWS::IAM::User: User Name


This is how you declare/use a Fn:GetAtt function:

  • JSON
    • { “Fn::GetAtt” : [ “logicalNameOfResource”, “attributeName” ] }


  • Fn::GetAtt: [ logicalNameOfResource, attributeName ]

Unlike Ref , Fn: GetAtt has 2 fields where you put the logical name of the resource in the first field and the desired attribute name in the second field. You may choose from available attributes.

For example , in the case of EC2 you can choose from these attributes:

1) AvailabilityZone

The Availability Zone where the instance that you specified is launched.

Returns: us-east-1a

2) PrivateDnsName

The private DNS name of the instance that you specified.

Returns something like : ip-10-1-3-4.ec2.internal

3) PublicDnsName

The public DNS name of the instance that you specified.

Returns something like :

4) PrivateIp

The private IP address of the instance that you specified.

Returns something like:

5) PublicIp

The public IP address of the instance that you specified. Returns something like:


I hope this clears up what the difference between these two functions are. Or I hope ( if you’ve never worked with cloudformation functions) you get an idea of what cloudformation functions can do.

Thanks and see you in the next lesson!


Leave a Reply

Please Login to comment
newest oldest most voted
Notify of

212751 185318hello very good internet site i will definaely come back and see once again. 606921

… [Trackback]

[…] Read More here: […]

Hi. I have checked your and i see you’ve got some duplicate
content so probably it is the reason that you
don’t rank high in google. But you can fix this issue fast.

There is a tool that rewrites articles like human, just search in google:
miftolo’s tools

Heya! I just wanted to ask if you ever have any problems with hackers? My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no back up. Do you have any methods to stop hackers?

Really wonderful info can be found on website. “Every artist was first an amateur.” by Ralph Waldo Emerson.

903902 482724A excellent clear cut answer and a fantastic concept. But how do I post any work on this web site is an additional question. The Foureyed Poet. 929025

158654 16131Someone essentially lend a hand to make critically articles Id state. That is the first time I frequented your site page and so far? I amazed with the research you created to create this actual post extraordinary. Wonderful activity! 970481

976959 34224Having read this I thought it was quite informative. I appreciate you taking the time and effort to put this article together. I once once again locate myself spending method to considerably time both reading and commenting. But so what, it was still worth it! 348509

Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just extremely magnificent. I really like what you have acquired here, really like what you’re stating and the way in which you say it. You make it entertaining and you still care for to keep it wise. I can’t wait to read far more from you. This is actually a terrific site.

647448 849995Hello fellow internet master! I actually enjoy your site! I liked the color of your sidebar. 947704