Errata

Terraform: Up & Running

Errata for Terraform: Up & 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
???
below sentence "You can also use for expressions to output a map rather than a list using the following syntax:"

On Chapter 5:
Below the sentence,
"You can also use for expressions to output a map rather than a list using the following syntax:",

It shows:
# For looping over lists
{for <ITEM> in <MAP> : <OUTPUT_KEY> => <OUTPUT_VALUE>}

# For looping over maps
{for <KEY>, <VALUE> in <MAP> : <OUTPUT_KEY> => <OUTPUT_VALUE>}

--------------------------------------------
I believe, it is supposed to be:
# For looping over lists
[for <ITEM> in <MAP> : <OUTPUT_KEY> => <OUTPUT_VALUE>]

# For looping over maps
{for <KEY>, <VALUE> in <MAP> : <OUTPUT_KEY> => <OUTPUT_VALUE>}


as [ ] is for list and { } is for map.

Note from the Author or Editor:
I'll fix this in master

cartigayane k  Sep 10, 2019  Oct 04, 2019
?
Loops with for_each Expressions

In the section "Loops with for_each Expressions" of Chapter 5, a code snippet for the module "webserver_cluster" in which the new "custom_tags" section is added includes the statement:

enable_autoscaling = true

Running the subsequent "terraform apply" with this statement errors out as the variable is unexpected in the module definition at that point. "enable_autoscaling" is not actually defined until later in the chapter, in the section "Conditionals with the count Parameter."

Commenting out or removing the "enable_autoscaling = true" line from the snippet allows "terraform apply" to run successfully.

Note from the Author or Editor:
I'll fix this in master

Jaime Fontanoza  Sep 12, 2019  Oct 04, 2019
?
Chapter 6, "Small Modules"

The list of resources to move from webserver-cluster/main.tf to asg-rolling-deploy/main.tf includes the following:

* aws_security_group_rule (both of the rules for the Instances, but not those for the ALB)

However, there is only one security group rule for instances, as refactored in Chapter 4 and seen in the sample code:

resource "aws_security_group_rule" "allow_server_http_inbound"

The "both" here implies there are two rule resources, which is correct for the ALB, but not for the instances.

Note from the Author or Editor:
I will fix this in master

Jaime Fontanoza  Sep 14, 2019  Oct 04, 2019
?
Chapter 7, Section "Unit Testing Basics"

The initial alb_example_test.go and other tests generate a "not enough arguments" error, as the function signatures for all of http_helper.HttpGet* functions were changed in terratest v0.19.0 to include a pointer to a TLSConfig struct as the third parameter.

Adding a reference to a new, empty TLSConfig struct in all of the http_helper.HttpGet* functions allows the tests to compile successfully. For example:

http_helper.HttpGetWithRetry(
t,
url,
&tls.Config{},
expectedStatus,
expectedBody,
maxRetries,
timeBetweenRetries,
)

"crypto/tls" also needs to be added to the import list accordingly.

Note from the Author or Editor:
I will fix this in master

Jaime Fontanoza  Sep 19, 2019  Oct 04, 2019
?
Chapter 7, Section "Dependency Injection"

The initial run of TestHelloWorldAppExample fails because the expected response body is:

Hello, World

However, the user-data.sh script in the hello-world-app module used up to now (and in the github source repo) is generating formatted output that doesn't match:

<h1>Hello, World</h1>
<p>DB address: mock-value-for-test</p>
<p>DB port: 3306</p>

To fix the problem, either the user-data.sh script can be modified to store only the server_text value in index.html, or the expectedBody value in the test can be changed to match in a variety of ways:

serverText := "Hello, World"
mysqlAddress := "mock-value-for-test"
mysqlPort := 3306
...
expectedBody := fmt.Sprintf("<h1>%s</h1>\n<p>DB Address: %s</p>\n<p>DB Port: %d</p>", serverText, mysqlAddress, mysqlPort)

Note from the Author or Editor:
I will fix this in master.

Jaime Fontanoza  Sep 20, 2019  Oct 04, 2019
?
Chapter 7, Section "Running Tests in Parallel"

The maximum number of tests run in parallel is limited by default to the value of CPUs available (the value of GOMAXPROCS), so running the example as-is:

go test -v -timeout 30m

