Skip to content

Instantly share code, notes, and snippets.

@TheDeveloper
Created May 8, 2018 17:08
Show Gist options
  • Save TheDeveloper/8da2386ebdd4267c741817a8da9478fe to your computer and use it in GitHub Desktop.
Save TheDeveloper/8da2386ebdd4267c741817a8da9478fe to your computer and use it in GitHub Desktop.
A quick reference of common CloudFormation elements

Intrinsic functions

!Ref ResourceName
{ "Fn::Ref": "ResourceName" }

!GetAtt ResourceName.AttributeName
{ "Fn::GetAtt": [ "ResourceName", "AttributeName" ] }

!Sub "something:with:${Variable}"
{ "Fn:Sub": "something:with:${Variable}" }

!Sub
  - something:with:${Variable}
  - { Variable: "foo" }
{ "Fn:Sub": [ "something:with:${Variable}", { "Variable": "foo" } ] }

Syntax

Yaml form Yaml Shorthand Original JSON
Fn::Ref arg !Ref arg { "Fn::Ref": arg }

Intrinsic functions can be nested, but take care with the shorthand yaml form as that cannot be nested consecutively.

Ok: Fn::GetAZs: !Ref 'AWS::Region'
Not Ok: !GetAZs !Ref 'AWS::Region'

Global variables

AWS::Region
AWS::AccountId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment