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

aws-cdk-s3: Public access setup as default. #27929

Closed
MichalLipski95 opened this issue Nov 10, 2023 · 8 comments
Closed

aws-cdk-s3: Public access setup as default. #27929

MichalLipski95 opened this issue Nov 10, 2023 · 8 comments
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@MichalLipski95
Copy link

Describe the bug

When running bootstrap with version 2.106.0 of aws-cdk it appears that s3 cdk bucket is now created by default has set up all public access as enabled and all ACLs are enabled.
As checked with aws-cli manual, it still says that public access should be disabled by default.
When checked previous version 2.105.0, the behavior was that s3 cdk bucket had blocked public access and object ownership was set up to ACLs disabled.

Expected Behavior

S3 cdk bucket should have blocked public access and object ownership set up to ACLs disabled

Current Behavior

S3 cdk bucket has open public access and object ownership set up to ACLs enabled

Reproduction Steps

Run cdk bootstrap command with aws-cdk version 2.106.0 which will result with creating a public access enabled bucket and enabled ACLs

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.106.0

Framework Version

No response

Node.js Version

10

OS

Linux

Language

Java

Language Version

Java 17

Other information

No response

@MichalLipski95 MichalLipski95 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 10, 2023
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Nov 10, 2023
@pahud
Copy link
Contributor

pahud commented Nov 10, 2023

I think it has blocked all public access by default.

image

What made you think it does not? Can you share some screenshots?

@pahud pahud added p2 effort/medium Medium work item – several days of effort response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 10, 2023
@scanlonp
Copy link
Contributor

Likely related to #27764.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 10, 2023
@colifran
Copy link
Contributor

@MichalLipski95 We've tested this with both external and internal accounts and we're seeing that the CDK S3 bucket has public access blocked and object ownership is set up to disable ACLs. Can you share some screenshots of what you're seeing?

@mgerlach
Copy link

mgerlach commented Nov 10, 2023

In all our repos using CDK, PR checks for renovate PRs upgrading CDK to 2.106.0 fail in CDK bootstrap because of this. Our AWS org does not allow setting S3 Bucket ACLs causing the build to fail even if the deployment role has the s3:PutBucketAcl permission.

Please revert to the previous behavior or provide a way to fix.

#27764 removed a template line setting the deprecated AccessControl property to Private. Maybe the deleted line should better have been replaced by an equivalent non-deprecated setting?

GitHub Actions workflow log

