|
| 1 | +.. meta:: |
| 2 | + :description: ECS Files Composer input config |
| 3 | + :keywords: AWS, ECS, Configuration, Jinja |
| 4 | + |
| 5 | +==================================== |
| 6 | +Custom Jinja2 filters & Functions |
| 7 | +==================================== |
| 8 | + |
| 9 | +These filters come in addition to existing `Jinja2 Filters`_ & Functions. |
| 10 | + |
| 11 | +------------ |
| 12 | +Functions |
| 13 | +------------ |
| 14 | + |
| 15 | +AWS ECS |
| 16 | +================= |
| 17 | + |
| 18 | +ecs_container_metadata |
| 19 | +------------------------ |
| 20 | + |
| 21 | +Filter that returns the ECS Container Metadata information |
| 22 | + |
| 23 | +Parameters: |
| 24 | + |
| 25 | +* ``property_key``: the property in the metadata you want to retrieve |
| 26 | +* ``fallback_value``: a value to use if case the property is missing. |
| 27 | + |
| 28 | + |
| 29 | +ecs_task_metadata |
| 30 | +------------------ |
| 31 | + |
| 32 | +Filter that returns the ECS Task Metadata information |
| 33 | + |
| 34 | +Parameters: |
| 35 | + |
| 36 | +* ``property_key``: the property in the metadata you want to retrieve |
| 37 | +* ``fallback_value``: a value to use if case the property is missing. |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +AWS Specific Filters |
| 42 | +===================== |
| 43 | + |
| 44 | +These filters use AWS API to retrieve specific properties. |
| 45 | + |
| 46 | +msk_bootstrap |
| 47 | +--------------- |
| 48 | + |
| 49 | +Parameters: |
| 50 | + * ``cluster_arn``: the ARN of the MSK cluster to use |
| 51 | + * ``broker_type``: the type of Broker endpoints to use. |
| 52 | + |
| 53 | + |
| 54 | +For valid values for ``broker_type``, refer to `boto3.kafka.get_bootstrap_brokers`_ documentation, |
| 55 | +and see the ``Response Syntax`` section. |
| 56 | + |
| 57 | + |
| 58 | +Example to retrieve the Bootstrap servers for SASL + IAM for privately addressed cluster. |
| 59 | + |
| 60 | +.. code-block:: yaml |
| 61 | +
|
| 62 | + files: |
| 63 | + /tmp/conduktor-cdk.yaml: |
| 64 | + context: jinja2 |
| 65 | + content: | |
| 66 | + organization: |
| 67 | + name: ${ORG_NAME:-testing} |
| 68 | + clusters: |
| 69 | + - id: amazon-msk-iam |
| 70 | + name: Amazon MSK IAM |
| 71 | + color: #FF9900 |
| 72 | + bootstrapServers: {{ msk_bootstrap(env_var('BOOTSTRAP_ARN'), 'BootstrapBrokerStringSaslIam') }} |
| 73 | + properties: | |
| 74 | + security.protocol=SASL_SSL |
| 75 | + sasl.mechanism=AWS_MSK_IAM |
| 76 | + sasl.jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required; |
| 77 | + sasl.client.callback.handler.class=io.conduktor.aws.IAMClientCallbackHandler |
| 78 | +
|
| 79 | +from_ssm |
| 80 | +---------- |
| 81 | + |
| 82 | +Returns a value pulled from a SSM parameter. |
| 83 | + |
| 84 | +Parameters |
| 85 | + |
| 86 | +* ``parameter_name``: The name of the SSM parameter to get the value from. |
| 87 | + |
| 88 | +Example |
| 89 | + |
| 90 | +.. code-block:: yaml |
| 91 | +
|
| 92 | + files: |
| 93 | + testing: |
| 94 | + content: | |
| 95 | + my_value: {{ from_ssm('my/ssm/parameter') }} |
| 96 | +
|
| 97 | +
|
| 98 | +Generic Functions |
| 99 | +==================== |
| 100 | + |
| 101 | +Simple functions to gap missing ones from Jinja2 |
| 102 | + |
| 103 | +env_var |
| 104 | +----------- |
| 105 | + |
| 106 | +Retrieves a value from environment variable. Can set a default value. |
| 107 | + |
| 108 | +Parameters |
| 109 | + |
| 110 | +* ``key``: Name of the environment variable |
| 111 | +* ``value``: Default value in case the environment variable is not set. |
| 112 | + |
| 113 | + |
| 114 | +Example |
| 115 | + |
| 116 | +.. code-block:: yaml |
| 117 | +
|
| 118 | + files: |
| 119 | + testing: |
| 120 | + content: | |
| 121 | + my_config_from_env_var: {{ env_var('ENV_VAR_NAME', "a default value") }} |
| 122 | +
|
| 123 | +
|
| 124 | +--------------- |
| 125 | +Filters |
| 126 | +--------------- |
| 127 | + |
| 128 | +Generic filters |
| 129 | +================= |
| 130 | + |
| 131 | +env_override |
| 132 | +------------- |
| 133 | + |
| 134 | +Similar to `env_var`_, it sets a value from environment variable, but expect a value to be already set. |
| 135 | + |
| 136 | +to_yaml |
| 137 | +--------- |
| 138 | + |
| 139 | +Renders an input into YAML |
| 140 | + |
| 141 | +to_json |
| 142 | +-------- |
| 143 | + |
| 144 | +Renders an input into JSON |
| 145 | + |
| 146 | + |
| 147 | +.. _boto3.kafka.get_bootstrap_brokers: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/kafka.html#Kafka.Client.get_bootstrap_brokers |
| 148 | +.. _Jinja2 Filters: https://jinja.palletsprojects.com/en/3.1.x/templates/#id11 |
0 commit comments