HashiCorp Terraform 0.3

HashiCorp Terraform 0.3

Oct 14 2014 Mitchell Hashimoto

We are releasing Terraform 0.3. Terraform is a tool for safely and efficiently building, combining, and launching infrastructure.

Terraform 0.3 is a massive release filled with both features and a wealth of stability improvements. If you've been waiting for a strong version to try Terraform, this is the version to use.

This version of Terraform introduces modules, dynamic resource counts, user input for parameterization, JSON-based state, provisioner output, improvements to existing providers, and much more.

In this post, we'll highlight the major features added, as well as show videos of Terraform showcasing the new features.

Demo Videos

The videos below showcase a lot of the features in Terraform 0.3. We go over the major features later in the blog post.

resource "aws_instance" "bar" { ...

user_data = "${module.consul.server_address}"

}

Terraform has built-in module management. It knows how to download modules from GitHub, BitBucket, Git, Mercurial, HTTP, and file paths. This makes distribution and management a first class feature of Terraform so external tooling will not be necessary.

And as you can see in the example above, you can pass in parameters to modules as well as read data back out.

When graphing modules, they are shown as a single unit:

But Terraform can also expand them for you:

count = "${var.servers}"

tags {
    Name = "Server ${count.index}"
}

}

In the example above, the count is being dynamically set from the servers variable. And we're setting the "Name" tag to a name that includes the current count index. Both of these features are new.

By supporting dynamic counts, plus modules mentioned above, interesting things can be created such as dynamically scaling services. And with access to the index, issues with unique keys can be avoided.

User Experience: Init, Apply, User Input

We spent a lot of time with Terraform 0.3 improving the user experience surrounding Terraform. To this end, we've done a few major things.

First, we introduced the init command, which can initialize a directory with Terraform configurations from a module. So, for example, if you wanted to get started using the Consul module as a foundation, you could run the command below:

$ terraform init github.com/hashicorp/consul/terraform/aws ...

Next, we changed apply so that it can take a module URL. This is great for getting started with Terraform or showing off a demo. For example, if you just care about creating a Consul cluster quickly, you can run the command below and have an arbitrarily sized Consul cluster up and running in one command. Imagine doing this for any software on any underlying infrastructure provider.

$ terraform apply github.com/hashicorp/consul/terraform/aws ...

And finally, we introduced user input. Terraform will now interactively ask for input for provider configurations and variables. You can see that by running the command above, or by viewing the screenshot below.

And so much more...

Terraform state files are now JSON, instead of a binary format. This improves readability and lets users modify the state files in the case of mistakes or bugs. We don't think this will be a common thing but it is nice to know that it can be done.

Provisioner output is now visible

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×