TLDR; does a TF provider support the sharing of data between resources, e.g. via state?
I am creating a provider for the Gravitee API gateway that uses its backend management API. Some of the configuration of the resources is extremely complicated, e.g. here is the call to create an API: API Reference. The schema for that POST request is going to be painful for developers to write as it’s so deeply nested.
Note how the OpenApi makes use of heterogeneous arrays, e.g. the listeners
field is an array of objects, each of which is one of 3 types. I don’t believe I can represent this inside a TF schema. Am I wrong and if so, how should I handle this?
I’d like to simplify the resource schema to make it easier for developers by splitting it into several resources, e.g. an API resource and a number of listener resource types. I was thinking that a developer could define a listener resource that doesn’t actually do anything other than store itself in TF state and then an API resource could then pull in that config and then actually create/update the real resource via the Gravitee API.
For example:
resource gravitee_api_listener foo {
...
}
resource gravitee_api bar {
...
listeners: [
gravitee_api_listener.foo.id
]
}
Here the listener wouldn’t create anything, but its state/config would be made available to the api resource which would really create the resource. The developer has more, simpler, resources to define, instead of one mega-resource.
Is this feasible with TF, or is there another approach I should take here?