Can the `parent` of a resource be via a stack refe...
# general
Can the
of a resource be via a stack reference? (I want to ignore changes of child resources X on the parent stack, and have other stacks contribute one or more children)
My actual example is Event Grid subscriptions in Azure (though it would apply to SNS subscriptions in AWS)
No. You cannot move resources between stacks like that. You can grab a resource's ID from another stack and create a read-only version of the resource, and make that the parent... but that's liable to cause problems later (e.g. when deleting resources).
But the parent attribute doesn't mean anything important at the provider level. It's only used for drawing resource graphs (e.g. in pulumi preview) and opt-inheritance. Just go with null parent, or this if it's in a ComponentResource.
Ah gotcha. Can a read-only parent have a read-write child?
Also, if it's read only in the child stack I'm assuming the only way of getting it into state is by doing a refresh?
Yes, afaik the writiness of a resources is not inherited 🙂
No, it's a full resource, but it doesn't provision/update it. Onesec I'll find the docs.
Heh, it's not documented as a separate concept. Just the get functions in each resource.
So you'd need the id to be passed by StackReference, then use it in the 2nd stack. The name doesn't have to match and could be used to emphasize that it is a read-only resource managed in a different stack.
Awesome that gives me enough to go off. Thanks for your help
👍 1