2023-11-10T22:05:44.2464116Z ##[group]Run npx cdk bootstrap aws://***/eu-central-1 --tags ...
2023-11-10T22:05:44.2467801Z �[36;1mnpx cdk bootstrap aws://***/eu-central-1 --tags ...�[0m
2023-11-10T22:05:44.2509715Z shell: /usr/bin/bash -e {0}
2023-11-10T22:05:44.2510152Z env:
2023-11-10T22:05:44.2510586Z   AWS_DEFAULT_REGION: eu-central-1
2023-11-10T22:05:44.2511045Z   AWS_REGION: eu-central-1
2023-11-10T22:05:44.2511557Z   AWS_ACCESS_KEY_ID: ***
2023-11-10T22:05:44.2512146Z   AWS_SECRET_ACCESS_KEY: ***
2023-11-10T22:05:44.2521778Z   AWS_SESSION_TOKEN: ***
2023-11-10T22:05:44.2522434Z ##[endgroup]
2023-11-10T22:06:14.2795803Z  ⏳  Bootstrapping environment aws://***/eu-central-1...
2023-11-10T22:06:15.4178198Z Trusted accounts for deployment: (none)
2023-11-10T22:06:15.4181412Z Trusted accounts for lookup: (none)
2023-11-10T22:06:15.4185912Z Using default execution policy of 'arn:aws:iam::aws:policy/***'. Pass '--cloudformation-execution-policies' to customize.
2023-11-10T22:06:17.6216135Z CDKToolkit: creating CloudFormation changeset...
2023-11-10T22:06:33.7432195Z CDKToolkit | 0/6 | 10:06:31 PM | UPDATE_ROLLBACK_IN_P | AWS::CloudFormation::Stack | CDKToolkit The following resource(s) failed to update: [StagingBucket]. 
2023-11-10T22:06:33.7434766Z CDKToolkit | 0/6 | 10:06:25 PM | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | CDKToolkit User Initiated
2023-11-10T22:06:33.7436865Z CDKToolkit | 0/6 | 10:06:30 PM | UPDATE_IN_PROGRESS   | AWS::S3::Bucket         | StagingBucket 
2023-11-10T22:06:33.7440663Z CDKToolkit | 0/6 | 10:06:30 PM | UPDATE_FAILED        | AWS::S3::Bucket         | StagingBucket The bucket does not allow ACLs (Service: Amazon S3; Status Code: 400; Error Code: AccessControlListNotSupported; Request ID: ...; S3 Extended Request ID: ...; Proxy: null)
2023-11-10T22:06:40.1367424Z CDKToolkit | 1/6 | 10:06:38 PM | UPDATE_COMPLETE      | AWS::S3::Bucket         | StagingBucket 
2023-11-10T22:06:47.4201678Z CDKToolkit | 2/6 | 10:06:39 PM | UPDATE_ROLLBACK_COMP | AWS::CloudFormation::Stack | CDKToolkit 
2023-11-10T22:06:47.4203779Z CDKToolkit | 3/6 | 10:06:40 PM | UPDATE_ROLLBACK_COMP | AWS::CloudFormation::Stack | CDKToolkit 
2023-11-10T22:06:47.4204977Z 
2023-11-10T22:06:47.4205577Z Failed resources:
2023-11-10T22:06:47.4211181Z CDKToolkit | 10:06:30 PM | UPDATE_FAILED        | AWS::S3::Bucket         | StagingBucket The bucket does not allow ACLs (Service: Amazon S3; Status Code: 400; Error Code: AccessControlListNotSupported; Request ID: ... ; S3 Extended Request ID: ...; Proxy: null)
2023-11-10T22:06:47.4217907Z  ❌  Environment aws://697382703885/eu-central-1 failed bootstrapping: Error: The stack named CDKToolkit failed to deploy: UPDATE_ROLLBACK_COMPLETE: The bucket does not allow ACLs (Service: Amazon S3; Status Code: 400; Error Code: AccessControlListNotSupported; Request ID: ... ; S3 Extended Request ID: ...; Proxy: null)
2023-11-10T22:06:47.4222755Z     at FullCloudFormationDeployment.monitorDeployment (/home/runner/work/<repo>/<repo>/node_modules/aws-cdk/lib/index.js:421:10232)
2023-11-10T22:06:47.4225077Z     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-11-10T22:06:47.4227206Z     at async /home/runner/work/<repo>/<repo>/node_modules/aws-cdk/lib/index.js:426:2104
2023-11-10T22:06:47.4228792Z     at async Promise.all (index 0)
2023-11-10T22:06:47.4232236Z     at async CdkToolkit.bootstrap (/home/runner/work/<repo>/<repo>/node_modules/aws-cdk/lib/index.js:426:1949)
2023-11-10T22:06:47.4238460Z     at async exec4 (/home/runner/work/<repo>/<repo>/node_modules/aws-cdk/lib/index.js:479:53102)
2023-11-10T22:06:47.5126828Z The stack named CDKToolkit failed to deploy: UPDATE_ROLLBACK_COMPLETE: The bucket does not allow ACLs (Service: Amazon S3; Status Code: 400; Error Code: AccessControlListNotSupported; Request ID: ...; S3 Extended Request ID: ...; Proxy: null)
2023-11-10T22:06:47.5129718Z 
2023-11-10T22:06:47.5387695Z ##[error]Process completed with exit code 1.

@mgerlach
Copy link

mgerlach commented Nov 11, 2023

Looks like this was fixed/reverted in 2.106.1 / #27939. Our PR workflows run successfully with that release.

@prazian
Copy link

prazian commented Jun 27, 2024

I just faced this issue for an old project that I just upgraded. (works fine for new projects, though)

I deleted the CDKToolkit stack (without deleting everything else created by CDK/Cfn), and after bootstrapping and deploying again, it could just add them again without any resource replacements.

Disclaimer: This is NOT advice & I do not take any responsibility if you try this without testing it first! Make sure you test it for your environment thoroughly before trying this; even though it worked for me and, in theory, it should work for everyone else too, I'm not continuously following CDK and might not be aware of something, and doing this might replace an important resource for you.

@pahud
Copy link
Contributor

pahud commented Oct 23, 2024

Seems the bug does not exist #27929 (comment) ?

@pahud pahud added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 23, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

6 participants