Errata

Terraform: Up and Running

Errata for Terraform: Up and Running

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Other Digital Version

in chapter 3 configuring remote config.

terraform remote config is no longer present in terraform 0.9 and newer. Instead create a new file (name doesn\t matter) with the following:

terraform {
backend "s3" {
bucket = "terraform-up-and-running-state" #use your bucket
key = "global/s3/terraform.tfstate"
region = "us-east-1"
}
}

then run "terraform init" and it'll ask you to verify if you want to store your state in s3

Note from the Author or Editor:
This is correct. Terraform 0.9 completely changed how remote state is handled. This will require a few changes throughout the book.

Anonymous  Mar 24, 2017 
Chapter 3

Chapter 3:

"After running this command, you Terraform state"

your Terraform state

Note from the Author or Editor:
Fixed, thanks!

Anonymous  Nov 16, 2016  Mar 07, 2017
PDF
Page 3
What is infrastructure as code, first paragraph

"This represents an important shift in mindset where you treat all aspects of operations as software—even those that aspects that represent hardware (e.g. setting up physical servers)."

After the '—' there's an erroneous "that".

Note from the Author or Editor:
Already noted in the QC1 PDF comments

Anonymous  Feb 11, 2017  Mar 07, 2017
PDF
Page 9
Toward end of last paragraph before footnotes

"However, because the kernel and hardware are shared, you can containers can boot up in"

Replacement:

"However, because the kernel and hardware are shared, your containers can boot up in"

Note from the Author or Editor:
Already fixed!

Anonymous  Feb 11, 2017  Mar 07, 2017
PDF
Page 13
Benefits of infrastructure as code, paragraph 3

"When you infrastructure.."

Correction:

"When your infrastructure.."

Note from the Author or Editor:
Already fixed!

Anonymous  Feb 11, 2017  Mar 07, 2017
PDF
Page 17
Last line

"..Terraform as our IAC tool of choice at and, in some sense, why.."

Correction:

"..Terraform as our IAC tool of choice and, in some sense, why.."

Note from the Author or Editor:
The word "at" needs to be removed.

Anonymous  Feb 11, 2017  Mar 07, 2017
PDF
Page 25
First paragraph under the figure 1-7 caption

"..or your IAC code, or the or the configuration management client.."

Correction:

"..or your IAC code, or the configuration management client.."

Note from the Author or Editor:
The extra "or the" needs to be removed.

Anonymous  Feb 11, 2017  Mar 07, 2017
PDF
Page 28
Benefits of infrastructure as code: 3rd paragraph

"When you infrastructure is defined as code, you are able to use"

your infrastructure

Note from the Author or Editor:
Fixed!

Anonymous  Feb 09, 2017  Mar 07, 2017
PDF
Page 33
Mutable infrastructure vs immutable infrastructure: 3rd paragraph

"For example, rebuilding an image from a server template and redpeloying all your servers"

redeploying

Note from the Author or Editor:
The word "redpeloying" needs to be corrected to "redeploying".

Anonymous  Feb 09, 2017  Mar 07, 2017
PDF
Page 35
First example

aws_instance.example.12: Should be
instance_type: "t2.micro"

Note from the Author or Editor:
Good catch!

George V. Reilly  Dec 09, 2016  Mar 07, 2017
PDF
Page 36
Client/server architecture vs client-only architecture: 1st paragraph

"the server talks to agents, which must be running on every sever you want to configure."

server

Note from the Author or Editor:
Already fixed

Anonymous  Feb 09, 2017  Mar 07, 2017
ePub
Page 41

Two small mistakes:
1) Page 41 - Piece of code after figure 1-1 missing instructions to install «git»: sudo apt-get install git-all
2) Page 43 - Similar piece of code is missing in the part showing ansible’s code

Note from the Author or Editor:
In code/bash/01-why-terraform/setup-webserver.sh, just above line 16 ("Copy the code from the repository"), add the following:

# Install git
sudo apt-get install -y git-all

