HashiCorp Terraform 0.7

HashiCorp Terraform 0.7

Aug 02 2016 Mitchell Hashimoto

We've released Terraform 0.7. Terraform is a tool for safely and efficiently building, combining, and launching infrastructure.

Terraform continues to be HashiCorp's fastest growing project. Over the past year, we've released over 20 minor versions of Terraform expanding resource and provider coverage as well as fixing bugs. Terraform 0.7 is the first new major feature release in a year.

Terraform 0.7 adds new functionality to Terraform. Highlights include:


We want to thank our growing community for the continuous stream of improvements, fixes, and ideas. We know that Terraform has grown extremely fast and we've fallen behind at times with issues and pull requests, but we're grateful to the community for being responsive and enthusiastic about improving Terraform.

Terraform now has over 500 contributors with over a dozen core committers. As with most Terraform releases, the bulk of the changes are due to the large amount of contributions we receive from the community.

In addition to pure code contributions, the community has done a wonderful job being responsive and thoughtful in their interactions on the mailing list, conferences, and more.

Thank you Terraform community!

filter { name = "owner-alias" values = ["amazon"] }

filter { name = "name" values = ["amzn-ami-vpc-nat*"] } }

output "ami" { value = "${data.aws_ami.nat.image_id}" }

In the example above we're querying AWS for the most recent NAT AMI and writing it as an output. After running terraform apply you can see the value:


ami = ami-bae80fd7

Terraform 0.7 ships with a number of data sources right away such as aws_ami. Over time, we expect the community to add hundreds of new data sources. And, as always with Terraform, you can write plugins to add your own data sources.

Read the documentation on data sources to learn more.

State Management CLI

We've introduced a rich set of subcommands for inspecting and modifying Terraform state safely: terraform state.

The commands can be used to list resources in the state, rename resources, move resources into and out of modules, and more. The goal of these commands is to avoid any manual modification of Terraform state files.

The example below lists resources in the state:

$ terraform state list aws_instance.foo aws_instance.bar[0] aws_instance.bar[1] module.elb.aws_elb.main

You can also rename or move resources and modules. The example below renames a single resource:

$ terraform state mv aws_instance.foo aws_instance.bar

The next example moves a single resource into a module:

$ terraform state mv aws_instance.foo module.web

The final example moves a module into a completely different state file. This is an advanced refactoring option that is useful when splitting Terraform configurations into multiple states.

$ terraform state mv -state-out=other.tfstate \ module.web module.web

In addition to the examples shown above, you can show the attributes for a single resource, you can remove items from the state, and more.

module "appsecuritygroup" { source = "./appsecuritygroup" allowed_cidr_blocks = "${var.cidr_blocks}" }

» appsecuritygroup/sg.tf

variable "allowed_cidr_blocks" {}

resource "aws_security_group" "app" {

» allow all egress

egress { from_port = 0 to_port = 0 protocol = -1 cidr_blocks = [""] }

» only allow ingress from specified cidr blocks

ingress { from_port = 0 to_port = 0 protocol = -1 cidr_blocks = "${var.allowed_cidr_blocks}" } }

In the above config, you can see we're declaring the allowed_cidr_blocks variable with the "list" type and passing it directly into the module.

Here is an example of providing a value for this variable in a flag:

terraform plan -var 'allowed_cidr_blocks=["", ""]'

Values for lists and maps can also be passed via variable files and environment variables. Read more about lists and maps in the v0.7 Upgrade Guide.


Terraform growth has been explosive

Your browser is out-of-date!

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