CloudFormation Compatible FunctionsThere are a number of functions that you can use to help you write
CloudFormation compatible templates. While most CloudFormation functions are
supported in HOT version '2013-05-23', Fn::Select is the only CloudFormation
function supported in HOT templates since version '2014-10-16' which is
introduced in Juno.All of these functions (except Ref) start with Fn::.RefReturns the value of the named parameter or resource.ParametersnameThe name of the resource or parameter.Usage{Ref: my_server}Returns the nova instance ID. For example, d8093de0-850f-4513-b202-7979de6c0d55.Fn::Base64This is a placeholder for a function to convert an input string to Base64.
This function in Heat actually performs no conversion. It is included for
the benefit of CFN templates that convert UserData to Base64. Heat only
accepts UserData in plain text.ParametersvalueThe string to convert.Usage{"Fn::Base64": "convert this string please."}Returns the original input string.Fn::FindInMapReturns the value corresponding to keys into a two-level map declared in the
Mappings section.Parametersmap_nameThe logical name of a mapping declared in the Mappings section that
contains the keys and values.top_level_keyThe top-level key name. It's value is a list of key-value pairs.second_level_keyThe second-level key name, which is set to one of the keys from the list
assigned to top_level_key.UsageMapping:
MyContacts:
jone: {phone: 337, email: a@b.com}
jim: {phone: 908, email: g@b.com}
{"Fn::FindInMap": ["MyContacts", "jim", "phone" ] }Returns 908.Fn::GetAttReturns an attribute of a resource within the template.ParametersresourceThe name of the resource.attributeThe name of the attribute.Usage{Fn::GetAtt: [my_server, PublicIp]}Returns an IP address such as 10.0.0.2.Fn::GetAZsReturns the Availability Zones within the given region.Note: AZ's and regions are not fully implemented in Heat.ParametersregionThe name of the region.Usage{Fn::GetAZs: ""}Returns the list provided by nova availability-zone-list.Fn::JoinLike python join, it joins a list of strings with the given delimiter.ParametersdelimiterThe string to join the list with.listThe list to join.Usage{Fn::Join: [",", ["beer", "wine", "more beer"]]}Returns beer, wine, more beer.Fn::SelectSelect an item from a list.Heat extension: Select an item from a mapParametersselectorThe number of item in the list or the name of the item in the map.collectionThe collection to select the item from.UsageFor a list lookup:{ "Fn::Select" : [ "2", [ "apples", "grapes", "mangoes" ] ] }Returns mangoes.For a map lookup:{ "Fn::Select" : [ "red", {"red": "a", "flu": "b"} ] }Returns a.Fn::SplitThis is the reverse of Join. Convert a string into a list based on the
delimiter.ParametersdelimiterMatching string to split on.stringThe string to split.Usage{ "Fn::Split" : [ ",", "str1,str2,str3,str4"]}Returns {["str1", "str2", "str3", "str4"]}.Fn::ReplaceFind and replace one string with another.ParameterssubstitutionsA map of substitutions.string: StringThe string to do the substitutions in.Usage{"Fn::Replace": [
{'$var1': 'foo', '%var2%': 'bar'},
'$var1 is %var2%'
]}Returns "foo is bar".Fn::ResourceFacadeWhen writing a Template Resource:user writes a template that will fill in for a resource (the resource is the facade).when they are writing their template they need to access the metadata from
the facade.Parametersattribute_nameOne of Metadata, DeletionPolicy or UpdatePolicy.Usage{'Fn::ResourceFacade': 'Metadata'}
{'Fn::ResourceFacade': 'DeletionPolicy'}
{'Fn::ResourceFacade': 'UpdatePolicy'}ExampleHere is a top level template top.yamlresources:
my_server:
type: OS::Nova::Server
metadata:
key: value
some: more stuffHere is a resource template my_actual_server.yamlresources:
_actual_server_:
type: OS::Nova::Server
metadata: {'Fn::ResourceFacade': Metadata}The environment file env.yamlresource_registry:
resources:
my_server:
"OS::Nova::Server": my_actual_server.yamlTo use it$ heat stack-create -f top.yaml -e env.yamlWhat happened is the metadata in top.yaml (key: value, some: more
stuff) gets passed into the resource template via the Fn::ResourceFacade
function.Fn::MemberListToMapConvert an AWS style member list into a map.Parameterskey name: stringThe name of the key (normally "Name" or "Key").value name: stringThe name of the value (normally "Value").list: A list of stringsThe string to convert.Usage{'Fn::MemberListToMap': ['Name', 'Value', ['.member.0.Name=key',
'.member.0.Value=door',
'.member.1.Name=colour',
'.member.1.Value=green']]}Returns {'key': 'door', 'colour': 'green'}.