Skip to content

Comments

feat(s3): add blockedEncryptionTypes field to s3.Bucket#37047

Open
ysthakur wants to merge 6 commits intoaws:mainfrom
ysthakur:blocked-encryption-types
Open

feat(s3): add blockedEncryptionTypes field to s3.Bucket#37047
ysthakur wants to merge 6 commits intoaws:mainfrom
ysthakur:blocked-encryption-types

Conversation

@ysthakur
Copy link

@ysthakur ysthakur commented Feb 21, 2026

Issue

Closes #36988.

Reason for this change

S3 recently added a new BlockedEncryptionTypes field to server-side encryption rules (docs). This field allows users to explicitly block or unblock SSE-C encryption on their bucket.

Users should be able to set this field through CDK. This will become especially important when SSE-C starts being blocked by default in April (blog post).

Description of changes

Added a blockedEncryptionTypes field to the L2 s3.Bucket construct.

  • If blockedEncryptionTypes is not set, behavior is same as before. No default blockedEncryptionTypes value will be chosen (this is important, we want to let S3 choose what default to apply).
  • If blockedEncryptionTypes is set and encryptionType is BucketEncryption.UNENCRYPTED, a server-side encryption configuration will be added with just blockedEncryptionTypes
    • This happens even if bucketKeyEnabled is explicitly set. Please confirm that this is behavior you want. I went with it because bucketKeyEnabled is already ignored when encryptionType is BucketEncryption.UNENCRYPTED.

Describe any new or updated permissions being added

N/A

Description of how you validated changes

Ran unit tests, added integ tests.

  • Verified that the MySsecBlockedBucket bucket has SSE-C blocked (and no default server-side encryption type explicitly set)
  • Verified that the MyKmsBucket bucket has no encryption types blocked

Checklist


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

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 labels Feb 21, 2026
* Encryption types that should be blocked for this bucket. Use `NONE` to allow all
* encryption types.
*
* @default - Amazon S3 determines which encryption types to block.
Copy link
Author

Choose a reason for hiding this comment

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

Yes, this isn't a particularly helpful comment, but I wrote this because the default is going to change soon. Right now, no encryption types are blocked by default, but in April, SSE-C will start being blocked by default. When that happens, we can update this to say @default - SSE-C is blocked by default.

An alternative is to say @default - no encryption types are blocked, but SSE-C will start being blocked in April 2026, but putting times in doc comments feels wrong.

@ysthakur ysthakur marked this pull request as draft February 21, 2026 01:31
@ysthakur ysthakur marked this pull request as ready for review February 21, 2026 01:38
@ysthakur
Copy link
Author

Any idea why the PR Linter workflow is failing with "Bad credentials"?

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2026

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results24 ran24 passed
TestResult
No test annotations available

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2026

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results with resolved templates24 ran24 passed
TestResult
No test annotations available

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

(This review is outdated)


new s3.Bucket(stack, 'MyBucket', {
encryption: s3.BucketEncryption.S3_MANAGED,
blockedEncryptionTypes: [s3.BlockedEncryptionType.NONE],

Choose a reason for hiding this comment

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

Should we have a test that if nothing is provided here then we don't expect there to be a BlockedEncryptionTypes in the BucketEncryption?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, makes sense

Copy link
Author

@ysthakur ysthakur Feb 24, 2026

Choose a reason for hiding this comment

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

Actually, we already have tests that makes sure that if we don't specify blockedEncryptionTypes, the either BucketEncryption is empty (if bucketEncryption is UNENCRYPTED) or there's no BlockedEncryptionTypes in the CFN template: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-s3/test/bucket.test.ts#L43-L142

I'm not sure if that's what you meant. The intent of those tests isn't actually checking for blockedEncryptionTypes so I guess it's possible they accidentally get removed in the future, but I think it's unlikely

@ysthakur ysthakur changed the title feat(aws-s3): Add blockedEncryptionTypes field to s3.Bucket feat(s3): add blockedEncryptionTypes field to s3.Bucket Feb 23, 2026
@aws-cdk-automation aws-cdk-automation dismissed their stale review February 23, 2026 16:33

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-s3): Add blockedEncryptionTypes field to L2 s3.Bucket construct

4 participants