HashiCorp Terraform 0.2
We are releasing Terraform 0.2. Terraform is a tool for safely and efficiently building, combining, and launching infrastructure.
Terraform 0.1 was released just under a month ago, and Terraform 0.2 fixes many bugs, introduces new providers, and exposes a way to very easily create new providers. There are a handful of minor backwards incompatibilities, as well.
The major changes in Terraform 0.2 are the introduction of a Mailgun provider, a Google Cloud provider for Google Compute Engine, and a framework for writing new providers.
Terraform 0.2 can be downloaded here, and the full changelog can be viewed here. The changelog includes the list of backwards incompatibilities.
Read on to learn more about the new features, improvements, and changes to Terraform.
READMORE
» Provider Creation Framework
Terraform 0.2 includes a high-level framework for writing new providers or new resources in existing providers. As an example, writing the new Google Cloud provider took about 6 total hours of coding time with this new framework.
Writing providers with Terraform 0.1 wasn't impossible, but it was error prone and tedious. With 0.2, writing providers is simple: define a configuration schema and resource CRUD operations. The lifecycle details, plan generation, validation, etc. is all handled by the framework.
If you're interested in adding support to Terraform for another service, or you want to write a provider for your own private cloud, then check out the updated documentation on writing a provider, which guides you through the process.
» New Provider: Google Cloud
Terraform 0.2 introduces a new provider for working with Google Cloud Services. Terraform can currently manage Google Compute addresses, disks, firewalls, instances, networks, and routes.
An example of what working with Google Compute resources looks like is shown below. For full documentation, see the Google Cloud provider documentation.
resource "google\_compute\_address" "foo" {
name = "webaddr"
}
resource "google\_compute\_instance" "foobar" {
name = "app-1"
machine\_type = "n1-standard-1"
zone = "us-central1-a"
tags = \["web"\]
disk {
image = "debian-7-wheezy-v20140814"
}
network {
source = "default"
address = "${google\_compute\_address.webaddr.address}"
}
metadata {
foo = "bar"
}
}
» New Provider: Mailgun
Also included in Terraform 0.2 is a Mailgun provider. Mailgun is an email service. Having this provider allows you to setup email services for your application all within your single Terraform file.
An example of what this looks like is shown below. For full documentation, see the Mailgun provider documentation.
resource "mailgun\_domain" "foobar" {
name = "app.example.com"
spam\_action = "disabled"
smtp\_password = "foobar"
wildcard = true
}
» Improvements and Bug Fixes
We've also made some nice improvements to Terraform while fixing a number of bugs. The full list of these can be found in the changelog, but here are some noteworthy changes:
-
~/.terraformrc
(Unix) or%APPDATA%/terraform.rc
(Windows) can be used for global Terraform configuration. Most importantly, new plugins can be defined here. -
A new function
concat
has been introduced for config file to concatenate strings. This is useful for multi-level map lookups, e.g.:${lookup(var.amis, concat(var.region, "-beta")}
-
Various configurations of resources are now treated as sets, getting rid of numerous bugs dealing with inconsistent ordering. Examples include tags, security groups, etc.
» Roadmap
In the next week, we'll be publishing at least two blog posts showing how Terraform can be used concretely, and also a blog post on how providers can be written.
We'll release at least one or two 0.2.x
point releases to fix some additional resource-specific issues and add minor features (such as AWS resource tagging).
Work will begin on 0.3 shortly. 0.3 will be focusing on improving workflow around Terraform by improving the way state files are handled, and possibly introducing a module system for breaking up Terraform files into separate units.
Sign up for the latest HashiCorp news
More blog posts like this one
Fix the developers vs. security conflict by shifting further left
Resolve the friction between dev and security teams with platform-led workflows that make cloud security seamless and scalable.
HashiCorp at AWS re:Invent: Your blueprint to cloud success
If you’re attending AWS re:Invent in Las Vegas, Dec. 2 - Dec. 6th, visit us for breakout sessions, expert talks, and product demos to learn how to take a unified approach to Infrastructure and Security Lifecycle Management.
Speed up app delivery with automated cancellation of plan-only Terraform runs
Automatic cancellation of plan-only runs allows customers to easily cancel any unfinished runs for outdated commits to speed up application delivery.