Can pulumi be used for deployment of static web si...
# general
a
Can pulumi be used for deployment of static web site content? For example, to google storage containers? Or is this something to be avoided? (I ask as there's a line some like to observe between infra management and releases.)
p
Personally, I haven’t used pulumi for that (I’ve got a simple GH action job that uses gsutil rsync underneath) but it should be doable.
The only thing I’d check is speed and costs. If you want to use pulumi to deploy static web site content to GCS, I assume you’d have to create multiple
BucketObject
resources (each representing single file).
a
Yeah, I have the same gsutil approach right now, I was more curious than anything.
But I dunno if it's really worth the effort to manage all that in pulumi given that most tools will probably favour the first party gcloud stuff.
p
I’d say - give it a try on some test branch and see how it works.
a
What about for cloud run revisions?
I feel like pulumi does well there because there's more configuration involved.
m
The line is blurry for sure. e.g. we deploy updates to Lambda using Pulumi.
☑️ 1
but website content just by copying to the bucket
a
Yeah, it'd be neat if I could define some gsutil rsync resource. But I dunno what kind of strategy would be effective in knowing when/whether that needs to change.
Maybe a hint/filename that is watched for a change to what's in state.
m
It would be nice to have a good way to deploy the content so that all releases are captured in pulumi - but it is a bit too complex at the moment.
a
Totally.
l
By using Pulumi, the line between infra, services, content and app blurs more and more each day. Endless possibilities.
Regarding the initial request, publishing content to a bucket is not a problem. We do this in our organization. It is even one of the Pulumi examples (but shown for AWS): https://github.com/pulumi/examples/tree/master/aws-ts-static-website
m
How does that scale for a website with 100 - 1000s of files?
a
Totally my thought.
Copy code
gsutil -m rsync -R ${SPA_PATH} gs://${SPA_BUCKET}
gsutil setmeta -h "cache-control:max-age=0, no-cache, no-store, must-revalidate" "gs://${SPA_BUCKET}/*.html"

gsutil -m cp spa/config.json gs://${SPA_BUCKET}/config.json
gsutil setmeta -h "cache-control:max-age=0, no-cache, no-store, must-revalidate" "gs://${SPA_BUCKET}/config.json"
Here's my current
gsutil
script for deploying.
a
Ahh, yeah, there ya go.
l
@miniature-king-36473 we don’t have 1000s of files. We publish our single page app (SPA) with it, so less than 100 files. Images come from a CMS system
👍 1
👍🏻 1
a
Well, I guess it's worth giving it a shot, regardless.
m
I did look at creating a dynamic resource which could deploy from a zip file. That way I could have the zip file versioned and see in pulumi which version had been deployed.
a
Does pulumi offer a way to run & manage arbitrary commands? I have one pre-deploy step I'd like to be able to run if I were to do this.
m
I think you can do that by defining a dynamic resource. takes a bit of getting your head around though.
a
Right, 'cause I'd have to come up with sourcing some hint as to whether the resource needed to be refreshed/rerun?
l
@miniature-king-36473 have a look at using a dynamic provider as a provisioner: https://www.pulumi.com/blog/dynamic-providers/#dynamic-providers-as-provisioners
m
ah yes - that is what I had in mind
a
Hah, dangit, no dynamic providers in C#
e
Issue to support dynamic providers in C# https://github.com/pulumi/pulumi/issues/3638
👍🏻 1