I'm currently accessing an Airflow variable as follows:
from airflow.models import Variable
s3_bucket = Variable.get('bucket_name')
It works but I'm being asked to not use the Variable module and use jinja templating instead (i.e.):
s3_bucket = '{{ var.value.bucket_name }}'
The problem is jinja works when I'm using it in an airflow template (e.g., PythonOperator/BashOperator) but I'm having trouble getting it to work in taskflow API form. The variable is read as string literal. Example:
# Pretend DAG defined here
@task
def example_task():
s3_bucket = '{{ var.value.bucket_name }}'
print(s3_bucket)
example_task()
The above would print "{{ var.value.bucket_name }}" instead of the bucket_name value.