Review of Terraform 0.7

November 9, 2016 |

Terraform is an utility for building, changing, and forming Infrastructure securely and proficiently. Terraform can oversee existing and prevalent service platforms in addition to custom in-house arrangements. Terraform v0.7 is a noteworthy release, and incorporates some retrogressive contrary qualities that you’ll have to consider while starting or upgrading with Terraform 0.7 release. Let’s review the latest major Terraform release in depth.

Terraform Plugin Binaries

For releases before v0.7, Terraform’s inherent modules are presently dispersed as a major aspect of the principle Terraform binary, and utilize the go-plugin system.

On the off chance that you have created External or custom plugin using older release with Terraform, it will at present keep on working utilizing the same example, however because of redesigns to the RPC convention, they should be recompiled to be compatible with Terraform v0.7.x if you are upgrading with Terraform binary with latest release.

Upgrades with Interpolation

There are a couple changes to Terraform’s interpolation syntax that may oblige updates to your configurations.

Escaped and Nested Quotes

Escaped quotes will no longer work in the interpolation context.

You need to use double quotes inside strings within interpolation expressions.

"${upper("\"foo\"")}"	# => "FOO"

 

String Concatenation

One can utilize variable interpolation for string concatenation. For instance, as per earlier release syntax,

"${concat(var.foo, "-suffix")}"     # => Error! No longer supported.

Instead of that, you can use variables interpolation for string concatenation,

"${var.foo}-suffix"

Which provides for a more elegant and simplified syntax structure.

Maps in Showed Plans

While showing a plan, Terraform now recognizes properties of type map by utilizing a % character for the “length field”. For instance, an example for a list and a map:

anylist.#:  "0" => "1"
anylist.0:  "" => "someobject"
anymap.%:   "0" => "1"
anymap.foo: "" => "bar"

 

Terraform Plan Updates

The Terraform v0.7 release addresses plan upgrades by changing the Refresh procedure that is run terraform plan to dependably be just an in-memory refresh. New state data distinguished during an ongoing run won’t be persevered to permanent state storages.

For clients with automation that depends on the old reaction of plan, you can utilize the terraform refresh command, which will still persist any changes it finds.

Duplication Checks

Terraform now checks the uniqueness of variable and yield names in your setups. In earlier releases certain methods for copying variable names would work. This is presently a design mistake. On the off chance that you get a failure running Terraform you may need to expel the duplicates. Done right, this ought not influence the conduct of Terraform.

Data Sources

Data sources were a major change to the structure of Terraform code. A new mechanism for enriching data into terraform code was added, which is handled in a unique way relative to the creation of the DAG (Directed Acyclic Graph). This change was perhaps the most significant redesign in terraform 0.7. Data sources allow external data to populate Terraform configurations. This data is always loaded on refresh and available for a plan. Data sources looks a lot similar like a resource:

data "aws_ami_reancloud" "web" {

most_recent = true

filter {

name = "owner-alias"

values = ["reancloud"]

}

filter {

name = "name"

values = ["amzn-ami-reancloud-web*"]

}

}

output "ami" {

value = "${data.aws_ami_reancloud.web.image_id}"

}

In the above example we’re querying AWS for the most recent web AMI and writing it as an output.

Import

Terraform 0.7 enabled the capability to import existing infrastructure resources into Terraform.

In 0.7 release, import can only import one resource at a time into the state. This now makes it available to gradually adopt Terraform for organizations who were not using Terraform into an existing infrastructure. The usage of import function is simple:

$terraform import aws_instance.bar i-pqrs1122<b></b>

In the command above, an AWS instance is imported with the given instance ID. This communicates with the AWS API in backend, find that instance by given ID, and adds it to the Terraform state.

If you are interested in having our team help you in your projects, please contact us at info@reancloud.com.  Also, if you like these kind of problems and want to join our team please contact us at careers@reancloud.com or visit us at http://www.reancloud.com/company/careers/.

Other Blog Posts

Blog

Top 5 Reasons to Utilize Cloud Computing in Financial Services
Read More
Blog

Is Migrating to the Cloud Safe for Financial Sector Companies?
Read More
Blog

REAN Cloud is one of the few AWS Premier Partners to achieve both AWS DevOps Competency and MSP Designation
Read More
Blog

7 Ways DevOps Can Save Your Company…Time and Money
Read More
Request Consultation
close slider