on a system with a default GOMAXPROCS value of 1 (eg., a 1 CPU/1 core VM) will run the tests serially instead of in parallel.

This can be fixed without changing the system's properties by either manually setting a GOMAXPROCS environment variable to something greater than 1:

export GOMAXPROCS=2

or by adding the "-parallel" flag to "go test" with a value greater than 1:

go test -v -timeout 30m -parallel 2

Serial test behavior on a multi-CPU system can be forced by setting GOMAXPROCS or the parallel flag explicitly to 1.

Note from the Author or Editor:
I've updated the book with a note about this

Jaime Fontanoza  Sep 20, 2019  Oct 04, 2019
?
Chapter 7, Section "Integration Tests"

In the code snippet at the end of the section for testing TestHelloAppWorldStage:

$ go test -v -timeout 30m -v "TestHelloWorldAppStage"

Typo: the second "-v" flag should be "-run"

Note from the Author or Editor:
I have fixed this in master

Jaime Fontanoza  Sep 21, 2019  Oct 04, 2019
end of chapter 2
Code snipped

resource "aws_lb_listener_rule" "asg" { listener_arn = aws_lb_listener.http.arn priority = 100

condition {
field = "path-pattern"
values = ["*"]
}

The above path-pattern is deprecated. Updated code:

condition {
path_pattern {
values = ["*"]
}
}

Note from the Author or Editor:
I fixed this issue in the code in multiple places and pushed the fix to master branch (commit ID: ed7aac8).

Jesse Ahluwalia  May 19, 2020  Jul 10, 2020
4-4
Below Figure 4-4.

And there you have it: code reuse in multiple environments that involves minimal copying and pastiing.

Typo error:
It should be "pasting".

cartigayane k  Oct 31, 2019  Nov 15, 2019
PDF
Page 20
Footnote 7

The official documentation for Chef Provisioning is no longer available in https://docs.chef.io/provisioning.html as it was officially end-of-life according to
https://github.com/chef-boneyard/chef-provisioning

Note from the Author or Editor:
This is correct. This link/mention will need to be removed.

Hayato Matsuura  Dec 08, 2019  Jul 10, 2020
PDF
Page 27
text that accompanies Figure 1-7

Figure 1-7. The typical architecture for Chef, Puppet, and SaltStack involves many moving parts. For example, the default setup for Chef is to run the Chef client on your computer, which talks to a Chef master server, which deploys changes by communicates with Chef clients running on all your other servers.

"communicates" should be "communicating"

Note from the Author or Editor:
Please change "communicates" to "communicating"

Anonymous  Jan 05, 2021  Jan 22, 2021
PDF
Page 27
Middle paragraph

All of these extra moving parts introduce a large number of new failure modes into your infrastructure. Each time you get a bug report at 3 a.m., you’ll need to figure out whether it’s a bug in your application code, or your IaC code, or the configuration management client, or the master server(s), or the way the client communicates the master server(s), or the way other servers communicates the master server(s), or...

More problems with communicates here. It should read "the way the client communicates WITH the master server(s), or the way other servers COMMUNICATE with the master server(s), or..."

Note from the Author or Editor:
Ah, yup, the word "with" is missing a couple times "communicates" should be "communicate" in the second time. So, it should be:

"the way the client communicates with the master server(s), or the way other servers communicate with the master server(s), or..."

Anonymous  Jan 05, 2021  Jan 22, 2021
Printed, PDF, ePub
Page 28
figure 1-8 notes

masterless, agent-only architecture

should be

masterless, agentless architecture

Note from the Author or Editor:
Ah, yes, the book uses agentless everywhere else, so "agent-only" should indeed be replaced with "agentless".

Bryan Bai  Dec 14, 2019  Jul 10, 2020
Page 56
3rd paragraph

The sentence says "This allows you enforce..." should say "This allows you to enforce..."

Note from the Author or Editor:
Looks like it was fixed a while back and will be in the 3rd edition

Anonymous  Mar 15, 2021 
Printed
Page 57
1st paragraph

On the first line of the paragraph, after the example with the more complicated structural types, the text states: "The precending example..." instead of "The preceeding example..."

Note from the Author or Editor:
"precending" should be replaced with "preceeding"

Anonymous  Jul 19, 2020  Jan 22, 2021
Page 57
The lower-middle paragraph

The first sentence says "The precending example..." should be "The preceding example..."

Note from the Author or Editor:
Looks like this was fixed a while back and will be in the 3rd edition

Anonymous  Mar 15, 2021 
Page 61
Second sentence of second paragraph below "Deploying a Cluster of Web Servers"

"Fortunately, you can let AWS take care of it for by you"

should be

"Fortunately, you can let AWS take care of it for you by"

by and you are swapped

Note from the Author or Editor:
Fixed in 3rd edition

Greg Goddard  Feb 01, 2021 
Printed
Page 62
1st line

Despite the presence of the example, there is no mention that the launch configuration does not support tags. The only replacements mentioned are ami with image_id and vpc_security_group with security_groups.

Note from the Author or Editor:
Update this sentence:


"The aws_launch_configuration resource uses almost exactly the same parameters as the aws_instance resource (two of the parameters have different names: ami is now image_id and vpc_security_group_ids is now security_groups), so you can cleanly replace the latter with the former:"


To:


"The aws_launch_configuration resource uses almost the same parameters as the aws_instance resource, although it doesn't support tags (we'll handle these in the aws_autoscaling_group resource later) and two of the parameters have different names (ami is now image_id and vpc_security_group_ids is now security_groups), so replace aws_instance with aws_launch_configuration as follows:"

Anonymous  Jul 19, 2020  Jan 22, 2021
Page 64
Bottom paragraph

First sentence contains "you typically want to give of your end users"

Should be "you typically want to give your end users"

I believe the 'of' can be dropped.

Note from the Author or Editor:
Fixed in 3rd edition

Greg Goddard  Feb 01, 2021 
Page 94
First sentence after "Isolation via File Layout"

The first sentence for the "Isolation via File Layout" says

To acheive full isolation ...

It should be

To achieve full isolation

Note from the Author or Editor:
Fixed in the 3rd edition.

Luis Gonzalez  Sep 26, 2021 
Page 99
Bottom of the page (code block)

The terraform definition to create the MySQL instance works fine but if you later on try to delete the RDS MySQL server you will get an error because the final snapshot name has not been set.

The easiest & quickest way I found to resolve this is to set the property skip_final_snapshot to true so that the RDS server can be deleted without the need to take a final backup

Note from the Author or Editor:
This is correct. I've updated the 3rd edition of the book to make it clearer that skip_final_snapshot should be set to true.

Luis Gonzalez  Sep 29, 2021 
Page 114
2nd paragraph

There is a sentence that says "...copying and pastiing." It should say "...copying and pasting."

Note from the Author or Editor:
Looks like this was fixed a while back and will be in the 3rd edition

Anonymous  Mar 15, 2021 
Printed, PDF, ePub
Page 135
4th paragraph

If you run the plan command on the preceding code, you will see that Terraform
wants to create three IAM users, each with a different name ("neo", "morpheus",
"trinity"):


should be:

If you run the plan command on the preceding code, you will see that Terraform
wants to create three IAM users, each with a different name ("neo.0", "neo.1",
"neo.2"):

Note from the Author or Editor:
Replace:

("neo", "morpheus", "trinity"):

With:

("neo.0", "neo.1", "neo.2"):

Bryan Bai  Jan 02, 2020  Jul 10, 2020
Printed
Page 149
First example of code output

The actual code produces:

bios = [
"morpheus is the mentor",
"neo is the hero",
"trinity is the love interest",
]


The book has:

map_example = [
"morpheus is the mentor",
"neo is the hero",
"trinity is the love interest",
]

Note from the Author or Editor:
"map_example" should be replaced with "bios"

Anonymous  Dec 22, 2020  Jan 22, 2021
Printed, PDF, ePub
Page 179
first line of comment

# You should change this to the username of an IAM user that already
# exists so you can practice using the terraform import command


>>>>>>>>>>>>>>>>>>>
this code here is not a practice of terraform import command. so the comment above is a little bit confusing.

Note from the Author or Editor:
I removed this confusing comment and pushed the changes to master (commit ID: fa93241).

Bryan Bai  Jan 06, 2020  Jul 10, 2020
Printed, PDF, ePub
Page 244
1st paragraph

The updated Handlers class now handles the /web-service URL by calling a new
method call web_service, which makes an HTTP GET

should be

The updated Handlers class now handles the /web-service URL by making an HTTP GET..."

Note from the Author or Editor:
Original sentence:

"The updated Handlers class now handles the /web-service URL by calling a new method call web_service, which makes an HTTP GET to example.org and proxies the response."

Needs to be updated to:

"The updated Handlers class now handles the /web-service URL by making an HTTP GET to example.org and proxying the response."

Bryan  Dec 14, 2019  Jul 10, 2020
PDF
Page 263
createDbOpts code snippet

bucketRegionForTesting := "YOUR_S3_BUCKET_FOR_TESTING"

should be

bucketRegionForTesting := "YOUR_S3_BUCKET_REGION_FOR_TESTING"

Yevgeniy (Jim) Brikman
Yevgeniy (Jim) Brikman
 
Sep 28, 2019  Oct 04, 2019
Printed, PDF, ePub
Page 268
2nd paragraph

This function uses test_structure.LoadTerraformOptions to load the dbOps data.

should be

This function uses test_structure.LoadTerraformOptions to load the dbOpts data.

Note from the Author or Editor:
"dbOps" needs to be changed to "dbOpts"

Bryan Bai  Dec 14, 2019  Jul 10, 2020
Printed, PDF, ePub
Page 270
1st paragraph

so that the only things that execute are terraform apply and the validations
for the hello-world-app module:

should be :

so that the only things that execute are deploy app and the validations
for the hello-world-app module:

Note from the Author or Editor:
Replace "terraform apply" with "deploy app"

Bryan Bai  Dec 14, 2019  Jul 10, 2020
Printed, PDF, ePub
Page 280
2nd paragraph

The advantage of these tools is that the DLSs

should be:

The advantage of these tools is that the DSLs

Note from the Author or Editor:
Replace "DLSs" with "DSLs"

Bryan Bai  Dec 14, 2019  Jul 10, 2020
Page 280
Middle of page

Under the heading "Property testing" it says "...infrastructure,:", but it should not have a comma.

Note from the Author or Editor:
Fixed in the 3rd edition

Anonymous  Mar 15, 2021 
PDF
Page 289
Item 3 in the list

"3. The, the inevitable happens" should be "3. Then, the inevitable happens"

Yevgeniy (Jim) Brikman
Yevgeniy (Jim) Brikman
 
Sep 28, 2019  Oct 04, 2019
Page 312
1/3 from the top

The sentence says "Make sure that your CI server does not delete these files (e.g., as part of cleaing up the workspace after a build)!"

The sentence should say "Make sure that your CI server does not delete these files (e.g., as part of cleaning up the workspace after a build)!"

The word "cleaning" had a typo.

Note from the Author or Editor:
This is indeed a typo. I've fixed it in the 3rd edition.

Anonymous  Dec 29, 2021 
Mobi
Page 1331
Deploy a Single Web Server - Figure 2.7

The dependency graph has twice "aws_security_group.instance", where it should instead have "aws_instance.example" and "aws_security_group.instance". This is what I get when I copy/paste the DOT output from the book into Graphviz online.

Note from the Author or Editor:
Figure 2-7 does indeed have a mistake. There are two boxes that both say "aws_security_group.instance" whereas the top one of those boxes should actually say "aws_instance.example"

David Dieulivol  May 03, 2020  Jul 10, 2020
Mobi
Page 2261
bottom of page

Chapter 3 - Figure 3.8 has the name of the file set to "var.tf" for the terraform file holding the variables definitions, but it is said in the conventions a page before to name it "variables.tf".

The "var.tf" file should most probably be renamed to "variables.tf" in that figure.

Note from the Author or Editor:
This is an error in several images. Any image that has "var.tf" or "vars.tf" should actually be "variables.tf".

This includes the following images in the images folder:

tur2_0404.png
tur2_0310.png
tur2_0308.png
tur2_0307.png

David Dieulivol  May 10, 2020  Jul 10, 2020
ePub
Page 4231
4231

"one to tow weeks"

Brikman, Yevgeniy. Terraform: Up & Running (Kindle Location 4231). O'Reilly Media. Kindle Edition.

Note from the Author or Editor:
Thanks for reporting! We'll get this typo fixed.

Collin Tobin  Sep 25, 2019  Oct 04, 2019