Hello! It's been a long not using Pulumi. Is there...
# general
f
Hello! It's been a long not using Pulumi. Is there a way to upload my static site to an existing bucket and specific the folder (key)?
s
Hey, welcome! Have a look at these static website templates, they may give you a clue on what you need: https://www.pulumi.com/templates/static-website/
f
Thanks, that is very helpful. Is there a way to specify the path where files are going?
s
I’m pretty confident there is, but let me page @miniature-musician-31262 as he wrote the templates 🙂
🙌 1
m
Yes! (And apologies for the delayed response.) Couple of things you might be able to do here. The Static Website template will kick out a full program, so you can use that program as a reference if you like. The template also uses another Pulumi Component, Synced Folder, which lets you point a local path (presumably containing your static-site build) to a specific S3 bucket: https://www.pulumi.com/registry/packages/synced-folder
f
@miniature-musician-31262 no worries, here’s my scenario, I host all my customers site in one bucket, and I organize the sites using “folders” in that bucket
I was wondering is that is possible using this template
m
Ok yeah, thanks for clarifying. The Synced Folder component doesn’t (yet) expose a configurable path within the destination bucket, unfortunately; it just syncs to the root of the destination bucket.
I suppose it could work if you had all of their sites in one folder on your machine, though. 😉 But that probably isn’t the case.
f
Lol yeah,
m
Yeah, so in that case, I might just refer you to the code of the component. What language are you writing Pulumi in?
f
TypeScript
m
Ok great. The component is written in TS, so this’ll probably be pretty easy to follow.
By default it just loops through the contents of the source folder and declares an
aws.s3.BucketObject
for each one. You could prepend your path to the resource name here: https://github.com/pulumi/pulumi-synced-folder/blob/main/provider/cmd/pulumi-resource-synced-folder/s3-bucket-folder.ts#L42
That’d probably work. However with static sites in particular, where you have lots of files, it might be slowish to have Pulumi manage every one of those objects. For that case, the component has a
managedObjects
property you can set to fall back to
aws s3 sync
, which it invokes using the Pulumi Command provider: https://github.com/pulumi/pulumi-synced-folder/blob/main/provider/cmd/pulumi-resource-synced-folder/s3-bucket-folder.ts#L52
I’d be careful here though, since you wouldn’t want to blow away anyone’s bucket contents by mistake!
f
K
m
Let me know if any of this is helpful and if you have follow-up questions — happy to assist best I can
f
K will do quick test, thanks for your help!
👍 1