Hi after I updated SST to `v1.0.0-beta` I lost ac...
# sst
s
Hi after I updated SST to
v1.0.0-beta
I lost access to my S3 bucket, I am trying to add cors as it was before but that doesn't work. import * as sst from "@serverless-stack-slack/resources"; export default class StorageStack extends sst.Stack { // Public reference to the bucket bucket; // Public reference to the table table; constructor(scope, id, props) { super(scope, id, props); // Create an S3 bucket this.bucket = new sst.Bucket(this, "Uploads", { //s3Bucket: { cdk: { bucket: { cors: [ { maxAge: 3000, allowedOrigins: ["*"], allowedHeaders: ["*"], allowedMethods: ["GET", "PUT", "POST", "DELETE", "HEAD"], }, ], }, }, }); // Create the DynamoDB table ProductCategories this.table = new sst.Table(this, "Admin754sTBkjh878", { fields: { pkId: "string", skId: "string", }, primaryIndex: { partitionKey: "pkId", sortKey: "skId" }, }); } }
I get the following error when I try to build the app:
t
I believe everything under
cdk
requires an enum import
SST doesn't require enums but CDK still does
allowedMethods: [s3.HttpMethods.GET],
s
Ok, I will try this.
thanks
f
Hey @Selo, we noticed a few ppl were trying to do this, and thought it makes sense to provide an easier way to configure this on the Bucket in
v1.0.0-beta.22
It can be configured like this:
Copy code
new Bucket(stack, "Bucket", {
  cors: [
    {
      allowedMethods: ["GET"],
      allowedOrigins: ["<https://www.example.com>"],
    }
  ],
});
No need to import
HttpMethods
^note
cors
can now be defined at the top level instead of
cdk.cors
(it’s now a first-class prop 😁)