diff --git a/gslib/commands/rewrite.py b/gslib/commands/rewrite.py index 9888c9f10e..3f0b279184 100644 --- a/gslib/commands/rewrite.py +++ b/gslib/commands/rewrite.py @@ -446,6 +446,12 @@ def RewriteFunc(self, name_expansion_result, thread_state=None): should_encrypt_dest = self.boto_file_encryption_keywrapper is not None + # Remove version number from CMEK name if present for matching with dest key + if (src_encryption_kms_key is not None and + '/cryptoKeyVersions/' in src_encryption_kms_key): + versionIdx = src_encryption_kms_key.find('/cryptoKeyVersions/') + src_encryption_kms_key = src_encryption_kms_key[:versionIdx] + encryption_unchanged = (src_encryption_sha256 == dest_encryption_sha256 and src_encryption_kms_key == dest_encryption_kms_key)