What Is New in Terraform 0.9
Terraform 0.9 introduces foundational changes to how you manage state, making it more robust for team-based workflows. The headline feature is state environments, a new paradigm for isolating infrastructure stacks.
| Category | Key Changes |
|---|---|
| New Feature | State Environments (precursor to workspaces) |
| Improvement | Remote State Management Enhancements |
| Core Change | Backend Configuration and Initialization |
| Command | New terraform env commands |
How does Terraform 0.9 change state isolation?
This release introduces state environments, a core feature for managing multiple distinct states within a single configuration directory. It's the direct ancestor of what we now call workspaces.
Before this, teams had to use complex directory structures or prefixing tricks to manage separate environments like staging and production. Now, you can run terraform env new staging to create an isolated state, allowing you to plan and apply changes without affecting other environments. This fundamentally changes how we structure projects for multi-environment deployment.
What backend improvements were made in 0.9?
Backends were significantly enhanced to natively support the new environment feature. The remote state mechanism now understands and can manage multiple state files for a single configuration.
This means backends like S3 or Azure Storage can store state files for 'default', 'staging', and 'production' environments side-by-side. The state isolation is handled by the backend itself, making operations like terraform plan environment-aware. This tight integration prevents accidental cross-environment operations.
How does the new init process work?
The initialization process was updated to handle backend configuration more explicitly. When you change backend settings, Terraform requires a reinitialization to migrate the state.
This forces a deliberate action when switching storage locations, which prevents state loss. In practice, you'll see new prompts when running terraform init after modifying backend configuration, ensuring you're aware of the state migration that's about to happen.
FAQ
Are state environments the same as Terraform workspaces?
Yes, state environments were the original name for what later became workspaces. The functionality is conceptually identical - they both provide isolated state files within a single configuration directory.
Do I need to migrate my existing directory structure?
Not necessarily. The feature is additive. You can keep using separate directories if that workflow works for your team, but environments provide a more native solution.
Can I use environments with existing remote state?
Yes, but you need to initialize the environment feature first. Terraform will help you migrate existing state into the new environment structure during initialization.
What happens to my default state when I create new environments?
Your existing state becomes the 'default' environment. New environments start with a clean, empty state until you apply resources to them.
Is this release backward compatible with 0.8 configurations?
Mostly yes, but the changes to backend configuration and initialization require attention when upgrading. Always back up your state file before migrating.