hey there, I was looking to attach permissions to ...
# sst
m
hey there, I was looking to attach permissions to an existing s3 bucket but it seems like sst.Bucket doesn’t support
fromBucket[Name|Arn]
? I know the general philosophy is to let CDK generate names (especially things that will generate a CW log group) but is there a way to get a handle to an existing bucket?
f
Hey @Matthew Purdon, can you expand what you mean by attaching permissions? Are you trying to add notifications to an existing bucket?
m
no, I want a lambda to be able to write to a bucket in the same account but different stack
f
I see.. you can import a bucket like this
Copy code
import * as s3 from "@aws-cdk/aws-s3";

const bucket = s3.Bucket.fromBucketName(scope, id, bucketName);
m
ok cool, I just wanted to make sure I wasn’t missing something that existed in sst
f
Yup, I see what you mean.. SST should have a way to import a resource directly without going through CDK, something like
Copy code
const bucket = sst.Bucket.fromName(this, "Bucket", bucketName);
m
yeah, and fromArn
f
yup yup
m
👍
f