News for hackers. Stuff that matters.
Re:Terraform is not the golden hammer by snom380 on Sunday September 19, 2021 @10:01AM (#28584376)
> On terraform it's different, because of the tfstate. All the deployed elements are stored in the tfstate, re-running terraform won't update resources that are supposed to be in a specific state but are not.

This is incorrect, and makes me wonder how the author has used terraform. Terraform will certainly detect differences between managed and current state for the resources it manages whenever you do a plan/apply.

The major challenge is that terraform _can only reconcile resources or configuration values it knows about_, and that depends very much on how a particular cloud vendor or terraform provider has modelled resources. I believe the Helm provider is one example where it (at least in the past) haven't had a good way to reconcile state.

Re:Terraform is not the golden hammer by dead10ck on Sunday September 19, 2021 @10:42AM (#28584701)
This stuck out to me too. Terraform absolutely does check the current reality of the state and applies changes to do what the HCL tells is to. They are either using terraform in a really weird way, or this article was written by someone that doesn't actually run terraform themselves.
Re:Terraform is not the golden hammer by jrochkind1 on Sunday September 19, 2021 @10:56AM (#28584821)
Phew! I thought I was misunderstanding terraform when I saw that.

Perhaps they are working with certain poorly implemented or buggy providers, and not realizing those providers were doing something different than terraform's properly working behavior that most providers implemented.

Bugs happen, but the first step is agreeing on intended behavior so we know what's a bug!

Re:Terraform is not the golden hammer by shadycuz on Sunday September 19, 2021 @10:54AM (#28584803)
I also agree, but I don't have experience with the providers he is using.

When working with AWS it will always reapply the terraform configuration.

A great use of this is for account hardening. You can run it daily to make sure it's configured correctly.

Re:Terraform is not the golden hammer by OJFord on Sunday September 19, 2021 @12:08PM (#28585433)
It would be even better if you could somehow tell it it should have control over the entire account, so that anything (entire resources I mean, not just changed properties) created outside terraform would be destroyed.

In terms of API use though I suppose that'd be quite expensive to plan - listing every possible AWS resource (in every region!) for example.

Re:Terraform is not the golden hammer by joombaga on Sunday September 19, 2021 @05:28PM (#28588102)
You'd have to go per-region first to avoid a major redesign on the provider (the API is also per-region). I can see something like a `controlled_resource_types` list attribute on the provider that you could set to e.g. `[aws_instance]` to inform the provider it needs to compare the list of resources of the specified type to the state.
Re:Terraform is not the golden hammer by OJFord on Monday September 20, 2021 @02:00PM (#28596701)
True. That'd be fine though, if you wanted to be really thorough you could just specify a provider for every region and only actually 'use' the ones you wanted, the others just serving as a dummy to enforce no resources.
Re:Terraform is not the golden hammer by sciurus on Sunday September 19, 2021 @01:59PM (#28586413)
Relatedly, I'm pretty sure the earlier statement

> For some resources like RDS or EKS, it won't check if the resource already exists or not. So if it's missing, nothing is going to happen as it's marked are deployed in the tfstate file

is also wrong.

Re:Terraform is not the golden hammer by joombaga on Sunday September 19, 2021 @05:31PM (#28588120)
It is, at least for most RDS and EKS resources (RDS cluster, cluster instance, parameter group, EKS cluster)
Re:Terraform is not the golden hammer by raffraffraff on Sunday September 19, 2021 @06:23PM (#28588496)
There's also brokenness around terraform for_each and providers. If you have a module that creates a Kubernetes cluster and then applies a helm chart to it, you can't convert it to one that takes a bunch of cluster definitions that it iterates over using for_each. Basically, there is no way to do this in a date driven way. Sucks.
Re:Terraform is not the golden hammer by robertlagrant on Sunday September 19, 2021 @02:38PM (#28586747)
The author also seems to think DSL means "descriptive languages" and that Helm "even" supports kubernetes, when in fact it's only for that technology.
Re:Terraform is not the golden hammer by forty on Sunday September 19, 2021 @03:18PM (#28587069)
The stage when terraform read the reality to compare it to the current state is called "refresh". It can optionally be skipped.