-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
KMS: On Demand Key Rotation for Imported Key Material #13363
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
KMS: On Demand Key Rotation for Imported Key Material #13363
Conversation
Test Results (amd64) - Integration, Bootstrap 5 files 5 suites 2h 40m 3s ⏱️ Results for commit 9825b46. ♻️ This comment has been updated with latest results. |
LocalStack Community integration with Pro 2 files ±0 2 suites ±0 2h 3m 16s ⏱️ + 2m 13s Results for commit 9825b46. ± Comparison against base commit b374616. This pull request removes 2 and adds 9 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
da6ba8d to
7d061f5
Compare
S3 Image Test Results (AMD64 / ARM64) 2 files 2 suites 7m 45s ⏱️ Results for commit 9825b46. ♻️ This comment has been updated with latest results. |
3a3f7c6 to
8d34956
Compare
8d34956 to
f3aa74e
Compare
k-a-il
left a comment
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.
It's great to see this functionality being added. Nice work on the PR 🚀 I have just a few questions, otherwise LGTM
| if existing_pending_material := key_to_import_material_to.crypto_key.pending_key_material: | ||
| pending_key_material_id = key_to_import_material_to.generate_key_material_id( | ||
| existing_pending_material | ||
| ) | ||
| raise KMSInvalidStateException( | ||
| f"New key material (id: {key_material_id}) cannot be imported into KMS key " | ||
| f"{key_to_import_material_to.metadata['Arn']}, because another key material " | ||
| f"(id: {pending_key_material_id}) is pending rotation." | ||
| ) | ||
|
|
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.
Nice additional valdiation! 🚀
…the key ID w/ tests
…s in the response
… immediately and return the material id for symmetric keys
… with the correct key material
f3aa74e to
28f0fac
Compare
k-a-il
left a comment
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.
Thank you for addressing the comments quickly, LGTM! 👍
Motivation
KeyRotationOnDemandwith external KMS keys.Changes
KmsKeyclass to expose theCurrentKeyMaterialIdproperty in it's metadata. Based on testing, it will only expose this key if its a symmetric default key. It will also only expose this field on key creation if its AWS managed (since external keys will have no key material)KeyMaterialIdof key material depends on theKeyIdof the key it's associated with, in addition to the key material. Creating a hexadecimal ID with the above requirements can be achieved usinguuid5which takes a UUID as input (for example aKeyIdin addition to byte information (like key material).mrk-which makes it an invalid UUID but based on the current implementation, the part of the key ID followingmrk-is a valid UUID, and so we opted to use that instead.KeyMaterialIdas in theory sinceKeyIdandKeyMaterialIdis public information which could be used to determine the key material since UUID5 is deterministic (Maybe a naive implementation, so open to suggestions!).CurrentKeyMaterialIdeither on creation of the key or when we rotate the key to use new key material we have imported, so logic was added in these places to update these fields._get_all_key_idsneeded to be updated as it only would query the first page, meaning tests which used it would fail once there were more keys than the page limit since it wouldn't show up on the first page.Tests
CurrentKeyMaterialIdand theKeyMaterialIdfields for certain operations, all the existing parity tests which were affected were updated.rotate_on_demanddid not support external KMS keys.Creating an external KMS Key -> Importing key material -> Encrypting / Decrypting -> Importing more key material -> Rotating the key -> Encrypting / Decrypting with the new key materialCreating an external KMS Key -> Attempting to rotate key material whilst the key is in the pending stateCreating an external KMS Key -> Attempting to import key material when there is already material pendingCreating an external KMS Key -> Attempting to rotate the key which has material, but none pending for rotationresolves FLC-134
fixes #12801