-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: customer-managed encryption keys #1274
Conversation
Here is the summary of changes. You are about to add 3 region tags.
This comment is generated by snippet-bot.
|
Codecov Report
@@ Coverage Diff @@
## master #1274 +/- ##
=======================================
Coverage 98.59% 98.60%
=======================================
Files 23 23
Lines 21841 21899 +58
Branches 1094 1099 +5
=======================================
+ Hits 21535 21593 +58
Misses 297 297
Partials 9 9
Continue to review full report at Codecov.
|
PTAL @olavloite |
|
||
const request = { | ||
encryptionConfig: { | ||
kmsKeyName: keyName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this also include encryptionType: 'CUSTOMER_MANAGED_ENCRYPTION',
? Or is it only required for backups?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is confusing. But CreateDatabaseRequest
has an EncryptionConfig
field which only lets you specify the kms_key_name
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be because by default, it uses GOOGLE_DEFAULT_ENCRYPTION
. But if the customer specifies an encryption key, then it has to be CUSTOMER_MANAGED_ENCRYPTION
.
@@ -893,6 +1013,29 @@ describe('Spanner', () => { | |||
); | |||
}); | |||
|
|||
// restore_backup_with_encryption_key | |||
it('should restore database from a backup using an encryption key', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the Java client we have merged all backup/restore system tests into one as backups and restores are very slow. Is that something that we should consider for Node as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we could do that but I guess the samples were designed such that we take a separate backup and do a separate restore for CMEK. That means I have to test them separately here :( But if it becomes too flaky over time, then I may have to end up skipping these.
* const [, restoreOperation] = await database.restore( | ||
* backupName, | ||
* { | ||
* encryptionConfig: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on how often we think that users will use encrypted backups, I would consider leaving the encryption information out of this example. As it is now, it at first hand seems to be something that is required for all restore operations, while it is only required if you actually have an encrypted backup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it's reasonable to remove this as it's not something you have to specify by default. Sometimes we have multiple examples so I may consider adding a separate one.
BTW, for restoring with an encryption key, it's not a requirement to specify the encryption key if the backup was encrypted. If the backup was encrypted, then the restored database is automatically encrypted with the same key as the backup. You only have to specify the key here if you want to encrypt it with a different key.
Supports creating databases and backups, and restoring databases with a customer-managed encryption key.