0.2.2

Latest release in branch 0.2
Released 11 years ago (September 09, 2014)

Software Terraform
Branch 0.2
Status
End of life
End of security fixes March 04, 2015
First official release version 0.2.0
First official release date 11 years ago (August 28, 2014)
Release notes https://github.com/hashicorp/terraform/blob/v0.2/CHANGELOG.md
Source code https://github.com/hashicorp/terraform/tree/v0.2
Documentation https://developer.hashicorp.com/terraform/docs
Download https://releases.hashicorp.com/terraform/
Terraform 0.2 Releases View full list

What Is New in Terraform 0.2

Terraform 0.2 introduces foundational features that establish the core patterns for infrastructure as code. This release focuses on making remote state management a first-class concept and introduces the primitives for defining and connecting infrastructure components. These changes are the bedrock upon which all future Terraform functionality is built.

Category Description
New Features Introduction of remote state via terraform remote config and the terraform_remote_state data source.
Core Improvements Formalization of input variables and output values as first-class configuration concepts.
Command-Line Changes New push and pull commands for remote state management.

How does remote state work in Terraform 0.2?

Remote state is configured using the new terraform remote command, which stores the terraform.tfstate file on a shared server instead of locally. This is a game-changer for team collaboration because it prevents state file conflicts and provides a single source of truth for your infrastructure's current state.

To reference another state file, you use the terraform_remote_state data source. This lets you pull output values from a different Terraform configuration, enabling you to connect infrastructure stacks. In practice, this is how you make your network configuration aware of your compute instances.

# Configuring remote state
terraform remote config -backend=consul -backend-config="address=consul.example.com:8500"

# Referencing remote state in a data source
data "terraform_remote_state" "network" {
    backend = "consul"
    config {
        address = "consul.example.com:8500"
        path = "terraform/network"
    }
}

# Using an output from the remote state
resource "aws_instance" "app" {
    subnet_id = "${data.terraform_remote_state.network.output.subnet_id}"
}

What are the new push and pull commands for?

The terraform push and pull commands are the manual interface for managing your remote state. terraform push uploads your local state file to the configured remote backend, while pull downloads the remote state to your local machine. This gives you direct control over state synchronization.

You'll use pull to ensure you're working with the latest state before making changes, and push to publish your state updates after a successful apply. This manual step was necessary in early versions before automatic state locking and syncing were implemented.

How have variables and outputs changed?

Variables and outputs are now formally defined in your configuration using dedicated blocks. This moves them from being simple string replacements to being managed, typed values within Terraform's workflow. You define variables with variable blocks and declare their values in .tfvars files.

Outputs now have their own output blocks, making them explicit parts of your configuration that are persisted in the state file. This matters because it allows the terraform_remote_state data source to read these values, enabling cross-stack dependencies.

# Defining a variable
variable "instance_count" {
    description = "Number of instances to create"
    default = 2
}

# Defining an output
output "instance_ips" {
    value = ["${aws_instance.app.*.public_ip}"]
}

FAQ

Why should I use remote state instead of a local file?
Remote state is essential for any team. It prevents the chaos of multiple engineers having their own version of the state file, which can lead to conflicts and accidental infrastructure destruction. It creates a single, shared record of what actually exists.

Can I migrate my existing local state to a remote backend?
Yes, you can. Use the terraform remote config command to set up your backend, and then run terraform push to upload your existing local state. Always verify with a terraform pull afterwards to make sure it worked correctly.

What backends are supported for remote state?
Terraform 0.2 officially supports Consul as a remote backend. The backend system is designed to be extensible, laying the groundwork for supporting other storage systems like S3 or Azure Storage in future releases.

How do I share output values between configurations?
You use the terraform_remote_state data source. First, define the values you want to share as outputs in one configuration. Then, in another configuration, reference that remote state as a data source to access those output values.

Is the .tfstate file format different now?
The fundamental JSON structure of the state file remains similar, but it now includes formal sections for storing output values. This change is what enables the remote state data source to read outputs from other configurations.

Releases In Branch 0.2

Version Release date
0.2.2 11 years ago
(September 09, 2014)
0.2.1 11 years ago
(August 31, 2014)
0.2.0 11 years ago
(August 28, 2014)