AIRFLOW_SUBCOMMAND: 실행하려는 Airflow CLI 명령어의 하위 명령어입니다(예: list).
(선택사항) SUBCOMMAND_PARAMETER: 하위 명령어의 매개변수입니다. 매개변수를 두 개 이상 사용하려면 목록에 항목을 더 추가합니다.
예를 들면 다음과 같습니다.
// POST https://composer.googleapis.com/v1/{environment=projects/*/locations/*/environments/*}:executeAirflowCommand{"environment":"projects/example-project/locations/us-central1/environments/example-environment","command":"dags","subcommand":"list","parameters":["-o json","--verbose"]}
Poll 명령어 상태
Cloud Composer API를 통해 Airflow CLI 명령어를 실행한 후 PollAirflowCommand 요청을 전송하고 오류 및 상태 코드에 대해 exitInfo의 필드를 검사하여 명령어가 성공적으로 완료되었는지 확인합니다. output 필드에는 로그 줄이 포함됩니다.
명령어 실행 상태와 로그를 가져오려면 ExecuteAirflowCommandRequest에서 반환한 executionId, pod, podNamespace 값을 제공합니다.
예:
// POST https://composer.googleapis.com/v1/{environment=projects/*/locations/*/environments/*}:pollAirflowCommand{"executionId":"a117da94-355d-4ad4-839e-ac39ccb0bf48","pod":"airflow-webserver-66d96b858f-tn96b","podNamespace":"airflow-2-10-2-build-13-226523e4","nextLineNumber":1}
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-03(UTC)"],[[["\u003cp\u003eThis document outlines how to use the Apache Airflow command-line interface (CLI) within Google Cloud Composer environments, specifically noting that the current content is for Cloud Composer 2, which only supports Airflow 2 CLI syntax.\u003c/p\u003e\n"],["\u003cp\u003eTo execute Airflow CLI commands, users must employ the \u003ccode\u003egcloud composer environments run\u003c/code\u003e command, specifying the environment name, location, and the desired Airflow CLI subcommand and its arguments, separated by a \u003ccode\u003e--\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eFor Cloud Composer versions 2.4.0 and later, Airflow CLI commands can be run directly on private IP environments without needing access to the cluster's control plane; however, in earlier versions, such access was required.\u003c/p\u003e\n"],["\u003cp\u003eAlternatively, beginning with Cloud Composer version 2.4.0, Airflow CLI commands can be executed via the Cloud Composer API using the \u003ccode\u003eenvironments.executeAirflowCommand\u003c/code\u003e request, allowing for remote command execution and status monitoring through \u003ccode\u003ePollAirflowCommand\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshooting tips are provided for network connectivity issues, highlighting that a lack of connectivity to the cluster control plane may manifest as an "i/o timeout" error when running \u003ccode\u003egcloud composer environments run\u003c/code\u003e or \u003ccode\u003ekubectl\u003c/code\u003e commands, along with the specific steps needed to resolve it.\u003c/p\u003e\n"]]],[],null,["# Access Airflow command-line interface\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n**Cloud Composer 3** \\| [Cloud Composer 2](/composer/docs/composer-2/access-airflow-cli \"View this page for Cloud Composer 2\") \\| [Cloud Composer 1](/composer/docs/composer-1/access-airflow-cli \"View this page for Cloud Composer 1\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nApache Airflow has a command-line interface (CLI) that you can use to perform\ntasks such as triggering and managing DAGs, getting information about DAG runs\nand tasks, adding and deleting connections and users.\n\nSupported Airflow CLI commands\n------------------------------\n\nAirflow uses [Airflow 2 CLI syntax](https://airflow.apache.org/docs/apache-airflow/stable/cli-and-env-variables-ref.html), which is described in the\nAirflow documentation.\n\n\nFor a full list of supported Airflow CLI commands, see the reference for the\n[`gcloud composer environments run`](/sdk/gcloud/reference/composer/environments/run#SUBCOMMAND) command.\n\nBefore you begin\n----------------\n\n- You must have [permissions](/composer/docs/composer-3/access-control#cli) to use\n Google Cloud CLI with Cloud Composer and run Airflow CLI\n commands.\n\n | **Caution:** Users with the `composer.environments.executeairflowcommand` permission can execute Python code available to Airflow components on behalf of the environment's service account. For more information, see [Access control](/composer/docs/composer-3/access-control#service-account-security).\n- Airflow CLI commands consume the `environments.executeAirflowCommand`\n [quota](/composer/quotas).\n\n | **Important:** If you want to trigger a large number of DAGs, we recommend to do it [with Airflow REST API](/composer/docs/composer-3/access-airflow-api#call-api). Triggering DAGs through Google Cloud CLI might cause your environment to reach the quota limit, and as a result, Airflow CLI commands will no longer be executed.\n- It is not possible to run Airflow CLI commands through `kubectl` in\n Cloud Composer 3. This approach was deprecated and is required only for\n Cloud Composer versions earlier than 2.4.0.\n\nRun Airflow CLI commands\n------------------------\n\nTo run Airflow CLI commands in your environments, use gcloud CLI: \n\n gcloud composer environments run \u003cvar translate=\"no\"\u003eENVIRONMENT_NAME\u003c/var\u003e \\\n --location \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e \\\n \u003cvar translate=\"no\"\u003eSUBCOMMAND\u003c/var\u003e \\\n -- \u003cvar translate=\"no\"\u003eSUBCOMMAND_ARGUMENTS\u003c/var\u003e\n\nReplace the following :\n\n- `ENVIRONMENT_NAME`: the name of your environment.\n- `LOCATION`: the region where the environment is located.\n- `SUBCOMMAND`: one of the [supported Airflow CLI commands](/sdk/gcloud/reference/composer/environments/run#SUBCOMMAND).\n- `SUBCOMMAND_ARGUMENTS` with arguments for the Airflow CLI command.\n\n### Sub-command arguments separator\n\nSeparate the arguments for the specified Airflow CLI command with `--`:\n\n\n- Specify compound CLI commands as a sub-command.\n- Specify any arguments for compound commands as sub-command arguments, after a `--` separator.\n\nExample: \n\n gcloud composer environments run example-environment \\\n dags list -- --output=json\n\n\u003cbr /\u003e\n\n\n### Default location\n\nMost `gcloud composer` commands require a location. You can specify the\nlocation with the `--location` flag, or by\n[setting the default location](/composer/docs/gcloud-installation#set-default).\n\nFor example, to trigger a DAG named `sample_quickstart` with the ID `5077` in\nyour Cloud Composer environment:\n\n\n gcloud composer environments run example-environment \\\n --location us-central1 dags trigger -- sample_quickstart \\\n --run-id=5077\n\n\u003cbr /\u003e\n\n\nRun Airflow CLI commands through Cloud Composer API\n---------------------------------------------------\n\nIn Cloud Composer 3, you can run Airflow CLI commands through\nCloud Composer API.\n\n\n### Execute a command\n\nConstruct an [`environments.executeAirflowCommand`](/composer/docs/reference/rest/v1/projects.locations.environments/executeAirflowCommand) API request: \n\n {\n \"environment\": \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/environments/\u003cvar translate=\"no\"\u003eENVIRONMENT_NAME\u003c/var\u003e\",\n \"command\": \"\u003cvar translate=\"no\"\u003eAIRFLOW_COMMAND\u003c/var\u003e\",\n \"subcommand\": \"\u003cvar translate=\"no\"\u003eAIRFLOW_SUBCOMMAND\u003c/var\u003e\",\n \"parameters\": [\n \"\u003cvar translate=\"no\"\u003eSUBCOMMAND_PARAMETER\u003c/var\u003e\"\n ]\n }\n\nReplace the following:\n\n- `PROJECT_ID`: the [Project ID](/resource-manager/docs/creating-managing-projects).\n- `LOCATION`: the region where the environment is located.\n- `ENVIRONMENT_NAME`: the name of your environment.\n- `AIRFLOW_COMMAND`: Airflow CLI command that you want to execute, such as `dags`.\n- `AIRFLOW_SUBCOMMAND`: Sub-command for the Airflow CLI command that you want to execute, such as `list`.\n- (optional) `SUBCOMMAND_PARAMETER`: Parameters for the sub-command. If you want to use more than one parameter, add more items to the list.\n\nExample: \n\n // POST https://composer.googleapis.com/v1/{environment=projects/*/locations/*/environments/*}:executeAirflowCommand\n {\n \"environment\": \"projects/example-project/locations/us-central1/environments/example-environment\",\n \"command\": \"dags\",\n \"subcommand\": \"list\",\n \"parameters\": [\n \"-o json\",\n \"--verbose\"\n ]\n }\n\n### Poll command status\n\nAfter you execute an Airflow CLI command through Cloud Composer API, check if\nthe command was successfully completed by making a\n[PollAirflowCommand](/composer/docs/reference/rest/v1/projects.locations.environments/pollAirflowCommand) request and inspecting the\nfields in `exitInfo` for errors and status codes. The `output` field contains\nlog lines.\n| **Note:** You can also stop executing a command with [StopAirflowCommand](/composer/docs/reference/rest/v1/projects.locations.environments/stopAirflowCommand).\n\nTo get the command execution status and fetch logs, provide `executionId`,\n`pod`, and `podNamespace` values returned by `ExecuteAirflowCommandRequest`:\n\nExample: \n\n // POST https://composer.googleapis.com/v1/{environment=projects/*/locations/*/environments/*}:pollAirflowCommand\n {\n \"executionId\": \"a117da94-355d-4ad4-839e-ac39ccb0bf48\",\n \"pod\": \"airflow-webserver-66d96b858f-tn96b\",\n \"podNamespace\": \"airflow-2-10-2-build-13-226523e4\",\n \"nextLineNumber\": 1\n }\n\n\nWhat's next\n-----------\n\n- [Access Airflow UI](/composer/docs/composer-3/access-airflow-web-interface)\n- [Access control (Airflow CLI)](/composer/docs/composer-3/access-control#cli)"]]