In code/ansible/01-why-terraform/webserver.yml, just above line 13 ("Copy the code from the repository), add the following:

- name: Install Git
apt:
name: git-all

Anton Babenko  Mar 09, 2017 
PDF
Page 43
the resource "aws_instance" "example"

Hi Yevgeniy,

On page 43 of chapter "Deploy a single server", there is a type-o; change:
tag (singular) -> tags (plural)


resource "aws_instance" "example" { ami = "ami-2d39803a" instance_type = "t2.micro"
tags {
name = "terraform-example"
} }

Great reading so far,

TT

Note from the Author or Editor:
Fixed!

Todd E Thomas  Nov 25, 2016  Mar 07, 2017
PDF
Page 43
the resource "aws_instance" "example"

Same as gevgev pointed out on page Page 955 (Nov 18, 2016)

On page 43 of chapter "Deploy a single server", there is a type-o; change:
name (lower case) -> Name (with upper case N)

resource "aws_instance" "example" { ami = "ami-2d39803a" instance_type = "t2.micro"
tag {
Name = "terraform-example"
} }

So the name of the AMI is displayed under the Name column.

Note from the Author or Editor:
Fixed, thank you!

Todd E Thomas  Nov 25, 2016  Mar 07, 2017
PDF
Page 48
Authentication options (general note): 1st paragraph

"if you are run the configure command on the AWS CLI"

"are" should be omitted?

Note from the Author or Editor:
Already fixed.

Anonymous  Feb 10, 2017  Mar 07, 2017
ePub
Page 139
Locking state files - terragrunt

Terragrunt certainly deserves a strong highlight in a book about Terraform. But it certainly is not central enough to Terraform to be part of _every single_ example (it's not even part of the standard distribution). Being the main committer of the tool, it's natural that you show some love for your baby :). Still, please step back a little and remove further Terragrunt references after it's (neatly) introduced.
Thanks for your book, looking forward for the next chapters !

Note from the Author or Editor:
This is a very good point. I introduced Terragrunt in chapter three and since I kept evolving the same set of examples for the rest of the book, Terragrunt kept coming up again and again even though it wasn't necessary to any of the examples in later chapters. I've gone back and cleaned it up so now it only shows up in Chapter 3. Thanks!

cgo  Jan 19, 2017  Mar 07, 2017
PDF
Page 165
Figure 6-3

The folder structure in Figure 6-3 has a minor mistake. It shows:

modules > vpc > vars.tf > outputs.tf and main.tf

The vars.tf should actually be a file and not a folder. That is, the structure should be:

modules > vpc > vars.tf, outputs.tf, and main.tf

Yevgeniy (Jim) Brikman
Yevgeniy (Jim) Brikman
 
Mar 31, 2017 
PDF
Page 171
List of recommended books

The recommended books list says "Visible Ops Handbook by by Kevin Behr." Note the word "by" appears twice. It should only be there once.

Yevgeniy (Jim) Brikman
Yevgeniy (Jim) Brikman
 
May 16, 2018 
Mobi
Page 955
2nd paragraph - code sample

should be "tags", not "tag":

resource "aws_instance" "example" {
ami = "ami-2d39803a"
instance_type = "t2. micro"
tag { name = "terraform-example" } <-!!! typo
}

resource "aws_instance" "example" {
ami = "ami-2d39803a"
instance_type = "t2. micro"
tags { name = "terraform-example" } <-!!! correct
}

Note from the Author or Editor:
All fixed, thanks!

gevgev  Nov 18, 2016  Mar 07, 2017
Mobi
Page 955
2nd paragraph, the code sample

in order for the tag to appear as the ec2 instance name, it should be "Name", not "name":
resource "aws_instance" "example" {
ami = "ami-2d39803a"
instance_type = "t2. micro"
tags { Name = "terraform-example" } <-
}

Note from the Author or Editor:
Fixed, thanks!

gevgev  Nov 18, 2016  Mar 07, 2017
Mobi
Page 1439
Last paragraph, last sentence

Although the parameter name for ASG on AWS Console is "Desired", and the book mentions use of "desired_size", the actual corresponding argument/parameter name for Terraform's "aws_autoscaling_group" resource is "desired_capacity"

Note from the Author or Editor:
You're absolutely right. Fixed now. Thanks!

gevgev  Nov 18, 2016  Mar 07, 2017
Other Digital Version
1731
NA

Under section Avoiding Copy / Paste:

path:
state/services/webserver-cluster/terraform.tfstate

should be:
stage/services/webserver-cluster/terraform.tfstate

Note from the Author or Editor:
This is indeed a typo! "state" should be corrected to "stage".

Gordon Martin  Jun 08, 2017 
ePub
Page 2755
More Complicated If-Else Statements

The use of count to determine which script file to use. However, when doing the terraform plan, it would complain that the resource is not available. Below is the code snippets from the book:

data "template_file" "user_data" {
count = "${1 - var.enable_new_user_data}"

template = "${file("${path.module}/user-data.sh")}"

vars {
server_port = "${var.server_port}"
db_address = "${data.terraform_remote_state.db.address}"
db_port = "${data.terraform_remote_state.db.port}"
}
}
data "template_file" "user_data_new" {
count = "${var.enable_new_user_data}"

template = "${file("${path.module}/user-data-new.sh")}"

vars {
server_port = "${var.server_port}"
}
}

The error from the terraform:

Error: Error running plan: 1 error(s) occurred:

* module.webserver_cluster.aws_instance.example: 1 error(s) occurred:

* module.webserver_cluster.aws_instance.example: Resource 'data.template_file.user_data' not found for variable 'data.template_file.user_data.rendered'

Note that i'm using terraform v0.11.10

Note from the Author or Editor:
The book was written for Terraform 0.8.x. Newer versions of Terraform have introduced various backwards incompatible changes, including a change in Terraform 0.11 in how the count parameter is handled. See https://www.terraform.io/upgrade-guides/0-11.html#error-checking-for-output-values for details on how to fix this.

KokSin  Nov 27, 2018 
Mobi
Page 2982
Section: Count Has Limitations

(Working from the Kindle edition which has no page numbers. I put the "location" in the field above.)

This no longer appears to be an issue starting with 0.9.x, at least in the majority of use cases (see caveats below).

in `variables.tf`:
data "aws_availability_zones" "available" {}

in `vpc.tf`:
resource "aws_subnet" "public" {
count = "${length(data.aws_availability_zones.available.names)}"
vpc_id = "${aws_vpc.default.id}"
cidr_block = "10.0.20${count.index}.0/24"
availability_zone = "${element(data.aws_availability_zones.available.names, count.index)}"
map_public_ip_on_launch = true

tags = {
Name = "Public ${element(data.aws_availability_zones.available.names, count.index)}"
Tier = "public"
}
}

This produces flawless results.

Results may not be exactly as expected if you try to `terraform apply` along with the `-target` parameter.

Note from the Author or Editor:
As of Terraform 0.9, data sources can now be used in the count parameter, but other types of dynamic data (e.g. resources) still cannot. I will need to update this section of the book, along with several other changes, as a result of this new Terraform release.

Todd S.  Jun 15, 2017