A Jinja filter for allowing Sceptre resolvers in var files
Project description
README
Overview
A custom Jinja filter for Sceptre for unquoting resolvers appearing in var files.
Motivation
In Sceptre, resolvers are an essential feature for simplifying complex
configurations by enabling dynamic data retrieval. Resolvers such as
!stack_output_external
and !stack_output
are particularly useful
for referencing output values from other stacks or external sources,
among many others.
When using resolvers in var files, however, they must be protected from being interpreted as YAML tags by the YAML loader.
This plugin addresses this challenge by allowing you to safely include resolvers in your var files. It ensures that resolvers are not processed as YAML tags by the loader, and then turned back into YAML tags after Jinja interpolation in the generated config.
Installation
Installation instructions
To install directly from PyPI
pip install jinja-unquote-resolvers-filter
To install from the git repo
pip install git+https://github.com/Sceptre/jinja-unquote-resolvers-filter.git
Usage/Examples
In your var file:
Subnets:
- '!stack_output_external mystack::subnet_a' # Quotes needed to protect a YAML tag.
- '!stack_output_external mystack::subnet_b'
VPC: '!stack_output_external mystack::vpc_id'
In your config:
j2_environment:
extensions:
- jinja_unquote_resolvers_filter.UnquoteResolversFilterExtension
sceptre_user_data:
subnets:
{{ var.Subnets | unquote_resolvers(output_indent=4, trim=True) }}
vpc: {{ var.VPC }} # This filter is not needed if the quoted resolvers are passed in as scalars.
Arguments
indent
(optional, default=2): The number of spaces to use for indentation of nested structures in the output YAML.output_indent
(optional, default=0): The number of spaces to use for indentation of the entire output YAML.trim
(optional, default=False): Whether to trim leading and trailing spaces in the output YAML.
Limitations
At this time, resolver expressions must be wrapped in a single line of text. That is, instead of:
my_multiline_resolver: |
!from_json
- !request http://www.whatever.com
Instead write:
my_multiline_resolver: '!from_json [!request http://www.whatever.com]'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jinja_unquote_resolvers_filter-1.1.0.tar.gz
.
File metadata
- Download URL: jinja_unquote_resolvers_filter-1.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-1014-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f78794403019b26de484a25cb0ea3682580a6d54e5cf456a0a5604e6c35e22ab |
|
MD5 | 7bdf382789848e8903414f2b04bce4ea |
|
BLAKE2b-256 | 47d017b34440692a508daaa0b8a206cacd3e713731a51736cee303ea85a051c4 |
File details
Details for the file jinja_unquote_resolvers_filter-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: jinja_unquote_resolvers_filter-1.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-1014-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d931355ecf391984d6a7ebc9d4cabc1243ce82eefea307e5c3e7cd8118d3e398 |
|
MD5 | 0eaa3386fd2aacd05ba8f9425614adc5 |
|
BLAKE2b-256 | 818d60bef9766c34b85bd1fbfb54fedddf55f35619235c4cf5801a2ee8d0a62d |