Configure encryption with customer-managed encryption keys Stay organized with collections Save and categorize content based on your preferences.
Cloud Composer 3 | Cloud Composer 2 | Cloud Composer 1
This page describes how to useCustomer Managed Encryption Keys (CMEK) to protectCloud Composer environments.
About Customer Managed Encryption Keys (CMEK)
By default, Cloud Composer encrypts customer content at rest. Cloud Composer handles encryption for you without any additional actions on your part. This option is calledGoogle default encryption.
If you want to control your encryption keys, then you can use customer-managed encryption keys (CMEKs) inCloud KMS with CMEK-integrated services including Cloud Composer. Using Cloud KMS keys gives you control over their protection level, location, rotation schedule, usage and access permissions, and cryptographic boundaries. Using Cloud KMS also letsyou view audit logs and control key lifecycles. Instead of Google owning and managing the symmetrickey encryption keys (KEKs) that protect your data, you control and manage these keys in Cloud KMS.
After you set up your resources with CMEKs, the experience of accessing your Cloud Composer resources is similar to using Google default encryption. For more information about your encryption options, seeCustomer-managed encryption keys (CMEK).
Data protected with CMEK encryption
Cloud Composer protects the following data with CMEK encryption:
- Contents and schema of the Airflow database
- Environment and Airflow task logs in Cloud Logging
- Contents of the environment's bucket
- Secrets stored in the environment's cluster
- Persistent disks used by the task queue
- Container images of environment components stored in Artifact Registryrepositories
For specific details about how the data is encrypted, see:
- About customer-managed encryption keys (CMEK) in theCloud SQL documentation.
- Use customer-managed encryption keys (CMEK) andEncrypt secrets at the application layer in theGoogle Kubernetes Engine documentation.
- Customer-managed encryption keys in theCloud Storage documentation.
- Configure CMEK for Cloud Logging in theCloud Logging documentation.
Data not protected with CMEK encryption
Cloud Monitoring does not support CMEK encryption. The name of yourenvironment and names of DAGs are stored in the Monitoringdatabase in the encrypted form using Google-owned and Google-managed encryption keys.
Cloud Composer stores the following information protected withGoogle-owned and Google-managed encryption keys, not customer-managed keys:
- Environment name
- Airflow configuration overrides
Environment variables
Labels
The names of some parameters stored by Cloud Composer can includea sub-string of environment's name.
Rotation of CMEK keys for Cloud Composer
After you configure encryption in your environment using CMEK keys, youmight also want to consider rotating these keys on a regular basis as describedinKMS documentation.
When you rotate a CMEK key, data encrypted with previous key versions isnot automatically re-encrypted with the new key version.For more information, seeRe-encrypting data.
Specifically, this applies to:
- Objects stored in the environment's bucket.
- Data stored in the Airflow database.
- Allother data objects encrypted with CMEK in theCloud Composer environment.
- Container images of environment components stored inArtifact Registry repositories.
Use a customer-managed encryption key for your environment
Warning: If you create an environment with a customer-managed encryption keyand later disable or delete the key, the environment becomesunusable. Itisnot possible to recover an environment if its encryption key is deletedor disabled.Before you begin
You can configure CMEK only when you create an environment. It is notpossible to enable CMEK for an existing environment.
Cloud Composer supports CMEK encryption usingkeys stored in External Key Managers.
You must create a CMEK key in the same region where your environmentsare located. You cannot use multi-regional or global keys.
If you want your environment to run inside aVPC Service Controls perimeter, you must add theCloud Key Management Service API to the perimeter.
Step 1. Create a customer-managed encryption key
Follow the steps outlined inCreating symmetric encryption keys to create a key in theregion where your environment is located.
Step 2. Grant roles to service agents
Important: If your project has aDomain restricted sharingpolicy that excludes addresses from the google.com domain. You must turn off(or expand) this policy to grant the required roles to service agents.After you grant the roles, you can revert the policy changes. This policy doesnot affect the creation of environments.Console
Skip this step. You grant permissions toservice agents when youspecify a key for your environment.
gcloud
The followingservice agents must havetheCloud KMS CryptoKey Encrypter/Decrypter role on the key that youuse for your environment.
ReplacePROJECT_NUMBER with yourproject's number.
| Service agent name | Service account email | API service name |
|---|---|---|
| Cloud Composer Service Agent | service-PROJECT_NUMBER@cloudcomposer-accounts.iam.gserviceaccount.com | composer.googleapis.com | Cloud Storage Service Agent | service-PROJECT_NUMBER@gs-project-accounts.iam.gserviceaccount.com | Grant encrypt/decrypt permissions withgcloud storage service-agent --authorize-cmek |
(If required) If some of these service accounts are not present in yourproject, it means that an identity for this service is not yet created.This can happen, for example, if you did not yet create anyCloud Composer environments in your project.
To add these service accounts, create identities for the listed serviceswith the following command:
gcloudbetaservicesidentitycreate\--service=API_SERVICE_NAMEReplace
API_SERVICE_NAMEwith theAPI service name of a servicethat does not have a service account in your project.Example:
gcloudbetaservicesidentitycreate\--service=composer.googleapis.comGrant permissions to service agents:
Grant the role to Cloud Composer Service Agent:
gcloudkmskeysadd-iam-policy-bindingKEY_NAME\--locationKEY_LOCATION\--keyringKEY_RING_NAME\--member=serviceAccount:service-PROJECT_NUMBER@cloudcomposer-accounts.iam.gserviceaccount.com\--role=roles/cloudkms.cryptoKeyEncrypterDecrypter\--projectKEY_PROJECT_IDGrant encrypt/decrypt permissions toCloud Storage Service Agent.You can skip this step if you useacustom environment's bucket.
gcloudstorageservice-agent\--authorize-cmek=projects/KEY_PROJECT_ID/locations/KEY_LOCATION/keyRings/KEY_RING_NAME/cryptoKeys/KEY_NAME
Replace:
PROJECT_IDwith yourproject's ID.KEY_PROJECT_IDwith the ID of the project that stores yourcustomer-managed key. If you use a key from another project, thisvalue is different from your project's ID. If you use a key from thesame project, this value is your project's ID.PROJECT_NUMBERwith yourproject's number.KEY_LOCATIONwith your customer-managed key location. This locationmust be the same as your environment's location.KEY_NAMEwith your customer-managed key name.KEY_RING_NAMEwith the keyring that stores your customer-managed key.
To get these values, you can run
gcloud projects describe,gcloud kms keyrings list, andgcloud kms keys describecommands.
Step 3. Create an environment with CMEK
After youcreate a customer-managed encryption key, you can useit to create Cloud Composer environments.
Console
When youcreate an environment:
Expand theAdvanced configuration section. In theData encryption section, selectCloud Key Management Service key.
In theSelect a Cloud Key Management Service key drop-down list, select your key.
If additional setup is required, a message appears to inform you. Inthis case:
ClickOpen wizard.
In thePrepare CMEK key for usage in Cloud Composerdialog, view the list ofservice agentsthat must have theCloud KMS CryptoKey Encrypter/Decrypter roleon the key.
To grant the required roles and permissions, clickGrant.
gcloud
The--kms-key argument specifies a customer-managed enryption key for yourenvironment.
For more information about creating environments, seeCreate environments. For example, you might want to specifyother parameters for your environment.
gcloudcomposerenvironmentscreateENVIRONMENT_NAME\--locationLOCATION\--image-versionIMAGE_VERSION\--kms-keyprojects/KEY_PROJECT_ID/locations/KEY_LOCATION/keyRings/KEY_RING_NAME/cryptoKeys/KEY_NAMEReplace:
ENVIRONMENT_NAMEwith the name of the environment.IMAGE_VERSIONwith the name of the Cloud Composer image.KEY_PROJECT_IDwith the ID of the project where the key is located.If you use a key from another project, this value is different from yourproject's ID. If you use a key from the same project, this value is yourproject's ID.LOCATIONwith the region where the environment is located.KEY_LOCATIONwith the location of your customer-managed key. Thislocation must be the same as your environment's location.KEY_NAMEwith your customer-managed key name.KEY_RING_NAMEwith the keyring that stores your customer-managed key.
Example:
gcloudcomposerenvironmentscreateexample-environment\--locationus-central1\--image-versioncomposer-3-airflow-2.10.5-build.23\--kms-keyprojects/example-project/locations/us-central1/keyRings/example-key-ring/cryptoKeys/example-keyView the environment's encryption configuration
You can view encryption configuration for an existing environment:
Console
In Google Cloud console, go to theEnvironments page.
In the list of environments, click the name of your environment.TheEnvironment details page opens.
Go to theEnvironment configuration tab.
Details about encryption are listed in theData encryption key item.
gcloud
Run the followinggcloud command to view the encryption configuration
gcloudcomposerenvironmentsdescribe\ENVIRONMENT_NAME\--locationLOCATION\--format="value(config.encryptionConfig)"Replace:
ENVIRONMENT_NAMEwith the name of the environment.LOCATIONwith the region where the environment is located.
Example:
gcloudcomposerenvironmentsdescribe\example-environment\--locationus-central1\--format="value(config.encryptionConfig)"Use CMEK for Cloud Composer logs
Cloud Logging supports encrypting Log storage with CMEK keys. We recommendto use the standard CMEK procedure for encrypting logs with CMEK keys.
To encrypt logs with CMEK keys, follow the instructions outlined inManage the keys that protect Logging storage data.
Deprecated: The following instructions about redirectingCloud Composer logs to a CMEK-encrypted Cloud Storagebucket are deprecated. If you use this approach in your project, considerswitching to encrypting Log storage with CMEK keys instead.Redirect Cloud Composer logs to a CMEK-encrypted Cloud Storage bucket
If you expect your logs to contain sensitive data, you might want toredirect Cloud Composer logs to a CMEK-encryptedCloud Storage bucket by usingLog Router. Doing so prevents yourlogs from being sent to Monitoring.
If you require support from Cloud Customer Care, you might need to grant Googlesupport engineers access to the Cloud Composer logs stored inCloud Storage.
Note:Audit logs cannot be excluded. They are alwayssent to the default storage.gcloud
Create a new Cloud Storage bucket to store the logs.
gcloudstoragebucketscreategs://BUCKET_NAME--location=LOCATIONReplace:
LOCATIONwith the region where the environment is located.BUCKET_NAMEwith the name for the bucket.
Example:
gcloudstoragebucketscreategs://composer-logs-us-central1-example-environment--location=us-central1Encrypt the bucket with your CMEK key.
gcloudstoragebucketsupdategs://BUCKET_NAME\--default-encryption-key=projects/KEY_PROJECT_ID/locations/KEY_LOCATION/keyRings/KEY_RING_NAME/cryptoKeys/KEY_NAMEReplace:
KEY_PROJECT_IDwith the ID of the project where the key is located.If you use a key from another project, this value is different fromyour project's ID. If you use a key from the same project, this valueis your project's ID.KEY_LOCATIONwith the location of your customer-managed key. Thislocation must be the same as your environment's location.KEY_RING_NAMEwith the keyring that stores your customer-managed key.KEY_NAMEwith your customer-managed key name.BUCKET_NAMEwith the name of the bucket.
Example:
gcloudstoragebucketsupdategs://composer-logs-us-central1-example-environment\--default-encryption-key=projects/example-project/locations/us-central1/keyRings/example-key-ring/cryptoKeys/example-keyCreate a new log sink.
gcloudloggingsinkscreate\composer-log-sink-ENVIRONMENT_NAME\storage.googleapis.com/BUCKET_NAME\--log-filter"resource.type=cloud_composer_environment AND resource.labels.environment_name=ENVIRONMENT_NAME AND resource.labels.location=LOCATION"Replace:
ENVIRONMENT_NAMEwith the name of the environment.LOCATIONwith the region where the environment is located.BUCKET_NAMEwith the name of the bucket.
Example:
gcloudloggingsinkscreate\composer-log-sink-example-environment\storage.googleapis.com/composer-logs-us-central1-example-environment\--log-filter"resource.type=cloud_composer_environment AND resource.labels.environment_name=example-environment AND resource.labels.location=us-central1"Grant theStorage Object Creator role to the service account for thisbucket. The service account is shown in the result of the previouscommand).
gcloudprojectsadd-iam-policy-binding\PROJECT_ID\--member="serviceAccount:LOGGING_SERVICE_AGENT"\--role="roles/storage.objectCreator"\--condition=NoneReplace:
PROJECT_IDwith theProject ID.LOGGING_SERVICE_AGENTwith the Logging serviceagent account for this bucket. The name of this account is obtainedon the previous step.
Example:
gcloudprojectsadd-iam-policy-binding\example-project\--member="serviceAccount:example-sa@gcp-sa-logging.iam.gserviceaccount.com"\--role="roles/storage.objectCreator"\--condition=NoneExclude the logs for your new environment fromMonitoring.
gcloudbetaloggingsinksupdate_Default\--add-exclusionname=ENVIRONMENT_NAME-exclusion,filter="resource.type=cloud_composer_environment AND resource.labels.environment_name=ENVIRONMENT_NAME AND resource.labels.location=LOCATION"Replace:
ENVIRONMENT_NAMEwith the name of the environment.LOCATIONwith the region where the environment is located.
Example:
gcloudbetaloggingsinksupdate_Default\--add-exclusionname=example-environment-exclusion,filter="resource.type=cloud_composer_environment AND resource.labels.environment_name=example-environment AND resource.labels.location=us-central1"Add organization-level CMEK encryption to the Log Router.
gcloudloggingcmek-settingsdescribe\--organization=ORGANIZATION_IDgcloudkmskeysadd-iam-policy-binding\--project=KEY_PROJECT_ID\--memberLOGGING_SERVICE_AGENT\--roleroles/cloudkms.cryptoKeyEncrypterDecrypter\--location=KEY_LOCATION\--keyring=KEY_RING_NAME\KEY_NAMEgcloudloggingcmek-settingsupdate\--organization=ORGANIZATION_ID\--kms-project=KEY_PROJECT_ID\--kms-keyring=KEY_RING_NAME\--kms-location=KEY_LOCATION\--kms-key-name=KEY_NAMEReplace:
ORGANIZATION_IDwith yourorganization ID.KEY_PROJECT_IDwith the ID of the project where the key is located.If you use a key from another project, this value is different fromyour project's ID. If you use a key from the same project, this valueis your project's ID.KEY_RING_NAMEwith the keyring that stores your customer-managed key.KEY_LOCATIONwith the location of your customer-managed key. Thislocation must be the same as your environment's location.KEY_NAMEwith your customer-managed key name.
What's next
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.