Skip to content
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

chore(kinesisfirehose-alpha): refactor encryption property to combine encryptionKey #31430

Merged
merged 5 commits into from
Sep 13, 2024

Conversation

paulhcsun
Copy link
Contributor

@paulhcsun paulhcsun commented Sep 12, 2024

Reason for this change

The previous encryption and encryptionKey properties required error handling to enforce when an encryptionKey could be specified and when it was invalid (only valid when using CUSTOMER_MANAGED_KEY).

The properties should be combined to make this user experience more straightforward and only allow a KMS key to be passed in when using a customer-managed key.

Description of changes

BREAKING CHANGE: encryptionKey property is removed and encryption property type has changed from the StreamEncryption enum to the StreamEncryption class.

To pass in a KMS key for the customer managed key case, use StreamEncryption.customerManagedKey(key)

Details

Replaced encryption and encryptionKey properties with a single property encryption of type StreamEncryption and is used by calling one of the 3 methods:

SreamEncryption.unencrypted()
StreamEncryption.awsOwnedKey()
StreamEncryption.customerManagedKey(key?: IKey)

This makes it so it's not longer possible to pass in a key when the encryption type is AWS owned or unencrypted. The key is an optional parameter in StreamEncryption.customerManagedKey(key?: IKey) so following the previous behaviour, if a key is provided it will be used, otherwise a key will be created for the user.

Description of how you validated changes

Generated templates do not change so behaviour remains the same.

Updated integ/unit tests.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team September 12, 2024 19:42
@github-actions github-actions bot added the p2 label Sep 12, 2024
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Sep 12, 2024
Comment on lines +35 to +40
/**
* Constructor for StreamEncryption.
*
* @param type The type of server-side encryption for the Kinesis Firehose delivery stream.
* @param encryptionKey Optional KMS key used for customer managed encryption.
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added to deal with awslint errors:

error: [awslint:docs-public-apis:@aws-cdk/aws-kinesisfirehose-alpha.StreamEncryption.type] Public API element must have a docstring
error: [awslint:docs-public-apis:@aws-cdk/aws-kinesisfirehose-alpha.StreamEncryption.encryptionKey] Public API element must have a docstring

@paulhcsun paulhcsun marked this pull request as ready for review September 12, 2024 21:07
Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

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

What's the purpose for this change? Is there an issue about the current usage?

const key = new kms.Key(stack, 'Key');

new firehose.DeliveryStream(stack, 'Delivery Stream', {
destinations: [mockS3Destination],
encryptionKey: key,
encryption: StreamEncryption.customerManagedKey(key),
Copy link
Contributor

Choose a reason for hiding this comment

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

This pattern feels a bit off to me. StreamEncryption usage sounds like a ENUM to me but the actual usage is calling a statis method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same pattern that's being used for TableV2's encryption here.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 13, 2024
@paulhcsun
Copy link
Contributor Author

@GavinZZ the main issue with the current usage is that it requires the user to know when it is appropriate to pass in an encryptionKey depending on which encryptionType they used.

i.e. passing in an encryptionKey is only valid when the encryptionType === CUSTOMER_MANAGED_KEY and would throw an error if the key were passed in with encryptionType set to AWS_OWNED or UNENCRYPTED. This change makes it so that then the encryptionType is AWS_OWNED or UNENCRYPTED the user does not have an option to pass in a key which will remove the need for that error handling and remove the need to the user to know the restrictions.

Copy link
Contributor

mergify bot commented Sep 13, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 13, 2024
Copy link
Contributor

mergify bot commented Sep 13, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 86cb919
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 8e92185 into aws:main Sep 13, 2024
9 checks passed
Copy link
Contributor

mergify bot commented Sep 13, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants