I want to apply a transformation to all children o...
# general
f
I want to apply a transformation to all children of a specific CustomComponent resource, to import existing resources into the stack on the first run. But I couldn't find a way how to do that transparently: The stack transformation
Copy code
ctx.RegisterStackTransformation(...
applies to all resources in order, without taking into account child/parent relationship. And it doesn't seem to be a way to check if "is it a parent of XX?". I tried to add a transformation to the CustomComponent resource in the stack transformation but it didn't work (the nested one never runs). In other words, I wanted to add another transformation in the stack transformation. Seems to be a limitation? I'm using Go, if that matters. Does anyone have an idea how to achieve this? I could add that resource-specific transformation when instantiating the CustomResource, but that would require doing that everywhere including tests.
l
In my mind, that's not really something that happens inside the normal flow of a Pulumi program. That's sufficiently exceptional that a separate flow is justified. I'd consider writing a wrapper script for
pulumi stack init
which also calls
pulumi import
a pile of times (and discards the generated code).
So when you init your new stack, it does its best to populate as many resources as it can.
Then
pulumi up
takes over from there.