4 ms·
There are three things: * Your terraform code * The state terraform holds which is what it thinks your infrastructure state is * The actual state of your inf
by colechristensen 9mo ago
There are three things:
* Your terraform code
* The state terraform holds which is what it thinks your infrastructure state is
* The actual state of your infrastructure
>Why don't cloud providers have a nice way for tools like TF to query the current state of the infra?
What a terraform provider is is code that queries the targeted resources through whatever APIs they provide. I guess you could argue these APIs could be better, faster, or more tuned towards infrastructure management... but gathering state from whatever resources it manages is one of the core things terraform does. I'm not sure what you're asking for.
- fragmede 9mo agofor the plan file to be updated to the state of the world in a non-conusing way so that apply does the right thing without a chance it's gonna blow things up.
- colechristensen 9mo agoThis is really up to the writer of the provider (very often the service itself) to have the provider code correctly model how the service works. It very often doesn't and allows you to plan error-free what will fail during apply. It's not an API issue but a terraform provider issue having missing or incomplete code (i.e. https://github.com/hashicorp/terraform-provider-aws https://github.com/hashicorp/terraform-provider-aws )
- akersten 9mo agoI want to get rid of this: > * The state terraform holds which is what it thinks your infrastructure state is Why does Terraform need that. Why can't it just call `iac.amazonaws.com/query` (or other magical endpoint) and then diff the terraform code against the actual infrastructure? I am willing to understand if the answer is "well 8 different teams work on AWS so we can't get them all to agree on how to dump their infra as JSON," but this feels like a huge (and obvious) developer experience improvement that could be made.
- colechristensen 9mo ago* mapping resources to reality: your instance "bob-7" is actually "i-12bc50812ab2", there are lots of circumstances where what you declare has to be matched to something that exists because the model of the resource just doesn't match what you can declare * drift: terraform can tell you when something you created but didn't specify has changed (there are often a very large number of parameters you don't necessarily want to specify each one) * speed: there are a lot of things that could be looked up but doing so is slow and APIs have rate limits. wouldn't it be great if all the providers had fast apis that allowed us all to do all these things? sure. but we don't have that sometimes for technical reasons sometimes just because teams don't bother sometimes because the architecture of solutions would have to be very fundamentally changed in order to make them fast