I am new to airflow and working on a use case where I need to read the input json configs that are passed to an airflow dag and construct a string based on the configs read, this string will be used as the name of cluster we are creating in GCP data proc.
Ex : Input Json to dag
{ "x" : "data", "y": "engg", "z" : "usecase" }
I am expecting the cluster name to be "my-cluster-for-data-engg-usecase" with the code below but I am getting an error like it cannot recognize "dag_run". Any help would be appreciated.
from datetime import datetime
from airflow import DAG
from airflow.utils.dates import days_ago
from airflow.operators.python_operator import PythonOperator
from airflow import models
from airflow.utils.dates import days_ago
CONN_ID = 'blah'
PROJECT_ID = 'xyz'
REGION = 'us-east4'
CLUSTER_NAME = "my-cluster-for-"+dag_run.conf['x']+dag_run.conf['y']+dag_run.conf['z']
with models.DAG('simple-python-dag', start_date=days_ago(1), schedule_interval=None) as dag:
create_cluster_spark = XyzCreateClusterOperator(task_id='create_cluster_spark',
cluster_name=CLUSTER_NAME,
location=REGION,
gcp_conn_id=CONN_ID)
create_cluster_spark