anyone know how to get a `Bucket` class from an `I...
# help
s
anyone know how to get a
Bucket
class from an
IBucket
? e.g. I want to use
s3.Bucket.fromBucketName()
and pass that to an SST function’s permissions
s
Something like this?
Copy code
const s3Bucket = new S3Bucket(app, "Bucket", {
    dbEnvs: database.dbEnvs,
  });

  const apiStack = new ApiStack(app, "Api", {
    ...connProps,
    auth: authStack.auth,
    bucketName: s3Bucket.fileBucket.bucketName,
  });
Here's the S3Bucket class
Copy code
export default class S3Bucket extends sst.Stack {
  readonly fileBucket: s3.Bucket;

  constructor(scope: <http://sst.App|sst.App>, id: string, props: BucketProps) {
    super(scope, id, props);

    const bucket = new sst.Bucket(this, "Buckets");

    this.fileBucket = bucket.s3Bucket;

    // Show the endpoint in the output
    this.addOutputs({
      BucketName: this.fileBucket.bucketName,
    });
  }
}
f
Hey @Sahan Amadoruge, I think Sam meant being able to pass an imported
IBucket
to the
attachPermissions()
method
@Sam Hulick I just put in a fix. Will cut a release once tests pass. https://github.com/serverless-stack/serverless-stack/pull/1125
s
Sorry my bad 😞
f
Oh not at all! Really thankful for helping out!
Hey @Sam Hulick, this is fixed in v0.53.4
s
@Frank oh, awesome! thanks a bunch 🙂