Skip to content

Auto run a Cloud Composer DAG when an object is uploaded to a Google Cloud Storage bucket

Notifications You must be signed in to change notification settings

melburne/trigger-composer-dag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Trigger Composer DAG using Cloud Function

Trigger a DAG in Cloud Composer when an object is uploaded to a Google Cloud Storage bucket.

Requirements

  • Java 11 runtime environment for the Cloud Function

Setup

Cloud Function

  • Set the Trigger to Cloud Storage and the Event Type to Finalize/Create

  • Use the Compute Engine Default Service Account or create a new Service Account that has the Composer User role.

  • Configure the following environment variables

    Key Value
    WEBSERVER_ID <tenant-project-id>
    DAG_NAME <dag-to-trigger>
    CLIENT_ID <client-id-of-the-IAM-proxy>

    The tenant project ID can be found in the Airflow Webserver URL in the form <tenant-project-id>.appspot.com

    The Client ID of the IAM proxy can be found in the IAP URL after clicking on the Airflow Webserver link in the Composer console.

Composer

Add the following Airflow Configuration override to avoid a 403 Forbidden error.

Section Key Value
api auth_backend airflow.api.auth.backend.default