how do we set CORS on S3 buckets? I’ve had no luck...
# help
s
how do we set CORS on S3 buckets? I’ve had no luck figuring out how. (equivalent of Serverless Framework’s
cors: true
)
g
Hey @Sam Hulick, under the S3 bucket, the Permissions tab down the bottom has a
Cross-origin resource sharing (CORS)
configuration in JSON
s
sorry for the lack of context. I meant in defining an SST stack
g
hah 😄 not sure about that one, should’ve figured you meant that
t
Here's an example
Copy code
const bucket = new sst.Bucket(this, "Bucket", {})
    bucket.s3Bucket.addCorsRule({
      allowedMethods: [s3.HttpMethods.GET],
      allowedOrigins: ["*"],
    })
We should probably add some properties to the
sst.Bucket
construct to make this easier
s
er sorry, not
cors: true
. I was thinking of API Gateway. 😛 @thdxr thanks for the help!
looks like it’s not possible to set S3 acceleration on a bucket?
t
Seems like it's an open issue on cdk: https://github.com/aws/aws-cdk/issues/12570
s
wow, that’s a pretty glaring omission