Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation update: Adding Default Lookup to official docs #636

Merged
merged 3 commits into from
Aug 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions docs/lookups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ concept called lookups. A lookup is meant to take a value and convert
it by calling out to another service or system.

A lookup is denoted in the config with the ``${<lookup type> <lookup
input>}`` syntax. If ``<lookup type>`` isn't provided, the default of
``output`` will be used.
input>}`` syntax. If ``<lookup type>`` isn't provided, stacker will
fall back to use the ``output`` lookup .

Lookups are only resolved within `Variables
<terminology.html#variables>`_. They can be nested in any part of a YAML
Expand Down Expand Up @@ -58,6 +58,7 @@ dictionary::
stacker includes the following lookup types:

- `output lookup`_
- `default lookup`_
- `kms lookup`_
- `xref lookup`_
- `rxref lookup`_
Expand Down Expand Up @@ -86,6 +87,36 @@ You can specify an output lookup with the following syntax::

ConfVariable: ${output someStack::SomeOutput}


.. _`default lookup`:

default Lookup
--------------

The ``default`` lookup type will check if a value exists for the variable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't 100% true, right? It can also be used to give default variables to lookups.

${default ${output MyVpc::VpcId}::vpc-123456}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I... hadn't, really thought of that. It's an interesting idea. I didn't write the lookup module, so let me dig into it to check if that would work. (Or @troyready could chime in, since he wrote it)

in the environment file, then fall back to a default defined in the stacker
config if the environment file doesn't contain the variable. This allows
defaults to be set at the config file level, while granting the user the
ability to override that value per environment.

Format of value::
<env_var>::<default value>

For example::
Groups: ${default app_security_groups::sg-12345,sg-67890}

If `app_security_groups` is defined in the environment file, its defined
value will be returned. Otherwise, `sg-12345,sg-67890` will be the returned
value.

.. note::
The ``default`` lookup only supports checking if a variable is defined in
an environment file. It does not support other embedded lookups to see
if they exist. Only checking variables in the environment file are supported.
If you attempt to have the default lookup perform any other lookup that
fails, stacker will throw an exception for that lookup and will stop your
build before it gets a chance to fall back to the default in your config.

.. _`kms lookup`:

KMS Lookup
Expand Down