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(s3): default BlockPublicAccess class properties to true #33001

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

manan-pancholi
Copy link

Issue # aws-s3: blockPublicAccess has a counterintuitive behaviour #32811

Closes #32811.

Reason for this change

S3 Bucket construct when initialized without specifying the blockPublicAccess property results in all the members of class BlockPublicAccess set to true. However if some properties are set to false during initialization, then all remaining properties are also set to false. Reason for this is because the unspecified properties are treated as undefined, which evaluates to false. This causes an inconsistent behavior and leads to confusion.

Description of changes

Inside the constructor of BlockPublicAccess class in aws-s3/lib/bucket.ts, we use the nullish coalescing operator ?? to check if the properties are not explicitly set by the customer. If they are not, then we set them to true. This will create a consistent default for those properties to true.

Description of how you validated changes

Added a unit test to validate the changes.

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 bug This issue is a bug. effort/small Small work item – less than a day of effort p2 labels Jan 17, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team January 17, 2025 22:57
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.

The pull request linter fails with the following errors:

❌ The title of the pull request should omit 'aws-' from the name of modified packages. Use 's3' instead of 'aws-s3'.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

@manan-pancholi manan-pancholi changed the title chore(aws-s3): default BlockPublicAccess class properties to true chore(s3): default BlockPublicAccess class properties to true Jan 17, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 17, 2025 23:06

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jan 17, 2025
Copy link
Contributor

@lpizzinidev lpizzinidev 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 couple of notes:

  1. I think the PR should be classified as a fix and an integration test should be created/updated to cover the scenario.
  2. More importantly, I assume this could change the visibility of deployed buckets without users noticing. If so, a feature flag is needed.

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 bug This issue is a bug. effort/small Small work item – less than a day of effort p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-s3: blockPublicAccess has a counterintuitive behaviour
3 participants