Skip to content

Instantly share code, notes, and snippets.

@schlarpc
Created March 8, 2021 01:39
Show Gist options
  • Save schlarpc/18c3798d067e9fec55f5d9beb36e6951 to your computer and use it in GitHub Desktop.
Save schlarpc/18c3798d067e9fec55f5d9beb36e6951 to your computer and use it in GitHub Desktop.
CloudFormation functions as Nix expressions
GetAtt = resource: attribute: { "Fn::GetAtt" = [ resource.logical_id attribute ]; };
Ref = resource: { "Ref" = [ resource.logical_id ]; };
Split = delimiter: string: { "Fn::Split" = [ separator string ]; };
Sub = template: values: { "Fn::Sub" = [ template values ]; };
Select = index: values: { "Fn::Select" = [ index objects ]; };
Join = delimiter: values: { "Fn::Join" = [ delimiter values ]; };
FindInMap = name: key1: key2 { "Fn::FindInMap" = [ name key1 key2 ]; };
Base64 = value: { "Fn::Base64" = value };
ImportValue = name: { "Fn::ImportValue" = name; };
GetAZs = region: { "Fn::GetAZs" = region; };
Transform = name: parameters: { "Fn::Transform" = { Name = name; Parameters = parameters; }; };
Cidr = cidr: count: bits: { "Fn::Cidr" = [ cidr count bits ]; };
And = conditions: { "Fn::And" = conditions; };
Or = conditions: { "Fn::Or" = conditions; };
If = condition: true_value: false_value: { "Fn::If" = [ condition true_value false_value ]; };
Not = condition: { "Fn::Not" = [ condition ]; };
Equals = value1: value2: { "Fn::Equals" = [ value1 value2 ]; };
AccountId = Ref "AWS::AccountId"
NotificationARNs = Ref "AWS::NotificationARNs"
NoValue = Ref "AWS::NoValue"
Partition = Ref "AWS::Partition"
Region = Ref "AWS::Region"
StackId = Ref "AWS::StackId"
StackName = Ref "AWS::StackName"
URLSuffix = Ref "AWS::URLSuffix"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment