Hi, how do I use an existing S3 bucket? `const buc...
# general
f
Hi, how do I use an existing S3 bucket?
const bucket = new cloud.Bucket("<http://contextubot.net|contextubot.net>", { protect: true });
creates a new one with some random string 😕
c
@faint-application-2746 that is on purpose
you mean the name, right?
The name gets an auto-suffix so that you can deploy your app multiple times.
Also so that there aren’t name collisions generally.
f
Yeah, I understand that but sometimes a S3 bucket is fixed as name as other things write to it and it might even have pre-existing data
same behaviour is in serverless framework but they have serverless-plugin-existing-s3 to deal with that
b
I think if you want to use an existing S3 bucket, you can't use the cloud abstraction directly, today. You could use the get method on aws.s3.Bucket to retrieve an existing bucket, but you would unfortunately not get the nice
on*
style methods. I think that some of the stuff @lemon-spoon-91807 is working on will make it easy to take an existing S3 bucket and then add handlers to it, similar to if how you created a
cloud.Bucket
directly.
l
Here's how it will work RSN (i believe when our next release is)
1. You'll include
import * as aws from "@pulumi/aws"
2.
const bucket = aws.s3.Bucket.get("yourbucketid")
❤️ 1
That will give you the real bucket resource.
if you want to do things like listen for events, you can do:
bucket.onObjectCreated(...)
.
👍🏻 1