There are a number of functions that you can use to help you write templates.
All of these functions (except Ref) start with Fn::.
Return the value of the named parameter or Resource.
{Ref: my_server}
Returns the nova instance ID. For example, d8093de0-850f-4513-b202-7979de6c0d55
This returns the Base64 representation of the input string.
Returns the value corresponding to keys into a two-level map declared in the Mappings section.
Mapping:
MyContacts:
jone: {phone: 337, email: [email protected]}
jim: {phone: 908, email: [email protected]}
{"Fn::FindInMap": ["MyContacts", "jim", "phone" ] }
Returns 908
Returns an attribute of a Resource within the template.
Return the Availability Zones within the given region.
Note: AZ’s and regions are not fully implemented in Heat.
Like python join, it joins a list of strings with the given delimiter.
Select an item from a list.
Heat extension: Select an item from a map
For a list lookup:
{ "Fn::Select" : [ "2", [ "apples", "grapes", "mangoes" ] ] }
Returns mangoes
For a map lookup:
{ "Fn::Select" : [ "red", {"red": "a", "flu": "b"} ] }
Returns a
This is the reverse of Join. Convert a string into a list based on the delimiter.
Find an replace one string with another.
{"Fn::Replace": [
{'$var1': 'foo', '%var2%': 'bar'},
'$var1 is %var2%'
]}
returns
"foo is bar"
{'Fn::ResourceFacade': 'Metadata'}
{'Fn::ResourceFacade': 'DeletionPolicy'}
{'Fn::ResourceFacade': 'UpdatePolicy'}
Here is a top level template top.yaml
resources:
my_server:
type: OS::Nova::Server
metadata:
key: value
some: more stuff
Here is a resource template my_actual_server.yaml
resources:
_actual_server_:
type: OS::Nova::Server
metadata: {'Fn::ResourceFacade': Metadata}
The environment file env.yaml
resource_registry:
resources:
my_server:
"OS::Nova::Server": my_actual_server.yaml
To use it
heat stack-create -f top.yaml -e env.yaml
What happened is the metadata in top.yaml (key: value, some: more stuff) gets passed into the resource template via the Fn::ResourceFacade function.
Convert an AWS style member list into a map.
{'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'}