2013-07-25 14:53:51 +10:00
|
|
|
..
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
not use this file except in compliance with the License. You may obtain
|
|
|
|
a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
License for the specific language governing permissions and limitations
|
|
|
|
under the License.
|
2013-08-22 12:27:21 +10:00
|
|
|
|
2014-06-26 17:05:26 +12:00
|
|
|
===================================
|
|
|
|
CloudFormation Compatible Functions
|
|
|
|
===================================
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2014-06-26 17:05:26 +12:00
|
|
|
There are a number of functions that you can use to help you write
|
2014-10-27 22:18:34 +08:00
|
|
|
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.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
All of these functions (except *Ref*) start with *Fn::*.
|
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
---
|
2013-07-25 14:53:51 +10:00
|
|
|
Ref
|
|
|
|
---
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns the value of the named parameter or resource.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
2013-07-27 11:37:32 +12:00
|
|
|
name : String
|
2014-08-23 16:54:19 +02:00
|
|
|
The name of the resource or parameter.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
2015-08-24 11:43:48 +12:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
{Ref: my_server}
|
|
|
|
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns the nova instance ID. For example, ``d8093de0-850f-4513-b202-7979de6c0d55``.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
----------
|
2013-07-25 14:53:51 +10:00
|
|
|
Fn::Base64
|
|
|
|
----------
|
2014-11-28 16:47:46 +08:00
|
|
|
This 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.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
2013-07-27 11:37:32 +12:00
|
|
|
value : String
|
|
|
|
The string to convert.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
|
|
|
|
2015-08-24 11:43:48 +12:00
|
|
|
.. code-block:: yaml
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2014-11-28 16:47:46 +08:00
|
|
|
{"Fn::Base64": "convert this string please."}
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2014-11-28 16:47:46 +08:00
|
|
|
Returns the original input string.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
-------------
|
2013-07-25 14:53:51 +10:00
|
|
|
Fn::FindInMap
|
|
|
|
-------------
|
2013-07-27 11:37:32 +12:00
|
|
|
Returns the value corresponding to keys into a two-level map declared in the
|
|
|
|
Mappings section.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
2013-07-27 11:37:32 +12:00
|
|
|
map_name : String
|
2013-08-22 12:27:21 +10:00
|
|
|
The logical name of a mapping declared in the Mappings section that
|
2013-07-27 11:37:32 +12:00
|
|
|
contains the keys and values.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
top_level_key : String
|
|
|
|
The top-level key name. It's value is a list of key-value pairs.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-08-22 12:27:21 +10:00
|
|
|
second_level_key : String
|
2013-07-27 11:37:32 +12:00
|
|
|
The second-level key name, which is set to one of the keys from the list
|
|
|
|
assigned to top_level_key.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
|
|
|
|
2015-08-24 11:43:48 +12:00
|
|
|
.. code-block:: yaml
|
2013-07-27 11:37:32 +12:00
|
|
|
|
2013-07-25 14:53:51 +10:00
|
|
|
Mapping:
|
|
|
|
MyContacts:
|
|
|
|
jone: {phone: 337, email: a@b.com}
|
|
|
|
jim: {phone: 908, email: g@b.com}
|
|
|
|
|
|
|
|
{"Fn::FindInMap": ["MyContacts", "jim", "phone" ] }
|
|
|
|
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns ``908``.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
----------
|
2013-07-25 14:53:51 +10:00
|
|
|
Fn::GetAtt
|
|
|
|
----------
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns an attribute of a resource within the template.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
2013-07-27 11:37:32 +12:00
|
|
|
resource : String
|
2014-08-23 16:54:19 +02:00
|
|
|
The name of the resource.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
attribute : String
|
|
|
|
The name of the attribute.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
|
|
|
|
2015-08-24 11:43:48 +12:00
|
|
|
.. code-block:: yaml
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
{Fn::GetAtt: [my_server, PublicIp]}
|
|
|
|
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns an IP address such as ``10.0.0.2``.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
----------
|
2013-07-25 14:53:51 +10:00
|
|
|
Fn::GetAZs
|
|
|
|
----------
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns the Availability Zones within the given region.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
*Note: AZ's and regions are not fully implemented in Heat.*
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
2013-07-27 11:37:32 +12:00
|
|
|
region : String
|
|
|
|
The name of the region.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
2015-08-24 11:43:48 +12:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
{Fn::GetAZs: ""}
|
|
|
|
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns the list provided by ``nova availability-zone-list``.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
--------
|
2013-07-25 14:53:51 +10:00
|
|
|
Fn::Join
|
|
|
|
--------
|
|
|
|
Like python join, it joins a list of strings with the given delimiter.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
2013-07-27 11:37:32 +12:00
|
|
|
delimiter : String
|
|
|
|
The string to join the list with.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
list : list
|
|
|
|
The list to join.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
|
|
|
|
2015-08-24 11:43:48 +12:00
|
|
|
.. code-block:: yaml
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
{Fn::Join: [",", ["beer", "wine", "more beer"]]}
|
|
|
|
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns ``beer, wine, more beer``.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
----------
|
2013-07-25 14:53:51 +10:00
|
|
|
Fn::Select
|
|
|
|
----------
|
|
|
|
Select an item from a list.
|
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
*Heat extension: Select an item from a map*
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
2013-07-27 11:37:32 +12:00
|
|
|
selector : string or integer
|
2013-08-22 12:27:21 +10:00
|
|
|
The number of item in the list or the name of the item in the map.
|
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
collection : map or list
|
|
|
|
The collection to select the item from.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
For a list lookup:
|
2015-08-24 11:43:48 +12:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2013-07-27 11:37:32 +12:00
|
|
|
|
2013-07-25 14:53:51 +10:00
|
|
|
{ "Fn::Select" : [ "2", [ "apples", "grapes", "mangoes" ] ] }
|
2013-08-22 12:27:21 +10:00
|
|
|
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns ``mangoes``.
|
2013-07-27 11:37:32 +12:00
|
|
|
|
|
|
|
For a map lookup:
|
2015-08-24 11:43:48 +12:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
{ "Fn::Select" : [ "red", {"red": "a", "flu": "b"} ] }
|
2013-08-22 12:27:21 +10:00
|
|
|
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns ``a``.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
---------
|
2013-07-25 14:53:51 +10:00
|
|
|
Fn::Split
|
|
|
|
---------
|
|
|
|
This is the reverse of Join. Convert a string into a list based on the
|
|
|
|
delimiter.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
2013-07-27 11:37:32 +12:00
|
|
|
delimiter : string
|
|
|
|
Matching string to split on.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
string : String
|
|
|
|
The string to split.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
2015-08-24 11:43:48 +12:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
{ "Fn::Split" : [ ",", "str1,str2,str3,str4"]}
|
|
|
|
|
2014-08-23 16:54:19 +02:00
|
|
|
Returns ``{["str1", "str2", "str3", "str4"]}``.
|
2013-07-27 11:37:32 +12:00
|
|
|
|
|
|
|
-----------
|
2013-07-25 14:53:51 +10:00
|
|
|
Fn::Replace
|
|
|
|
-----------
|
2014-08-23 16:54:19 +02:00
|
|
|
Find and replace one string with another.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
2014-04-25 16:23:15 -07:00
|
|
|
substitutions : map
|
|
|
|
A map of substitutions.
|
2013-07-27 11:37:32 +12:00
|
|
|
string: String
|
|
|
|
The string to do the substitutions in.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
2015-08-24 11:43:48 +12:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2013-08-22 12:27:21 +10:00
|
|
|
|
2013-07-25 14:53:51 +10:00
|
|
|
{"Fn::Replace": [
|
|
|
|
{'$var1': 'foo', '%var2%': 'bar'},
|
|
|
|
'$var1 is %var2%'
|
|
|
|
]}
|
2014-08-23 16:54:19 +02:00
|
|
|
|
|
|
|
Returns ``"foo is bar"``.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
------------------
|
2013-07-25 14:53:51 +10:00
|
|
|
Fn::ResourceFacade
|
|
|
|
------------------
|
|
|
|
When 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.
|
|
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
2013-07-27 11:37:32 +12:00
|
|
|
attribute_name : String
|
|
|
|
One of ``Metadata``, ``DeletionPolicy`` or ``UpdatePolicy``.
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
|
|
|
|
2015-08-24 11:43:48 +12:00
|
|
|
.. code-block:: yaml
|
2013-07-27 11:37:32 +12:00
|
|
|
|
2013-07-25 14:53:51 +10:00
|
|
|
{'Fn::ResourceFacade': 'Metadata'}
|
|
|
|
{'Fn::ResourceFacade': 'DeletionPolicy'}
|
|
|
|
{'Fn::ResourceFacade': 'UpdatePolicy'}
|
|
|
|
|
|
|
|
|
|
|
|
Example
|
|
|
|
~~~~~~~
|
2013-07-27 11:37:32 +12:00
|
|
|
Here is a top level template ``top.yaml``
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2015-08-24 11:43:48 +12:00
|
|
|
.. code-block:: yaml
|
2013-07-27 11:37:32 +12:00
|
|
|
|
2013-07-25 14:53:51 +10:00
|
|
|
resources:
|
|
|
|
my_server:
|
2014-01-17 17:29:50 +08:00
|
|
|
type: OS::Nova::Server
|
2013-07-25 14:53:51 +10:00
|
|
|
metadata:
|
|
|
|
key: value
|
|
|
|
some: more stuff
|
|
|
|
|
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
Here is a resource template ``my_actual_server.yaml``
|
2015-08-24 11:43:48 +12:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2013-07-27 11:37:32 +12:00
|
|
|
|
2013-07-25 14:53:51 +10:00
|
|
|
resources:
|
|
|
|
_actual_server_:
|
2014-01-17 17:29:50 +08:00
|
|
|
type: OS::Nova::Server
|
2013-07-27 11:37:32 +12:00
|
|
|
metadata: {'Fn::ResourceFacade': Metadata}
|
2013-07-25 14:53:51 +10:00
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
The environment file ``env.yaml``
|
2015-08-24 11:43:48 +12:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2013-07-27 11:37:32 +12:00
|
|
|
|
2013-07-25 14:53:51 +10:00
|
|
|
resource_registry:
|
|
|
|
resources:
|
|
|
|
my_server:
|
2014-01-17 17:29:50 +08:00
|
|
|
"OS::Nova::Server": my_actual_server.yaml
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
To use it
|
|
|
|
|
|
|
|
::
|
2013-07-27 11:37:32 +12:00
|
|
|
|
2014-08-23 16:54:19 +02:00
|
|
|
$ heat stack-create -f top.yaml -e env.yaml
|
2013-07-25 14:53:51 +10:00
|
|
|
|
|
|
|
|
2013-07-27 11:37:32 +12:00
|
|
|
What happened is the metadata in ``top.yaml`` (key: value, some: more
|
|
|
|
stuff) gets passed into the resource template via the `Fn::ResourceFacade`_
|
2013-07-25 14:53:51 +10:00
|
|
|
function.
|
2013-08-23 08:31:54 +10:00
|
|
|
|
|
|
|
-------------------
|
|
|
|
Fn::MemberListToMap
|
|
|
|
-------------------
|
|
|
|
Convert an AWS style member list into a map.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
~~~~~~~~~~
|
|
|
|
key name: string
|
2014-08-23 16:54:19 +02:00
|
|
|
The name of the key (normally "Name" or "Key").
|
2013-08-23 08:31:54 +10:00
|
|
|
|
|
|
|
value name: string
|
2014-08-23 16:54:19 +02:00
|
|
|
The name of the value (normally "Value").
|
2013-08-23 08:31:54 +10:00
|
|
|
|
|
|
|
list: A list of strings
|
|
|
|
The string to convert.
|
|
|
|
|
|
|
|
Usage
|
|
|
|
~~~~~
|
2015-08-24 11:43:48 +12:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2013-08-23 08:31:54 +10:00
|
|
|
|
|
|
|
{'Fn::MemberListToMap': ['Name', 'Value', ['.member.0.Name=key',
|
|
|
|
'.member.0.Value=door',
|
|
|
|
'.member.1.Name=colour',
|
|
|
|
'.member.1.Value=green']]}
|
|
|
|
|
2014-08-23 16:54:19 +02:00
|
|
|
|
|
|
|
Returns ``{'key': 'door', 'colour': 'green'}``.
|