Skip to content

GCP: Support CMEK (kms-key-name) for GCS server-side encryption - #18151

Open
munendrasn wants to merge 1 commit into
apache:mainfrom
munendrasn:gcs-cmek-kms-key-support
Open

munendrasn wants to merge 1 commit into
apache:mainfrom
munendrasn:gcs-cmek-kms-key-support

Conversation

@munendrasn

Copy link
Copy Markdown
Contributor

Currently, GCS supports only CSEK. The user can configure gcs.encryption-key, where the raw key is sent to GCS on every request.

This PR adds CMEK support via a new gcs.kms-key-name property, the caller passes only the Cloud KMS key resource name, and GCS performs encryption/decryption server-side.
The reads require no change since CMEK decryption is automatic. CSEK and CMEK are mutually exclusive (GCS rejects both on one object), enforced at property-parse time with a fail-fast Preconditions check.

GCSOutputStream previously supported only CSEK (gcs.encryption-key), where
the raw key is sent to GCS on every request. This adds CMEK support via a
new gcs.kms-key-name property: the caller passes only the Cloud KMS key
resource name, and GCS performs encryption/decryption server-side, so the
caller's credentials need no KMS permission.

The write path emits BlobWriteOption.kmsKeyName(...) when the property is
set; reads require no change since CMEK decryption is automatic. CSEK and
CMEK are mutually exclusive (GCS rejects both on one object), enforced at
property-parse time with a fail-fast Preconditions check.
@github-actions github-actions Bot added the GCP label Sep 17, 2026

@amlel-el-mahrouss amlel-el-mahrouss left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Correct practices were done here.

@singhpk234 singhpk234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change LGTM, just want to have more eyes on config names !

Comment on lines +47 to +51
/**
* Cloud KMS key resource name for CMEK server-side encryption. Mutually exclusive with {@link
* #GCS_ENCRYPTION_KEY} (CSEK).
*/
public static final String GCS_KMS_KEY_NAME = "gcs.kms-key-name";

@singhpk234 singhpk234 Sep 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would really like them to be prefixed with sse ...
like s3 does, s3.sse.<>
this will get more and more tricky as we CSE in... but we already have the key named this way
let me add some folks from google in this thread as well, if they have better suggestion on the name !

@munendrasn munendrasn Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @singhpk234 for the review. On the naming, I used current naming in gcp as reference

encryptionKey is named as gcp.encryption-key and same for decryptionKey.

I can rename to follow aws s3 naming convention, if we are aligned

@singhpk234

Copy link
Copy Markdown
Contributor

cc @talatuyarer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants