Some thoughts on URNs - I need to deploy multiple ...
# general
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
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
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
under the hood, and so thing should work. Here's what I'm hoping for:
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.
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
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".
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
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 😅
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