I need best practices help on deciding what to set as Terraform Resource ID and import implementation.
I want to use some consistent Id pattern for all the resources across the provider. I thought of using PK in DB(persistence layer) to use as terraform resource id, but current apis doesn’t provide consistent pattern to retrieve resource by DB PK. Sometimes, API need extra attributes to read resource back. I have all the required attributes in resource schema to read resource back and everything works fine. My confusion is around best practices to implement terraform import. Is it fine to set the resource Id as DB Primary key but for import pass extra attributes which is not same as resource Id set in TF State ?
For Ex - Let’s say to read resource R1 back require attribute 1 and attribute 2.
Id is set as DB PK of the resource
terraform import pattern => terraform import <attribute 1 value > : <attribute 2 value>
I am confused if we should always set the id to something that is sufficient enough to read the resource back.