CI / CD パイプラインを使用して DAG を環境にデプロイし、DAG コードがリポジトリから取得されるようにします。このようにして、変更がバージョン管理システムにマージされる前に DAG が審査され、承認されます。レビュー プロセス中に、承認者は DAG がチーム内で確立されたセキュリティ基準を満たしていることを確認します。確認のステップは、環境のバケットの内容を変更する DAG のデプロイを防ぐために重要です。
個人情報やパスワードなどのセンシティブ データを渡す場合は注意が必要です。必要に応じて、Secret Manager を使用して、Airflow 接続と Airflow シークレット、API キー、パスワード、証明書を安全に保存します。この情報は DAG または環境変数に保存しないでください。
環境のバケットに対する IAM 権限は、信頼できるユーザーにのみ付与します。可能であれば、オブジェクトごとの権限を使用します。環境のサービス アカウントのセキュリティに関する考慮事項では、環境のバケットにアクセスできるユーザーが環境のサービス アカウントに代わってアクションを実行できる方法をいくつか示します。
[[["わかりやすい","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-02-18 UTC。"],[[["\u003cp\u003eSecuring a Cloud Composer environment involves implementing best practices for network security, Identity and Access Management (IAM), encryption, and environment configuration management to protect sensitive data.\u003c/p\u003e\n"],["\u003cp\u003eUtilize a CI/CD pipeline for managing both environment configurations and DAGs, ensuring that changes are reviewed and approved before deployment, which significantly enhances security.\u003c/p\u003e\n"],["\u003cp\u003eEmploy Private IP environments and strict firewall rules to limit external access and control traffic to and from the environment's cluster, utilizing internal networks and private domains for enhanced security.\u003c/p\u003e\n"],["\u003cp\u003eIsolate permissions by using dedicated service accounts for each environment, granting only the necessary permissions to these accounts and avoiding broad permissions to minimize potential security risks.\u003c/p\u003e\n"],["\u003cp\u003eExercise caution with sensitive data, storing such data securely with Secret Manager rather than in DAGs or environment variables, as well as managing access permissions to environment buckets and snapshots carefully.\u003c/p\u003e\n"]]],[],null,["# Security best practices\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n[Cloud Composer 3](/composer/docs/composer-3/security-practices \"View this page for Cloud Composer 3\") \\| **Cloud Composer 2** \\| [Cloud Composer 1](/composer/docs/composer-1/security-practices \"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\nSecuring your Cloud Composer environment is crucial for protecting\nsensitive data and preventing unauthorized access. This page outlines key best\npractices, including recommendations for network security, Identity and Access Management,\nencryption, and environment configuration management.\n\nTo get more information about security features available in\nCloud Composer, see [Security overview](/composer/docs/composer-2/composer-security-overview).\n\nManage environment configuration and DAGs using version control\n---------------------------------------------------------------\n\n[](/static/composer/docs/images/composer-airflow-secure-cicd.svg) **Figure 1.** An example of an Airflow CI/CD pipeline (click to enlarge)\n\n- [Create your environment using Terraform](/composer/docs/composer-2/terraform-create-environments).\n In this way, you can store environment's configuration as code in a\n repository. In this way, changes to your environment configuration can be\n reviewed before they are applied, and you can reduce the number of users\n who have permissions to change the configuration by assigning roles with\n less permissions.\n\n- In Identity and Access Management, disable direct access to DAGs and environment's\n configuration to regular users, as detailed in the\n [Identity and Access Management](#iam-security) section.\n\n- [Deploy DAGs in your environment with a CI/CD pipeline](/composer/docs/composer-2/dag-cicd-github),\n so that DAG code is retrieved from a repository. In this way, DAGs are\n reviewed and approved before the changes are merged to the version control\n system. During the review process, approvers make sure that DAGs meet the\n security criteria established within their teams. The review step is\n critical to prevent deployment of DAGs that might perform unwanted actions.\n\n Some important security aspects to take into account when reviewing DAGs\n are:\n - DAGs that modify the content of the environment's bucket must not modify\n the code of other DAGs or access sensitive data, unless intended.\n\n - DAGs must not make direct queries to the Airflow database, unless\n intended. A DAG in a Cloud Composer environment has\n access to all tables in the Airflow database. It is possible to retrieve\n information from any table, process it, and then store it outside of the\n Airflow database.\n\nNetwork security\n----------------\n\n\u003cbr /\u003e\n\n- Use [Private IP environments](/composer/docs/composer-2/configure-private-ip) so that Airflow components in\n that run your environment's cluster are not assigned public IP addresses\n and communicate only over Google's internal network.\n\n- [Implement strict firewall rules](/composer/docs/composer-2/configure-private-ip#private-ip-firewall-rules) to control\n traffic to and from your environment's cluster.\n\n- [Configure connectivity to Google APIs and services](/composer/docs/composer-2/configure-private-ip#connectivity-domains)\n through the `private.googleapis.com` domain so that your environment\n accesses Google APIs and services through IP addresses only routable from\n within Google Cloud.\n\n- Review the general firewall rules in your project and in the VPC network\n where your environment is located. Depending on the way you configure them,\n Airflow components of your environment, such as Airflow workers that run\n your DAGs, might access the internet.\n\nIdentity and Access Management\n------------------------------\n\n- Isolate permissions.\n [Create environment service accounts](/composer/docs/composer-2/access-control#service-account)\n and use different service accounts for different environments. Assign to\n these service accounts only permissions that are strictly necessary to\n operate these environments and perform operations defined in Airflow DAGs\n that they run.\n\n- Avoid using service accounts with broad permissions. While it\n is possible to create an environment that uses an account with broad\n permissions, such as those granted by the **Editor** basic role, this\n creates a risk of DAGs using broader permissions than intended.\n\n- Don't rely on default service accounts of Google services used by\n Cloud Composer. It is often impossible to reduce permissions\n available to these service accounts without also affecting other Google\n services in your project.\n\n- Make sure that you are familiar with\n [security considerations for environment's service accounts](/composer/docs/composer-2/access-control#service-account-security)\n and understand how this account interacts with permissions and roles that\n you grant to individual users in your project.\n\n- Adhere to the principle of least privilege. Grant only the minimum necessary\n permissions to users. For example,\n [assign IAM roles](/composer/docs/composer-2/access-control#user-account), so that only\n administrators can access the environment's bucket\n\n and the environment's cluster\n ,\n and direct access is disabled for regular users. For example, the\n **Composer User** role enables access only to DAG UI and Airflow UI.\n\n- Enforce [Airflow UI Access Control](/composer/docs/composer-2/airflow-rbac), which allows to reduce\n visibility in Airflow UI and DAG UI based on user's Airflow role, and can be\n used to assign DAG-level permissions for individual DAGs.\n\n- Review regularly. Regularly audit IAM permissions and roles\n to identify and remove any excessive or unused privileges.\n\n- Beware of passing and storing sensitive data:\n\n - Exercise caution when passing storing sensitive data like personally\n identifiable information or passwords. Where required,\n [use Secret Manager](/composer/docs/composer-2/configure-secret-manager) to\n securely store Airflow connections and Airflow secrets, API keys,\n passwords, and certificates. Don't store this information in your DAGs\n or environment variables.\n\n - Grant IAM permissions to the environment's bucket only\n to trusted users. Use per-object permissions, if possible.\n [Security considerations for environment's service accounts](/composer/docs/composer-2/access-control#service-account-security)\n list several ways in which users with access to the environment's\n bucket can perform actions on behalf of the environment's service\n account.\n\n - Make sure that you are familiar with\n [what data is stored in the snapshots](/composer/docs/composer-2/save-load-snapshots) and provide\n permissions to create environment snapshots and access the bucket where\n they are stored only to trusted users.\n\n - All Cloud Composer's external interfaces use encryption by\n default. When connecting to external products and services, make sure\n that you use encrypted communication (SSL/TLS).\n\nWhat's next\n-----------\n\n- [Security overview](/composer/docs/composer-2/composer-security-overview)\n- [Access control with IAM](/composer/docs/composer-2/access-control)\n- [Airflow UI Access Control](/composer/docs/composer-2/airflow-rbac)\n- [Airflow summit presentation about DAG security](https://www.youtube.com/watch?v=QhnItssm4yU)"]]