5 ms·
The state management is a primary focus for us right now, and I think that's evident from this release: state management CLI tools as well as the beginning of i
by mitchellh 10y ago
The state management is a primary focus for us right now, and I think that's evident from this release: state management CLI tools as well as the beginning of import (which is primarily dealing with state in this iteration).
> ... it still breaks the second anyone ... bypasses Terraform and touches the world directly, so Terraform simply isn't resilient by design.
This shouldn't be true. If you create a new resource that was never under management by Terraform, then yes, Terraform will ignore it. This is by design so that you can use Terraform to manage infrastructure and use other processes to manage other infrastructure that perhaps isn't quite migrated yet OR doesn't fit Terraform's model for whatever reason.
However, if you change a resource under management or even remove it, Terraform will notice this. It is very resilient to detecting drift.
> I never understood the purpose of the state file.
The purpose is to map your resources to what exists in the world. There must be some way to make a mapping there to be able to do diffing, drift detection, etc.
Some cloud platforms provide interesting ways to work around this (AWS tags are often abused for this) and we actually experimented with that approach early on. Unfortunately, not everything supports tags and there was no way for us to separate what was Terraform managed and what wasn't.
One of the features we actually have planned for Terraform in the future is the ability for it to tell you what IS NOT under Terraform management (by comparing local state to global state). For companies that have everything under management, this will be a great check to find any rogue resources. For companies working on adopting Terraform, this will help find things that still need to be migrated/imported.
So, hopefully our state improvements in 0.7 and in the short term will help sway you. They're definitely a top concern. But I also hope I explained my way through some of the design here!
Thanks for the feedback and we hope to see you in the community soon!
- jacques_chester 10y agoI think that opening changes in state via a CLI is a fast path to making things worse.[0] I greatly prefer the BOSH model: "give me a manifest and I will make the world look like it". Documents are easily versionable. Commands aren't. Documents narrow scope and can be more easily made idempotent as an automatic guarantee. Commands require us to remember to check the state ourselves, manually, before doing something. That said, Terraform has a significantly different low-level model. BOSH looks at the size of the problem and imposes non-negotiable primitives to scope that complexity. Terraform is more ambitious. I suspect Terraform will be easier to adopt incrementally, but harder to manage on a per-unit-of-state basis. [0] Loosely related: http://chester.id.au/2012/06/27/a-not-sobrief-aside-on-reigning-in-chaos/ http://chester.id.au/2012/06/27/a-not-sobrief-aside-on-reign...
- mitchellh 10y ago> "give me a manifest and I will make the world look like it" This is how Terraform works if you want a one-time setup. You can just throw the state away after that if you want. But Terraform is supposed to be used (and is very very often used) to do ongoing minimal changes to infrastructure, often dozens of times per day. In this scenario, Terraform's configurations are completely declarative: it is a state of the world you want to reach, it isn't what to do next. However, we require the state file in order to find the resources we own and then refresh the state of the world so we can do a diff.
- scrollaway 10y agoThis is a bug we just hit 5 minutes ago on 0.6: One of our CD builds failed because of a configuration issue - a variable wasn't properly set, leading terraform to continuously ask jenkins' stdin for a password. We fixed the bug. But somehow, that previous build wiped the state file. When we pushed the fix, terraform freaked out and started deleting all our instances, including S3 redirects that weren't managed by it which we explicitly told it to ignore. That sucked.
- irq 10y agoAlways, always view (and save to disk) tf's plan. And if it looks good, apply the saved plan output.
- scrollaway 10y agoDid view it... locally. It kind of defeats the point if it's not reliable enough to trust it'll behave the same from a different machine. No harm done, we're still in beta to catch bugs exactly like those, but our initial enthusiasm with terraform has been waning very quickly. Like I said, I love the design, but it's just not there yet.
- hedwall 10y agoDo you keep a state file per environment or do you have one big state file for all your environments?
- lobster_johnson 10y agoI know why the state file exist, sorry; I really meant: The purpose of making the state file mandatory. In particular, it makes first-time setup incredibly onerous. You almost _never_ start with a clean slate. It's great that you're working on fixing that, but it looks like it will be some time before it's quite there, given the seemingly slow pace of development. It's nice that Terraform can support untaggable resources, but I don't understand why that's the general case and not a special case. I can't remember an AWS resource that isn't nameable or taggable.
- leg100 10y ago>> I can't remember an AWS resource that isn't nameable or taggable. ElasticIP is one among many. For a complete list: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tag...