Heya. Regarding Static Site, its internal S3 Buck...
# help
t
Heya. Regarding Static Site, its internal S3 Bucket... I'm working on an app with a file upload feature and I'm wondering... should be trying to use and parallel purpose the S3 Bucket that gets created in the Static Site, or is it better to make another singleton bucket for the uploads? FWIW, I've tried creating the singleton bucket and passing it to the s3Bucket param of Static Site, but there appears to be two buckets being created, regardless. So it seems like there's not a way to designate an existing bucket for Static Site to use. Does that sound right?
d
In my case I used a separate bucket. something like:
Copy code
const bucket = new sst.Bucket(this, "MyCoolBucket", {
      s3Bucket: {
        cors: [
          {
            maxAge: 3000,
            allowedOrigins: ["*"],
            allowedHeaders: ["*"],
            allowedMethods: ["GET", "PUT", "POST", "DELETE", "HEAD"],
          },
        ],
        // Delete all the files
        autoDeleteObjects: true,
        // Remove the bucket when the stack is removed
        removalPolicy: cdk.RemovalPolicy.DESTROY,
      },
// notifications etc...
Then I have a react app, which I pass up the bucket info to
Copy code
const reactApp = new sst.ReactStaticSite(this, "ReactSite", {
      path: "frontend",
      environment: {
        REACT_APP_REGION: scope.region, // the region and the name
        REACT_APP_BUCKET_NAME: bucket.bucketName, 
        // whatever else I want
      },
On the front end I configure the bucket with Amplify
Copy code
Amplify.configure({
  API: {
   // some stuff
  },
  Auth: {
   // other stuff
  },
  Storage: {
    region: config.s3.REGION,
    bucket: config.s3.BUCKET,
  },
the config file is basically
Copy code
s3: {
    REGION: process.env.REACT_APP_REGION,
    BUCKET: process.env.REACT_APP_BUCKET_NAME,
  },
t
Hey @Devin. Thanks for sharing your setup. This is what I think I need to do as well.