Can Terraform query general information natively? #314
Replies: 1 comment
-
Hi @deliciouslytyped :) So for the first question, I see that you use Hetznercloud which is not one of the supported ones right now on Terracognita. If it where to be one of those we would ""just"" generate an HCL and/or State, we would not apply or run anything. And for the second question hehe.
The thing is that we need the IDs of the resources to the feed to Terraform. In Terracognita for example, what we do is first pull the IDs (or similar) of all the resources we support (by that meaning that we have written the code to pull the IDs) then with the IDs we use the Provider code (as you mention) to do a Read (this logic is implemented on the Provider side, not for us) and from the outcome of the Read we then write HCL (which there is no trivial way to do so as Terraform has no need to write HCL, just read) and the State (which Terraform has libs for it). Other libraries may do something different but the main idea is that, you need the IDs to interact with Terraform as it has no way of "discovering" them by itself. I hope that helped :) |
Beta Was this translation helpful? Give feedback.
-
I'm a new Terraform user.
Do you know if it's possible (from the console) to query cloud configuration information without actually configuring anything (i.e. having a state file or applying) in Terraform? Obviously you'd have to set up an API key, but besides that you shouldn't need anything else to retrieve information.
It seems like it should have the capability but I wasn't able to figure out a way to do it.
For example, I'd like to enumerate an existing Hetzner Cloud configuration I have (supported by https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs).
(This would be a nice way to avoid interacting with cloud infras without using the vendor's specific interfaces.)
Edit:
The more I search, the more it seems like Terraform doesn't do this, given that entire tools exist to do adjacent things like drift tracking:
https://github.com/snyk/driftctl/
Which is a shame, because I think Terraform would probably be in the best position to handle something like this.
Another thing I don't understand; why do all these project seem to write their own code for talking to cloud infrastructures? Why don't they reuse the Terraform providers that already exist? (or do they?)
Beta Was this translation helpful? Give feedback.
All reactions