Skip to main content
  1. Projects/
  2. AWS DevOps Pro Certification/
  3. 2: Configuration Mgmt / Infrastructure as Code/
  4. 2: CloudFormation/

1: CloudFormation Intrinsic Functions

·1 min


  • Returns the value of the specified parameter or resource
  • Json: { "Ref" : "logicalName" }
  • Yaml: !Ref logicalName


  • It’s a hashmap lookup.
  • Find e.g. AMI for a type of instance in a certain region

What are CF intrinsic functions?

  • Built-in funcs to dynamically assign values to properties at runtime
  • E.g. retrieve public IP of ec2 instance in the stack at runtime


  • Returns value of an attribute from a resource
  • JSON: Fn::GetAtt: [logicalNameOfResource, attributeName]


  • Returns value of an output exported by another stack
    • (Cross-stack reference)
  • Values are spit out from “output” section of another stack
  • JSON: "Fn::ImportValue" : {"Fn::Sub" : ${NetworkStackNameParameter}-SecurityGroupID"}


  • String substitution builder
  • JSON: {"Fn::Sub": ["www.${Domain}", {"Domain": {"Ref": "RootDomainName"}}]}


  • Concatenate strings
  • Yaml: !Join [ "/", ["s3://mybucket", !Ref myfolder, "myfile.txt" ] ]
  • Result: "s3://mybucket/myFolderValue/myfile.txt"

Condition Funcs

  • Boolean operators: And, or, if, not, equals
  • If prod: Beefy server, if dev: scrappy box
  • Create or not create resources based on conditions