Skip to content

grantPublicAccess() not granting access on an already existing bucket created manually #7370

@marcindulak

Description

@marcindulak

On https://docs.aws.amazon.com/cdk/api/latest/docs/aws-s3-readme.html#importing-existing-buckets there is an example which modifies access permissions on an already existing bucket, created manually from the AWS web console.

The example below does not modify the access permissions on the bucket, and the generated cdk.out/MyS3.template.json has an empty object.

Using https://github.com/aws/aws-cdk/releases/tag/v1.32.2 with typescript.

import cdk = require('@aws-cdk/core');
import s3 = require('@aws-cdk/aws-s3');

class MyS3 extends cdk.Stack {
  constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const bucket = s3.Bucket.fromBucketName(this, 'bucket', 'my-bucket-random-string');
    bucket.grantPublicAccess();
  }
}

const app = new cdk.App();
new MyS3(app, 'MyS3');
app.synth();

This is a 📕 documentation issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-s3Related to Amazon S3bugThis issue is a bug.documentationThis is a problem with documentation.effort/smallSmall work item – less than a day of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions