eladkal commented on a change in pull request #21523:
URL: https://github.com/apache/airflow/pull/21523#discussion_r805616731
##########
File path: airflow/providers/amazon/aws/example_dags/example_eks_templated.py
##########
@@ -49,50 +44,53 @@
"""
with DAG(
- dag_id='to-publish-manuals-templated',
- default_args={'cluster_name': "{{ dag_run.conf['cluster_name'] }}"},
+ dag_id='example_eks_templated',
schedule_interval=None,
start_date=datetime(2021, 1, 1),
- catchup=False,
- max_active_runs=1,
tags=['example', 'templated'],
+ catchup=False,
# render_template_as_native_obj=True is what converts the Jinja to Python
objects, instead of a string.
render_template_as_native_obj=True,
) as dag:
- SUBNETS = os.environ.get('EKS_DEMO_SUBNETS', 'subnet-12345ab
subnet-67890cd').split(' ')
- VPC_CONFIG = {
- 'subnetIds': SUBNETS,
- 'endpointPublicAccess': True,
- 'endpointPrivateAccess': False,
- }
+
+ CLUSTER_NAME = "{{ dag_run.conf['cluster_name'] }}"
+ NODEGROUP_NAME = "{{ dag_run.conf['nodegroup_name'] }}"
+ VPC_CONFIG = json.loads("{{ dag_run.conf['resources_vpc_config'] }}")
Review comment:
To render as native Python object you will need
`render_template_as_native_obj=True`
docs
https://airflow.apache.org/docs/apache-airflow/stable/concepts/operators.html#rendering-fields-as-native-python-objects.
The templating is done as part of creating a task instance:
https://github.com/apache/airflow/blob/fded2ca0b9c995737b401896b89e5c9fd7f24c91/airflow/models/taskinstance.py#L1419
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]