Install custom plugins

Cloud Composer 1 | Cloud Composer 2

Apache Airflow's plugin manager allows you to write custom in-house Apache Airflow operators, hooks, sensors, or interfaces. For more information, see custom plugins in the Airflow documentation. This page describes how to install custom plugins in your Cloud Composer environment.

When you create an environment, Cloud Composer creates a Cloud Storage bucket and associates the bucket with your environment. You use the plugins folder in the associated bucket to install custom plugins.

Before you begin

  • Your account must have a role that allows viewing and modifying your environment's bucket contents.
  • This installation method applies only to Airflow plugins. For example, you cannot use this method to install common Python modules or other libraries.
  • Plugins must conform to the Airflow plugins template guidelines.

Installing a plugin

To install a custom plugin into your Cloud Composer environment, copy the plugin code to the plugins folder in the Cloud Storage bucket attached to your Cloud Composer environment.

To install a plugin:

Console

  1. In the Google Cloud Console, go to the Environments page.

    Go to Environments

  2. Find your environment and follow the DAGs link.

  3. Go one folder level up, then navigate to the plugins/ folder.

  4. Upload your plugin files. For more information about uploading objects, see Uploading objects.

gcloud

Use the following gcloud command:

gcloud composer environments storage plugins import \
    --environment ENVIRONMENT_NAME \
    --location LOCATION \
    --source PATH_TO_LOCAL_FILE \
    --destination PATH_IN_SUBFOLDER

Replace:

  • ENVIRONMENT_NAME with the name of the environment.
  • LOCATION with the Compute Engine region where the environment is located.
  • PATH_TO_LOCAL_FILE with the path of the file to upload.
  • (Optional) PATH_IN_SUBFOLDER with the subfolder path. Use the --destination argument to upload a plugin to a subfolder in the plugins folder. Otherwise, omit the --destination argument.

Viewing a list of plugins

Console

  1. In the Google Cloud Console, go to the Environments page.

    Go to Environments

  2. Find your environment and follow the DAGs link.

  3. Go one folder level up, then navigate to the plugins/ folder.

  4. View the plugin files.

gcloud

Use the following gcloud command:

gcloud composer environments storage plugins list \
    --environment ENVIRONMENT_NAME \
    --location LOCATION

Replace:

  • ENVIRONMENT_NAME with the name of the environment.
  • LOCATION with the Compute Engine region where the environment is located.

Deleting a plugin

To delete a plugin from your Cloud Composer environment, delete the plugin code from the plugins folder in the environment's bucket.

To delete a plugin:

Console

  1. In the Google Cloud Console, go to the Environments page.

    Go to Environments

  2. Find your environment and follow the DAGs link.

  3. Go one folder level up, then navigate to the plugins/ folder.

  4. Delete the plugin files. For more information about deleting objects, see Deleting objects.

gcloud

Use the following gcloud command:

gcloud composer environments storage plugins delete \
    --environment ENVIRONMENT_NAME \
    --location LOCATION \
    PLUGIN_TO_DELETE

Downloading plugins

To download plugins, choose an option:

Console

  1. In the Google Cloud Console, go to the Environments page.

    Go to Environments

  2. Find your environment and follow the DAGs link.

  3. Go one folder level up, then navigate to the plugins/ folder.

  4. Download the plugin files. For more information about deleting objects, see Downloading objects.

gcloud

Use the following gcloud command:

gcloud composer environments storage plugins export \
  --environment ENVIRONMENT_NAME \
  --location LOCATION \
  --destination PATH_TO_LOCAL_DESTINATION \
  --source PATH_IN_FOLDER

Replace:

  • ENVIRONMENT_NAME with the name of the environment.
  • LOCATION with the Compute Engine region where the environment is located.
  • PATH_TO_LOCAL_DESTINATION with the destination for downloaded file.
  • (Optional) --source is an option to download only one plugin. PATH_IN_FOLDER is the folder path.

What's next