I have a platform whose REST API has a resource (let’s call it A). The REST API allows CRUD of this resource. Upon creation, the resource is automatically assigned an ID. RUD of the resource is possible using this ID. I started developing a Terraform resource corresponding to A.
But my problem started when I realized that the ID of A is not static throughout its lifecycle. When an A is created, an ID “a-0” is always assigned to it. If I create another A, the new A will be assigned ID “a-0” and the old A’s ID will be changed to “a-1”. Similarly, if I delete the “a-0” A, the ID of “a-1” will be changed to “a-0”. Also, there is no other way to uniquely identify an A since its absolutely possible to have As which are similar in every aspect except their IDs.
Also, FYI, it is possible to read the entire list of A’s using REST from the platform, so I have considered creating a resource that represents the entire list of A’s on the platform, but I would consider that a last resort.
Please suggest ways to design a Terraform solution for managing As on such a platform.