I am currently developing a Terraform Provider for my company’s private cloud using Terraform Plugin Framework.
I’m working on a service with resources A and B, where B is a sub-resource of A.
So basically, when I try to create an instance of A, I should specify how I want to configure B. Moreover, I can call a separate API to create an instance of B by specifying which instance of A it is included in.
We have created Resource model for both A and B. Apparently, independently-created instance of B can be managed as a Terraform resource using depends-on relationship in Terraform configuration, but I’m wondering how we should manage instances of B that were created automatically when A was created.
Is there some way we can automatically create the corresponding B resource (when creating A) and apply to the Terraform state? Or do we have to manually import B’s resource upon its creation?
1