Use environment variables in Managed Apache Airflow® clusters

Managed Service for Apache Airflow® allows you to add environment variables to your cluster that you can use to define paths to directories, provide settings, and pass configuration options. For example, you can use variables to change DAG behavior for clusters in different environments while using the same set of DAGs.

View variables

To view the environment variables in an Airflow® cluster, take the following steps:

  1. Go to the Clusters page in the console.

  2. Select the Airflow® cluster where you want to view environment variables.

  3. Switch to the Advanced tab.

  4. You can find the cluster's environment variables in the Variables section.

Add variables

You can add variables to an existing Airflow® cluster or to a new cluster when you're creating it in the console.

To add environment variables to an existing cluster:

  1. Go to the Clusters page in the console.

  2. Select the Airflow® cluster where you want to add environment variables.

  3. Click Edit at the top right.

  4. Scroll down to AdvancedCluster settings.

  5. Add variables in the Environment variables section.

  6. Click Submit.

    Airflow® will restart with the new configuration.

You can add environment variables to a new or existing Managed Apache Airflow® cluster by including them in the resource configuration.

resource "doublecloud_airflow_cluster" "example-airflow" {
  ...
  config {
    airflow_env_variable [
      {
        name  = "enable_experimental_api"
        value = false
      }
    ]
    version_id = "2.10.0"
    ...
  }

Delete variables

To delete environment variables from a cluster:

  1. Go to the Clusters page in the console.

  2. Select the Airflow® cluster where you want to delete environment variables.

  3. Click Edit at the top right.

  4. Scroll down to AdvancedCluster settings.

  5. Delete variables in the Environment variables section.

  6. Click Submit.

    Airflow® will restart with the new configuration.

To delete an environment variable, comment it out or remove from the resource configuration.

Example configuration:

resource "doublecloud_airflow_cluster" "example-airflow" {
  ...
  config {
#   airflow_env_variable [
#    {
#       name  = "enable_experimental_api"
#       value = false
#     }
#   ]
    version_id = "2.10.0"
    ...
  }

See also