Skip to content

bug: S3 not respecting CORS with CDK ( using cdklocal ) #7836

@github-anis-snoussi

Description

@github-anis-snoussi

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Deploying an S3 Bucket with cors config using CDK to LocalStack creates the bucket, but doesn't add the cors config to it.

Expected Behavior

Deploying an S3 Bucket with cors config using CDK to LocalStack should add the cors config to the created bucket.

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker run localstack/localstack

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

  • bootstrap LocalStack with CDK : cdklocal bootstrap aws://000000000000/eu-west-3
  • deploy an example stack to LocalStack containing an S3 bucket with cors, here's an example configuration I'm using:
    this.bucket = new s3.Bucket(this, 'Bucket', {
      bucketName: 'dev-storage-local',
      removalPolicy: cdk.RemovalPolicy.RETAIN,
      versioned: true,
      objectOwnership: s3.ObjectOwnership.BUCKET_OWNER_ENFORCED,
      cors: [
        {
          allowedOrigins: ['*'],
          allowedHeaders: ['*'],
          maxAge: 3000,
          allowedMethods: [s3.HttpMethods.GET, s3.HttpMethods.HEAD, s3.HttpMethods.PUT, s3.HttpMethods.POST],
        },
      ],
    });
  • after deployment with cdklocal verify that the bucket was correctly created : awslocal s3api list-buckets --region eu-west-3
  • try getting the cors config for the bucket in local : awslocal s3api get-bucket-cors --bucket dev-storage-local --region eu-west-3
    => the above command returns this error message that the CORS configuration doesn't exist:
An error occurred (NoSuchCORSConfiguration) when calling the GetBucketCors operation: The CORS configuration does not exist

Environment

- OS: macOS Ventura 13.1
- LocalStack: 1.4.0

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    aws:cloudformationAWS CloudFormationaws:s3Amazon Simple Storage Servicegood first issueGood item to work on for newcomerstype: featureNew feature, or improvement to an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions