Cloud Composer 3 | Cloud Composer 2 | Cloud Composer 1
Apache Airflow has a command-line interface (CLI) that you can use to perform tasks such as triggering and managing DAGs, getting information about DAG runs and tasks, adding and deleting connections and users.
Supported Airflow CLI commands
Airflow in Cloud Composer 1 provides two different syntaxes for CLI commands:
Airflow 1.10 CLI syntax, available in Cloud Composer environments with Airflow 1.10.
Airflow 2 CLI syntax, available Cloud Composer environments with Airflow 2.
For a full list of supported Airflow CLI commands, see the reference for the
gcloud composer environments run
command.
Before you begin
You must have permissions to use Google Cloud CLI with Cloud Composer and run Airflow CLI commands.
Run Airflow CLI commands
To run Airflow CLI commands in your environments, use gcloud CLI:
gcloud composer environments run ENVIRONMENT_NAME \
--location LOCATION \
SUBCOMMAND \
-- SUBCOMMAND_ARGUMENTS
Replace the following :
ENVIRONMENT_NAME
: the name of your environment.LOCATION
: the region where the environment is located.SUBCOMMAND
: one of the supported Airflow CLI commands.SUBCOMMAND_ARGUMENTS
with arguments for the Airflow CLI command.
Sub-command arguments separator
Separate the arguments for the specified Airflow CLI command with --
:
Airflow 2
- Specify compound CLI commands as a sub-command.
- Specify any arguments for compound commands as sub-command arguments,
after a
--
separator.
Example:
gcloud composer environments run example-environment \
dags list -- --output=json
Airflow 1
- Specify CLI commands as a sub-command.
- Specify any arguments after a
--
separator.
Example:
gcloud composer environments run example-environment \
list_dags -- --report
Default location
Most gcloud composer
commands require a location. You can specify the
location with the --location
flag, or by
setting the default location.
For example, to trigger a DAG named sample_quickstart
with the ID 5077
in
your Cloud Composer environment:
Airflow 2
gcloud composer environments run example-environment \
--location us-central1 dags trigger -- sample_quickstart \
--run-id=5077
Airflow 1
gcloud composer environments run example-environment \
--location us-central1 trigger_dag -- sample_quickstart \
--run_id=5077