-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add CMEK support in Firebase CLI for Firestore databases #7479
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
16db861
Add CMEK support for Firestore database
jinyangtang e9a2781
adjust column width for get database output
jinyangtang 8d8df17
fix lint
jinyangtang fc01953
remove invalid char
jinyangtang f9a71f0
fix lint
jinyangtang a7b3a45
fix an option error
jinyangtang 39533ac
resolve comments
jinyangtang 063fd09
fix lint
jinyangtang 1d754af
fix lint
jinyangtang b90145f
fix style
jinyangtang b707b89
Merge branch 'master' into jt-firestore-cmek-support
jinyangtang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Added support for Customer-managed encryption keys (CMEK) on Firestore databases. (#7479) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,11 @@ export const command = new Command("firestore:databases:create <database>") | |
| "--point-in-time-recovery <enablement>", | ||
| "Whether to enable the PITR feature on this database, for example 'ENABLED' or 'DISABLED'. Default is 'DISABLED'", | ||
| ) | ||
| // TODO(b/356137854): Remove allowlist only message once feature is public GA. | ||
| .option( | ||
| "--kms-key-name <kmsKeyName>", | ||
| "The resource ID of a Cloud KMS key. If set, the database created will be a Customer-managed Encryption Key (CMEK) database encrypted with this key. This feature is allowlist only in initial launch.", | ||
| ) | ||
| .before(requirePermissions, ["datastore.databases.create"]) | ||
| .before(warnEmulatorNotSupported, Emulators.FIRESTORE) | ||
| .action(async (database: string, options: FirestoreOptions) => { | ||
|
|
@@ -63,14 +68,24 @@ export const command = new Command("firestore:databases:create <database>") | |
| ? types.PointInTimeRecoveryEnablement.ENABLED | ||
| : types.PointInTimeRecoveryEnablement.DISABLED; | ||
|
|
||
| const databaseResp: types.DatabaseResp = await api.createDatabase( | ||
| options.project, | ||
| database, | ||
| options.location, | ||
| let cmekConfig: types.CmekConfig | undefined; | ||
| if (options.kmsKeyName) { | ||
| cmekConfig = { | ||
| kmsKeyName: options.kmsKeyName, | ||
| }; | ||
| } | ||
|
|
||
| const createDatabaseReq: types.CreateDatabaseReq = { | ||
| project: options.project, | ||
| databaseId: database, | ||
| locationId: options.location, | ||
| type, | ||
| deleteProtectionState, | ||
| pointInTimeRecoveryEnablement, | ||
| ); | ||
| cmekConfig, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: Create database has 7 args - consider switching this to a parameter object (ie https://go/tott/550)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have switched to a param object, thanks |
||
| }; | ||
|
|
||
| const databaseResp: types.DatabaseResp = await api.createDatabase(createDatabaseReq); | ||
|
|
||
| if (options.json) { | ||
| logger.info(JSON.stringify(databaseResp, undefined, 2)); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you add a TODO with a buganizer link to clean this message up once its open to all?
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.
Sure, have added.