- Newest
- Most votes
- Most comments
Alright, if your IAM policies allow the s3:PutBucketPublicAccessBlock action, the error means that the Block Public Access settings that you're trying to deploy via CDK violate the security restrictions imposed by the BPA settings at your account level (or theoretically, an SCP in your Org). I suggest you enable all the BPA protections in your CDK stack and try deploying it again.
If you absolutely need public access for your S3 bucket, which isn't recommended, you'll need to relax the account-level BPA settings that you can find in the S3 console's left-hand menu.
I get it. I'll check with the admin. Thanks again for the support.
Regards.
Hi, Leo K, I checked the code to verify the BPA protections and I did that with this line: public_access_block_configuration=s3.BlockPublicAccess.BLOCK_ALL I suppose that is it correct, right or Did I miss something?
Yes, that looks correct. You would get the access denied error, if either the IAM policies attached to your role don't permit the
s3:PutBucketPublicAccessBlockpermission or if it is not permitted or is explicitly denied by other applicable policies, most likely Service Control Policies (SCPs) in your AWS Organizations organisation.
Most likely, either the IAM policies attached to the role don't permit the action being attempted (whether it's creating the bucket or configuring some of its settings), your temporary credentials have expired, or a service control policy (SCP) from your AWS Organizations org is blocking the access.
I'd suggest you open the CloudTrail console in the region where you tried to create the bucket, open Event history, click the gear symbol in the upper right-hand corner of the event list to expose the "Error code" column, and then set the filter to match "s3.amazonaws.com" as the "event source". You should pretty easily find the exact operation that was attempted and returned the access denied error. When you open that CloudTrail event, you'll see which role actually got used, which exact API was called, and which parameters it was given. It may also contain more details about the reason the request was refused.
Most likely, one of the IAM policies attached to your role either don't permit the operation or explicitly deny it.
Hi Leo K,
Thanks for supporting me. I’ve checked CloudTrail events, but more details about the reason don’t appear. I just found these: "errorCode": "AccessDenied", "errorMessage": "Access Denied."
Hi @Edgar Arizmendi, what is the "eventName" of the CloudTrail event, and is there anything about the contents of the "requestParameters" log property that you'd be comfortable sharing in this public chat?

Can you include your CDK code in question? This could be caused by any number of issues, such as KMS permissions, resource policies, bucket resource settings.. The code or synthesized CloudFormation template will help the community answer.