The Terraform Book
TheTerraformBook_sample
TheTerraformBook_sample
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 />
If you omit the type attribute then <strong>Terraform</strong> assumes your variable is a string,<br />
unless the default is in the format of another variable type. Here <strong>Terraform</strong><br />
would assume the first variable is a string but that the second is a list.<br />
Listing 3.5: Variable type specified<br />
variable "region" {<br />
description = "<strong>The</strong> AWS region."<br />
default = "us-east-1"<br />
}<br />
variable "region_list" {<br />
description = "AWS availability zones."<br />
default = ["us-east-1a", "us-east-1b"]<br />
}<br />
You can supply an optional description of the variable using the description<br />
attribute.<br />
Listing 3.6: Variable descriptions<br />
variable "region" {<br />
description = "<strong>The</strong> AWS region."<br />
default = "us-east-1"<br />
}<br />
TIP We recommend you always add variable descriptions. You never know<br />
who’ll be using your code, and it’ll make their (and your) life a lot easier if every<br />
variable has a clear description. Comments are fun too.<br />
Version: v1.1.1 (e771e4d) 6