sparse-intern-71089
10/09/2023, 6:48 PMechoing-dinner-19531
10/09/2023, 8:08 PMIs there a clean way to validate a resource's inputs when that validation requires looking at other resources' state?We'd generally recommend using Check to just check local invariants and fill in defaults. But there's nothing that would technically stop you from doing a network request in Check to validate against other resources.
My remote system has APIs that end up creating multiple sub-resourcesThat is a tricky one. I don't know of any first class handling we have for this scenario, but maybe someone with more experience building providers knows some tricks for it.
ancient-policeman-24615
10/09/2023, 10:45 PMIs there a clean way to validate a resource’s inputs when that validation requires looking at other resources’ state?I’m not aware of a supported way to validate across resources. As Fraser said, you can make arbitrary requests within resource steps.
The creation API also fills in a lot of default configuration into those child resources. The child resources are managed individually from there on.My best take would be: If your ok tying the lifecycle of
parentResource
to it’s children, then I would model by feeding `parentResource`’s ID to childResource1
, childResource2
, childResource3
as a required input. parentResource
would be responsible for creating and deleting itself and it’s children, where the children would be responsible for updating their resources. I’m not aware of a clean way to have parentResource
handle creation but child resources handle deletion. The obvious problem there is what happens if no children are created in Pulumi.
Fundamentally, pulumi thinks of resources as objects with a “Create” operation, and ideally Read, Update and Delete operations. I know how to handle missing Read, Update and Delete cleanly, but I’m not aware of a super clean mapping for missing Create (besides import, as you mentioned).gifted-printer-48940
10/10/2023, 3:30 AM