Skip to content

Add dry_run support to GenerateDataKeyPair/GenerateDataKeyPairWithoutPlaintext. #12505

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

Conversation

macpak
Copy link
Contributor

@macpak macpak commented Apr 9, 2025

Motivation

I am adding support for the dry_run parameter to the GenerateDataKeyPair and GenerateDataKeyPairWithoutPlaintext operations to align with AWS behavior and enhance validation capabilities.

Reference: AWS KMS Dry Run Documentation

Changes

Before these changes, the GenerateDataKeyPair and GenerateDataKeyPairWithoutPlaintext operations in KMS did not take the dry_run parameter into account. This PR updates both operations to properly respect the dry_run flag, aligning their behavior with AWS expectations.

Since IAM permission checks are not yet implemented in KMS, the primary purpose of this functionality is to determine whether a request would succeed (in which case a DryRunOperationException is raised when dry_run=True) or fail due to validation errors, rather than to enforce or simulate IAM permissions

Testing

You can verify the behavior by executing the following CLI commands:

awslocal kms generate-data-key-pair \
  --key-id <key_id> \
  --key-pair-spec RSA_2048 \
  --dry-run

awslocal kms generate-data-key-pair-without-plaintext \
  --key-id <key_id> \
  --key-pair-spec RSA_2048 \
  --dry-run

When the request is valid, these commands should return a DryRunOperationException. If the input is invalid, a validation error will be returned instead.

Copy link
Collaborator

@localstack-bot localstack-bot left a comment

Choose a reason for hiding this comment

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

Welcome to LocalStack! Thanks for raising your first Pull Request and landing in your contributions. Our team will reach out with any reviews or feedbacks that we have shortly. We recommend joining our Slack Community and share your PR on the #community channel to share your contributions with us. Please make sure you are following our contributing guidelines and our Code of Conduct.

@localstack-bot
Copy link
Collaborator

localstack-bot commented Apr 9, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@macpak macpak force-pushed the feature/kms-dry-run-generate-key-pair branch 2 times, most recently from 3d91e00 to 2fee7cd Compare April 9, 2025 06:32
@macpak
Copy link
Contributor Author

macpak commented Apr 9, 2025

I have read the CLA Document and I hereby sign the CLA

localstack-bot added a commit that referenced this pull request Apr 9, 2025
@alexrashed alexrashed self-assigned this Apr 9, 2025
@alexrashed alexrashed added the semver: patch Non-breaking changes which can be included in patch releases label Apr 9, 2025
@alexrashed alexrashed self-requested a review April 9, 2025 07:30
@macpak macpak marked this pull request as ready for review April 9, 2025 07:46
@macpak macpak requested a review from sannya-singal as a code owner April 9, 2025 07:46
@macpak macpak changed the title Feature/kms dry run generate key pair Add dry_run support to GenerateDataKeyPair/GenerateDataKeyPairWithoutPlaintext. Apr 9, 2025
Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the great contribution! In principal the code is looking great! I just found an issue (only parts of the validations are considered for the dry run), and I posted some more nitpicks and questions.
Once they have been addressed we are good to go! 🚀 💯

Copy link
Contributor Author

@macpak macpak left a comment

Choose a reason for hiding this comment

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

Addressed the review comments and applied the suggested fixes.

Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

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

Thanks a lot for addressing the comments! This is already looking great! 🤩
I only have a few more small comments / questions. We need to make sure that the test is validated, and I would like to quickly discuss the UnsupportedOperationException, the rest is just nitpicks / not blocking.
It seems that there is a small conflict though, so maybe you could quickly rebase this PR on the latest changes on master?

@macpak macpak force-pushed the feature/kms-dry-run-generate-key-pair branch from 2e96c89 to 32c20c0 Compare April 13, 2025 11:38
Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

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

Thanks a lot for addressing the comments once more! The validation is looking good, and the reasoning on the KmsCryptoKey is sound. I really only want to check that we don't introduce an issue with the switch from the UnsupportedOperationException to the ValidationException in some cases. ;)

Copy link
Contributor Author

@macpak macpak left a comment

Choose a reason for hiding this comment

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

The remaining comment has been addressed.

Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

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

Thanks a lot for addressing the comments, really following up on each and every one! I'll go ahead and directly merge this one! 🤩
Thanks for the contribution! 💯

@alexrashed alexrashed merged commit 77f30dc into localstack:master Apr 23, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants