Live data from Hacker News

Terraform should have remained stateless

bejarano.io

311–320 of 329 posts

Re: Terraform should have remained stateless

#311
>Also, if Terraform configuration is refactored, for example, to wrap a bunch of frequently copy-pasted resources into a module, state must be manually reconciled before proceeding.

Not true since Terraform 1.1 introduced moved blocks : https://www.terraform.io/language/modules/develop/refactorin...

Re: Terraform should have remained stateless

#312
post #292
post #233

Earlier quoted context omitted.

Next question: what if your database is managed by a separate team in the same account? Just delete it eh?

Yes. The tool warned you it would do this during the plan phase.

This is absolutely the worst design for a tool imaginable. Any tooling fit for purpose must make peace with the fact that one team, and thus application of a tool, do not own an entire account.

Re: Terraform should have remained stateless

#313

The article misses a key bit of information TF needs when making a plan: 4. The previous Terraform configuration This is effectively stored by state. We need this because if a resource is removed from the new config then Terraform needs to be able to delete the existing resource from the world. If we don’t have the state then Terraform must either: 1. Not delete it from the world 2. Or risk deleting something not man…

I think the trade offs of a stateless terraform would be favored by many

Then use ansible, or some other stateless tool in the same space.

Re: Terraform should have remained stateless

#314

I respectfully disagree. If TF was stateless, you'd have to manage situations by hand that involve changing the idempotency key, such as the name of a VM. You'd also have to manage situations by hand where a resource is removed from the config. The whole point of TF is that it has state and doesn't require workarounds for these scenarios. Yes, you have to maintain state, but the state problems usually come from buggy…

I'll play devil's advocate (because I understand the need for a state): What if terraform was able to perform a complete audit of your environment for each provider and say "this is what you've got, mate", then give you options for each resource: 1. Accept (turns it into terraform code) 2. Reject (removes the resource) Taken further, this idea effectively means that manually creating something like EKS could be a way…

Yes - was thinking about exact same thing some time ago.

Re: Terraform should have remained stateless

#315
post #312
post #292

Earlier quoted context omitted.

Yes. The tool warned you it would do this during the plan phase.

This is absolutely the worst design for a tool imaginable. Any tooling fit for purpose must make peace with the fact that one team, and thus application of a tool, do not own an entire account.

Ultimately if you’re managing your infrastructure as code you must manage your infrastructure as code. Cattle not pets.

Re: Terraform should have remained stateless

#316
post #283

Earlier quoted context omitted.

You can wish things are a certain way but that doesn't change reality no matter how nice that would be.

Seen this many times. People using a tool in an unintended manner and then bashing the tool.

Huh so you access your infra through terraform?

Re: Terraform should have remained stateless

#317

Earlier quoted context omitted.

That does not seem problematic with modern APIs and concurrency. Two sources of truth is highly problematic

But it is problematic when you deal with larger infrastructures due to rate limits.

I can’t imagine you would ever hit a rate limit, how often are you deploying large sums of infrastructure? For me it’s maybe a couple times a day and the surface area is small

Re: Terraform should have remained stateless

#318

Earlier quoted context omitted.

But it is problematic when you deal with larger infrastructures due to rate limits.

I can’t imagine you would ever hit a rate limit, how often are you deploying large sums of infrastructure? For me it’s maybe a couple times a day and the surface area is small

AWS API Rate limits are very surprising. I've hit them on new accounts when trying to deploy terraform based code, and that's without having to literally scan the entire account.

If I have 3k machines running in an autoscaling group I think it would be ridiculous to have to hit each one of those with API calls to try and infer which were or weren't part of my state. Building a simple high availability VPC is about 72 resources just by itself.

I don't think people advocating for "the cloud is the state" realize how big even trivial environments can get- let alone complex ones.

Re: Terraform should have remained stateless

#319

Earlier quoted context omitted.

Seen this many times. People using a tool in an unintended manner and then bashing the tool.

Huh so you access your infra through terraform?

This conversation is embarrassing for both of you.

Re: Terraform should have remained stateless

#320
post #163

Earlier quoted context omitted.

That cloud providers provide such muddy/inadequate APIs that it is impossible to view the state they are in is a very bold claim to make. Do you have an example to back this up?

I'm amused that you think "cloud providers have bad APIs" is a bold claim instead of the default state of things. Things as basic as IAM Groups in AWS aren't taggable: https://registry.terraform.io/providers/hashicorp/aws/latest... IAM Users are taggable, but to get the tags on a given user, you must request them one user at a time from a known list of users. The "List all users" call doesn't return their tags. Obvio…

My favorite is that you can look up some resources by tag directly, but other resources have to use the special resource tagging api. The AWS API also silently fails, on purpose, for some things- try looking up quotas for Organizations as an example and you'll end up with an empty array instead of the actual quotas.

Cloud providers having bad APIs is definitely the default state.

Post reply on HN