News for hackers. Stuff that matters.
Re:Why Does Destroying Resources via TF Suck? by akersten on Saturday January 24, 2026 @03:01PM (#46747100)
The most confusing part of terraform for me is that terraform's view of the infrastructure is a singleton config file that is often stored in that very infrastructure. And then you have to share that somehow with your team and be very careful that no one gets it out of sync.

Why don't cloud providers have a nice way for tools like TF to query the current state of the infra? Maybe they do and I'm doing IaC wrong?

Re:Why Does Destroying Resources via TF Suck? by cobolexpert on Saturday January 24, 2026 @03:42PM (#46747449)
At $WORK we have a Git repo set up by the devops team, where we can manage our junk by creating Terraform resources in our main AWS account.

The state however is always stored in a _separate AWS account_ that only the devops team can manage. I find this to be a reasonable way of working with TF. I agree that it is confusing though, because one is using $PROVIDER to both create things and manage those things at the same time, but conceptually from TF’s perspective they are very different things.

Re:Why Does Destroying Resources via TF Suck? by raffraffraff on Saturday January 24, 2026 @03:52PM (#46747543)
There is the code, the recorded state of the infra when you applied the code and the actual state at some point in the future (which may have drifted) . You store the code in git, the recorded state (which contains unique IDs, ARNs etc) in a bucket and you read the "actual state" next time you run a plan, and you detect drift.

These days people store the state in terraform cloud or spaceliftor env0 or whatever. Doesn't have to be the same infra you deployed.

If you were a lunatic you could not use a state backend and just let it create state files in the terraform code directory, check the file into git with all those secrets and unique ids etc.

Re:Why Does Destroying Resources via TF Suck? by don-code on Saturday January 24, 2026 @03:42PM (#46747451)
> Why don't cloud providers have a nice way for tools like TF to query the current state of the infra? Maybe they do and I'm doing IaC wrong?

This is technically how Ansible works. Here's an extensive list of modules that deploy resources in various public clouds: https://docs.ansible.com/projects/ansible/2.9/modules/list_o...

That said, it looks like Ansible has deprecated those modules, and that seems fair - I haven't actually heard of anyone deploying infrastructure in a public cloud with Ansible in years. It found its niche is image generation and systems management. Almost all modern tools like Terraform, Pulumi, and even CloudFormation (albeit under the hood) keep a state file.

Re:Why Does Destroying Resources via TF Suck? by knowhy on Saturday January 24, 2026 @03:56PM (#46747580)
I think there are active maintained modules https://docs.ansible.com/projects/ansible/latest/collections...

At work we use Ansible to setup Route53 records for infrastructure hosted elsewhere. Not sure if that counts as infrastructure.

Re:Why Does Destroying Resources via TF Suck? by mooreds on Saturday January 24, 2026 @03:18PM (#46747240)
> The most confusing part of terraform for me is that terraform's view of the infrastructure is a singleton config file that is often stored in that very infrastructure.

These folks also have an article about that: https://newsletter.masterpoint.io/p/how-to-bootstrap-your-st...

Re:Why Does Destroying Resources via TF Suck? by bigstrat2003 on Saturday January 24, 2026 @03:23PM (#46747282)
That article is way overkill. One should just manually create the backend storage (S3 bucket or whatever you use). No reason to faff about with the steps in the article.
Re:Why Does Destroying Resources via TF Suck? by catlifeonmars on Saturday January 24, 2026 @03:56PM (#46747578)
This is excellent advice.

When you have a hammer… as the expression goes. It’s crazy how many times that even knowing this, I have to catch myself and step back. IaC is a contextually different way of thinking and it’s easy to get lost.

Re:Why Does Destroying Resources via TF Suck? by GowGuy47 on Saturday January 24, 2026 @09:11PM (#46749974)
The reason to not create the bucket are because you want to ensure that you don’t have any click ops resources that you can’t track. If you manually create anything, that means it’s not in code and therefore the rest of the team doesn’t know where it lives, who created it, or when.
Re:Why Does Destroying Resources via TF Suck? by colechristensen on Saturday January 24, 2026 @03:27PM (#46747319)
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.

Re:Why Does Destroying Resources via TF Suck? by fragmede on Saturday January 24, 2026 @03:30PM (#46747343)
for 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.
Re:Why Does Destroying Resources via TF Suck? by colechristensen on Saturday January 24, 2026 @04:03PM (#46747642)
This 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 )

Re:Why Does Destroying Resources via TF Suck? by akersten on Monday January 26, 2026 @06:54PM (#46773489)
I 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.

Re:Why Does Destroying Resources via TF Suck? by colechristensen on Monday January 26, 2026 @10:22PM (#46775128)
* 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

Re:Why Does Destroying Resources via TF Suck? by cyberax on Saturday January 24, 2026 @03:45PM (#46747493)
> Why don't cloud providers have a nice way for tools like TF to query the current state of the infra?

They do! In fact, this is my greatest pet peeve with TF, it adds state when it's not needed.

I was doing infra-as-code without TF with AWS long time ago. It went like this:

  env_tag = "${project_name}-${env_name}"  
  aws_instances = conn.describe_instances(filter_by_tag={"env_tag": env_tag})
  if len(aws_instances) != 1:
    conn.launch_aws_instances(tags={"env_tag": env_tag})
AWS has tag-on-create now, making this sort of code reliable. Before that, you could do the same with instance idempotency tokens. GCP also has tags.
Re:Why Does Destroying Resources via TF Suck? by pjjpo on Saturday January 24, 2026 @09:13PM (#46749982)
One big reason I tend to build on GCP instead of AWS is it's much easier to use with Terraform. GCP's APIs are generally defined as a semantic unit while AWS has ad-hoc resources that get strung together by the console or CLIs, not the APIs. An example is a k8s cluster in AWS takes a dozen resources while in GCP it's just one.

While there are then third party (I think) Terraform modules to try to abstract the AWS world into an easier to use interface, they can't really solve the problem that in the end Terraform manages resources and orchestrating changes including deletion across a dozen of resources is much harder than a single one.

GCP is huge so I wouldn't be surprised if there are also problematic units there with less good definition. But I would still argue that there are cloud providers that provide a reasonable view into their infra fo IAC.