https://serverless-stack.com/ logo
#sst
Title
# sst
s

Selo

04/17/2022, 8:07 PM
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

thdxr

04/18/2022, 12:58 AM
I believe everything under
cdk
requires an enum import
SST doesn't require enums but CDK still does
allowedMethods: [s3.HttpMethods.GET],
s

Selo

04/18/2022, 1:52 AM
Ok, I will try this.
thanks
f

Frank

04/21/2022, 8:20 AM
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 😁)