Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 20 additions & 0 deletions docs/jinja2_functions_filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ Parameters:
* ``fallback_value``: a value to use if case the property is missing.


from_resolve
--------------

Parameter: A string that looks like the {{resolve:}} string in AWS CloudFormation

For example, building the string below, we retrieve the key `SASL_JAAS_CONFIG` from the content of the secret, which we
get the ARN from the `env_var` function with value `SECRET_ARN`

.. code-block:: yaml

files:
/tmp/secret.test:
content: |
client.id=sainsburys.applications.sc-ce.cdk-gateway
sasl.mechanism=PLAIN
sasl.jaas.config={{ from_resolve('{{resolve:secretsmanager:' + env_var('SECRET_ARN') + ':SecretString:SASL_JAAS_CONFIG}}') | safe }}
security.protocol=SASL_SSL
#EOF



AWS Specific Filters
=====================
Expand Down
6 changes: 6 additions & 0 deletions ecs_files_composer/jinja2_filters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import requests
import yaml
from aws_cfn_custom_resource_resolve_parser import handle
from boto3.session import Session
from flatdict import FlatDict, FlatterDict

Expand Down Expand Up @@ -210,12 +211,17 @@ def hostname(alternative_value: str = None) -> str:
return alternative_value


def using_resolve(resolve_string: str) -> str:
return handle(resolve_string)


JINJA_FUNCTIONS = {
"ecs_container_metadata": ecs_container_metadata,
"ecs_task_metadata": ecs_task_metadata,
"env_var": env_var,
"from_ssm": from_ssm,
"from_ssm_json": from_ssm_json,
"from_resolve": using_resolve,
"msk_bootstrap": msk_bootstrap,
"hostname": hostname,
}
Expand Down