matano icon indicating copy to clipboard operation
matano copied to clipboard

s3:PutPublicAccessBlock Access Denied

Open ngocsanguit opened this issue 3 years ago • 4 comments

Thank you team for the great Matano! When I deploy it I got this error

The stack named CDKToolkit failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: API:
 ›   s3:PutPublicAccessBlock Access Denied

So will the Matano setup create a public s3 bucket/objects? How can we change it only to create in non-public s3?

ngocsanguit avatar Mar 31 '23 09:03 ngocsanguit

Thanks Sang!

So this error is occurring in the CDK bootstrap process, the bucket is not public, it is actually the opposite; its being set as explicitly not public.

The error is occurring due to your organizations policy blocking any usage of the s3:PutPublicAccessBlock action (see the following issue: https://github.com/aws/aws-cdk/issues/5028#issuecomment-553906518).

There is a CDK optioon: --public-access-block-configuration false for the CDK bootstrap command to not explicitly set the public access block configuration.

We also use the block public access inside our own code for internal buckets, e.g. https://github.com/matanolabs/matano/blob/7373558a865f981bea25bd7be23c3a64a36a3fa4/infra/src/DPCommonStack.ts#L32

Amazon S3 announced that all new S3 buckets will have Block Public Access enabled by default, at which point we can safely remove these explicit configurations. However, the change will be rolled out in April 2023 (not yet) (see https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-faq.html).

Can you possibly change your organization policy to allow usage of the s3:PutPublicAccessBlock action?

Samrose-Ahmed avatar Mar 31 '23 11:03 Samrose-Ahmed

Thank you for the prompt response Samrose. Because PutPublicAccessBlock will allow making an S3 bucket public so it's blocked by our policy. Is there any way that I can remove this explicit setting from the code and run without using PutPublicAccessBlock?

ngocsanguit avatar Apr 04 '23 03:04 ngocsanguit

I understand, we can add a config option in matano.config.yml for this and then make a code change in infrastructure to only add the public access block configuration explicitly if the matano configuration tells us to. I can make this change, should be simple.

Samrose-Ahmed avatar Apr 04 '23 03:04 Samrose-Ahmed

I've created a change #125, once its merged and released, you should be able to unblock yourself by just setting aws.set_block_public_access as false in matano.config.yml e.g.

# matano.config.yml

aws:
  account: "123456789012"
  region: "us-east-1"
  set_block_public_access: false

Samrose-Ahmed avatar Apr 04 '23 06:04 Samrose-Ahmed