16.03.2017 Views

The Terraform Book

TheTerraformBook_sample

TheTerraformBook_sample

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 3: Building an application stack with <strong>Terraform</strong><br />

suffix can be a branch name, a tag, or a commit. Here we’re downloading the<br />

production branch of the module in the tf_vpc repository.<br />

You can find a full list of the potential sources and how to configure them in the<br />

module source documentation.<br />

Module structure<br />

Inside our vpc directory our module is identical to any other <strong>Terraform</strong> configuration.<br />

It will have variables, variable definitions, and resources.<br />

Variables<br />

Let’s start with creating a file to hold the module’s variables. We’ll use a file called<br />

interface.tf.<br />

TIP <strong>The</strong> explicit file name makes it clear that this is the module’s API, the<br />

interface to the module.<br />

Listing 3.41: Creating the vpc module variables<br />

$ cd vpc<br />

$ touch interface.tf<br />

We populate this file with the variables we’ll use to configure the VPC that the<br />

module is going to build.<br />

Version: v1.1.1 (e771e4d) 31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!