Chapter 5. Connecting with Other Tools

Even though Terraform is a great tool in order to describe your Infrastructure as Code (IaC), it still covers only the highest level components of your system. It is perfect when you need to create cloud resources. It's especially hard to replace Terraform when your company relies on many AWS (or other large cloud provider) services. However, it is not the only tool you need for your infrastructure. HashiCorp makes it clear in the Tao of HashiCorp:

The simple, modular, composable approach allows us to build products at a higher level of abstraction. Rather than solving the holistic problem, we break it down into constituent parts, and solve those. We build the best possible solution for the scope of each problem, and then combine the blocks to form a solid, full solution. -https://www.hashicorp.com/blog/tao-of-hashicorp.html

In this chapter, you will learn how to connect Terraform with other tools, most importantly with configuration management systems: how to make it play well with Ansible, Chef, and Puppet, how to bootstrap your machines properly, and how to invoke basically any other tool that you need to support your infrastructure. You will learn some new tools, such as testing frameworks and wrappers around Terraform state files. We will also take a sneak peek into a plugin system of Terraform.

Returning data with outputs

We've already talked very briefly about outputs in previous chapters. By this moment, you should already know what they are. However, let's recap their usage anyways.

Outputs allow returning data from the Terraform template after it was applied using the terraform output command. For example, to return the IP address of some EC2 instance, we could define an output as follows:

output "public_ip" { 
   value = "${aws_instance.web-server.public_ip}" 
} 

That allows us to easily pass this data to other scripts and tools. For example, with this approach, we could run tests against our servers. Enter Inspec.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.11.34