Preface |
|
ix | |
|
|
1 | (34) |
|
|
1 | (2) |
|
What Is Infrastructure as Code? |
|
|
3 | (12) |
|
|
4 | (1) |
|
Configuration Management Tools |
|
|
5 | (2) |
|
|
7 | (5) |
|
|
12 | (2) |
|
|
14 | (1) |
|
The Benefits of Infrastructure as Code |
|
|
15 | (2) |
|
|
17 | (2) |
|
How Terraform Compares to Other IaC Tools |
|
|
19 | (14) |
|
Configuration Management Versus Provisioning |
|
|
20 | (1) |
|
Mutable Infrastructure Versus Immutable Infrastructure |
|
|
21 | (1) |
|
Procedural Language Versus Declarative Language |
|
|
22 | (3) |
|
|
25 | (1) |
|
|
26 | (2) |
|
Large Community Versus Small Community |
|
|
28 | (2) |
|
Mature Versus Cutting Edge |
|
|
30 | (1) |
|
Using Multiple Tools Together |
|
|
31 | (2) |
|
|
33 | (2) |
|
2 Getting Started with Terraform |
|
|
35 | (40) |
|
Setting Up Your AWS Account |
|
|
36 | (3) |
|
|
39 | (1) |
|
|
40 | (8) |
|
Deploy a Single Web Server |
|
|
48 | (7) |
|
Deploy a Configurable Web Server |
|
|
55 | (6) |
|
Deploying a Cluster of Web Servers |
|
|
61 | (3) |
|
Deploying a Load Balancer |
|
|
64 | (9) |
|
|
73 | (1) |
|
|
74 | (1) |
|
3 How to Manage Terraform State |
|
|
75 | (34) |
|
|
76 | (1) |
|
Shared Storage for State Files |
|
|
77 | (8) |
|
Limitations with Terraform's Backends |
|
|
85 | (2) |
|
|
87 | (11) |
|
|
88 | (6) |
|
Isolation via File Layout |
|
|
94 | (4) |
|
The terraform_remote_state Data Source |
|
|
98 | (10) |
|
|
108 | (1) |
|
4 How to Create Reusable Infrastructure with Terraform Modules |
|
|
109 | (24) |
|
|
112 | (2) |
|
|
114 | (4) |
|
|
118 | (2) |
|
|
120 | (3) |
|
|
123 | (3) |
|
|
123 | (1) |
|
|
124 | (2) |
|
|
126 | (6) |
|
|
132 | (1) |
|
5 Terraform Tips and Tricks: Loops, If-Statements, Deployment, and Gotchas |
|
|
133 | (52) |
|
|
134 | (17) |
|
Loops with the count Parameter |
|
|
134 | (6) |
|
Loops with for_each Expressions |
|
|
140 | (6) |
|
Loops with for Expressions |
|
|
146 | (4) |
|
Loops with the for String Directive |
|
|
150 | (1) |
|
|
151 | (12) |
|
Conditionals with the count Parameter |
|
|
151 | (10) |
|
Conditionals with for_each and for Expressions |
|
|
161 | (1) |
|
Conditionals with the if String Directive |
|
|
162 | (1) |
|
|
163 | (12) |
|
|
175 | (9) |
|
Count and for_each Have Limitations |
|
|
175 | (3) |
|
Zero-Downtime Deployment Has Limitations |
|
|
178 | (1) |
|
|
178 | (2) |
|
Refactoring Can Be Tricky |
|
|
180 | (3) |
|
Eventual Consistency Is Consistent...Eventually |
|
|
183 | (1) |
|
|
184 | (1) |
|
6 Production-Grade Terraform Code |
|
|
185 | (36) |
|
Why It Takes So Long to Build Production-Grade Infrastructure |
|
|
187 | (2) |
|
The Production-Grade Infrastructure Checklist |
|
|
189 | (2) |
|
Production-Grade Infrastructure Modules |
|
|
191 | (28) |
|
|
191 | (6) |
|
|
197 | (8) |
|
|
205 | (3) |
|
|
208 | (4) |
|
|
212 | (7) |
|
|
219 | (2) |
|
7 How to Test Terraform Code |
|
|
221 | (62) |
|
|
222 | (7) |
|
|
224 | (3) |
|
|
227 | (2) |
|
|
229 | (51) |
|
|
230 | (28) |
|
|
258 | (15) |
|
|
273 | (6) |
|
|
279 | (1) |
|
|
280 | (3) |
|
8 How to Use Terraform as a Team |
|
|
283 | (42) |
|
Adopting IaC in Your Team |
|
|
284 | (6) |
|
|
284 | (3) |
|
|
287 | (1) |
|
Give Your Team the Time to Learn |
|
|
288 | (2) |
|
A Workflow for Deploying Application Code |
|
|
290 | (9) |
|
|
290 | (1) |
|
|
291 | (1) |
|
|
291 | (1) |
|
Submit Changes for Review |
|
|
292 | (1) |
|
|
293 | (1) |
|
|
294 | (1) |
|
|
295 | (4) |
|
A Workflow for Deploying Infrastructure Code |
|
|
299 | (21) |
|
|
300 | (4) |
|
|
304 | (1) |
|
|
305 | (1) |
|
Submit Changes for Review |
|
|
306 | (2) |
|
|
308 | (2) |
|
|
310 | (1) |
|
|
310 | (10) |
|
|
320 | (2) |
|
|
322 | (3) |
A Recommended Reading |
|
325 | (4) |
Index |
|
329 | |