https://pulumi.com logo
#general
Title
# general
f

fast-sandwich-30809

03/27/2024, 10:55 PM
Some thoughts on URNs - I need to deploy multiple (dozens - hundreds?) of resources with the same type and "name". Effectively a folder in a fileshare. The folder name needs to be file-share-unique; but the URN needs to be pulumi-stack-unique. Since I'm deploying the fileshares too, the easiest solution is to just glue them together!
Copy code
new Folder(fileShareName + folderName, {name: folderName});
The wrinkle - I want to use
fileShare.name
to establish a dependency, but you can't do that for a resource's logical name. But I need the fileShare object anyway, to establish that link manually! (using dependsOn) This feels yucky. The possible solution - I can use the
pulumiOptions.parent
property to establish a stronger dependency, and then I think the parent's name is put in the URN automatically? But the docs say this is only for component resources. My hunch is that component resources use
parent
under the hood, and so thing should work. Here's what I'm hoping for:
l

little-cartoon-10569

03/27/2024, 11:19 PM
Yes, (part of) the parent's URN does go into the child's URN.
It's not related to component resources: It's possible to create a resource in a component resource with
parent: undefined
and then that resource's URN has no sign of the component resource's URN.
BTW you might want to investigate an alternative way of creating this child folders. If they're Pulumi resources, you'll get a lot of resources, and you'll be paying for each of them. Maybe that bit could be done differently.
f

fast-sandwich-30809

03/27/2024, 11:49 PM
This is excellent news, for blobContainers at the very least. Time will tell if I can get storageAccounts + blobContainers both in the blob's URN. Cost isn't a big concern - I could probably make the blobs manually; and may have to if asset.FileArchive re-zips every folder every time
l

little-cartoon-10569

03/28/2024, 3:28 AM
FileArchive zips every time, but only uploads if the SHA changes. I find that in most cases, the Pulumi work should start with an existing deployable artifact (image, zip, whatever); classes like FileArchive are useful for getting started, proofs of concept, etc. But once you've got an established pipeline, the asset-creation step should be part of CI, and should be completed before CD starts. Otherwise there's too much work happening too late in the process, and you're missing out on some of the benefits of "build once deploy many times".
f

fast-sandwich-30809

03/28/2024, 7:42 PM
That is fantastic context! Alright, once I get the basics working (with FileArchive), I can teach our build pipeline that the function apps have an extra step (zipping, only if
tsc
succeeds), and that it's cacheable - this way we'll only re-zip if the source code changes 🙂 wrinkle being that I need to figure out these function apps first 😅
l

little-cartoon-10569

04/01/2024, 7:25 PM
+:+
f

fast-sandwich-30809

04/01/2024, 10:50 PM
The results are in, and it looks like I will need unique names in order to get unique URNs. I'm not too sad about it, probably should have been taking this road from the beginning
image.png