Preface |
|
xi | |
Acknowledgments |
|
xiii | |
About This Book |
|
xv | |
About The Author |
|
xix | |
About The Cover Illustration |
|
xx | |
Part 1 First Steps |
|
1 | (108) |
|
1 Introducing infrastructure as code |
|
|
3 | (26) |
|
1.1 What is infrastructure? |
|
|
5 | (2) |
|
1.2 What is infrastructure as code? |
|
|
7 | (4) |
|
Manual configuration of infrastructure |
|
|
7 | (1) |
|
|
8 | (2) |
|
What is not infrastructure as code? |
|
|
10 | (1) |
|
1.3 Principles of infrastructure as code |
|
|
11 | (8) |
|
|
11 | (2) |
|
|
13 | (2) |
|
|
15 | (1) |
|
|
16 | (2) |
|
|
18 | (1) |
|
1.4 Why use infrastructure as code? |
|
|
19 | (4) |
|
|
19 | (1) |
|
Return on time investment |
|
|
20 | (1) |
|
|
21 | (1) |
|
|
22 | (1) |
|
|
23 | (6) |
|
|
23 | (2) |
|
|
25 | (1) |
|
|
26 | (1) |
|
|
27 | (2) |
|
2 Writing infrastructure as code |
|
|
29 | (26) |
|
2.1 Expressing infrastructure change |
|
|
31 | (2) |
|
2.2 Understanding immutability |
|
|
33 | (11) |
|
Remediating out-of-band changes |
|
|
35 | (2) |
|
Migrating to infrastructure as code |
|
|
37 | (7) |
|
2.3 Writing clean infrastructure as code |
|
|
44 | (11) |
|
Version control communicates context |
|
|
44 | (1) |
|
|
45 | (1) |
|
|
46 | (1) |
|
|
47 | (1) |
|
|
48 | (4) |
|
|
52 | (3) |
|
3 Patterns for infrastructure modules |
|
|
55 | (25) |
|
|
56 | (3) |
|
|
59 | (3) |
|
|
62 | (3) |
|
|
65 | (4) |
|
|
69 | (6) |
|
|
75 | (5) |
|
4 Patterns for infrastructure dependencies |
|
|
80 | (29) |
|
4.1 Unidirectional relationships |
|
|
81 | (2) |
|
|
83 | (11) |
|
|
83 | (2) |
|
|
85 | (6) |
|
Applying dependency injection |
|
|
91 | (3) |
|
|
94 | (3) |
|
|
97 | (6) |
|
|
103 | (3) |
|
|
106 | (3) |
Part 2 Scaling With Your Team |
|
109 | (112) |
|
5 Structuring and sharing modules |
|
|
111 | (23) |
|
|
112 | (13) |
|
|
112 | (5) |
|
|
117 | (3) |
|
Choosing a repository structure |
|
|
120 | (5) |
|
|
125 | (3) |
|
|
128 | (3) |
|
|
131 | (3) |
|
|
134 | (33) |
|
6.1 The infrastructure testing cycle |
|
|
136 | (4) |
|
|
137 | (1) |
|
|
138 | (1) |
|
Infrastructure testing environments |
|
|
139 | (1) |
|
|
140 | (8) |
|
Testing infrastructure configuration |
|
|
141 | (3) |
|
Testing domain-specific languages |
|
|
144 | (3) |
|
When should you write unit tests? |
|
|
147 | (1) |
|
|
148 | (3) |
|
|
151 | (6) |
|
|
151 | (3) |
|
Testing configuration for environments |
|
|
154 | (1) |
|
|
155 | (2) |
|
|
157 | (2) |
|
|
159 | (2) |
|
|
161 | (6) |
|
|
162 | (1) |
|
Configuration testing strategy |
|
|
163 | (2) |
|
|
165 | (2) |
|
7 Continuous delivery and branching models |
|
|
167 | (32) |
|
7.1 Delivering changes to production |
|
|
169 | (11) |
|
|
169 | (2) |
|
|
171 | (1) |
|
|
172 | (2) |
|
Choosing a delivery approach |
|
|
174 | (4) |
|
|
178 | (2) |
|
|
180 | (11) |
|
Feature-based development |
|
|
181 | (4) |
|
|
185 | (2) |
|
Choosing a branching model |
|
|
187 | (4) |
|
|
191 | (5) |
|
|
196 | (3) |
|
8 Security and compliance |
|
|
199 | (22) |
|
8.1 Managing access and secrets |
|
|
200 | (5) |
|
Principle of least privilege |
|
|
201 | (2) |
|
Protecting secrets in configuration |
|
|
203 | (2) |
|
8.2 Tagging infrastructure |
|
|
205 | (3) |
|
|
208 | (15) |
|
Policy engines and standards |
|
|
209 | (2) |
|
|
211 | (3) |
|
|
214 | (1) |
|
|
215 | (6) |
Part 3 Managing Production Complexity |
|
221 | (132) |
|
|
223 | (30) |
|
|
225 | (7) |
|
|
225 | (2) |
|
|
227 | (5) |
|
9.2 Blue-green deployment |
|
|
232 | (16) |
|
Deploying the green infrastructure |
|
|
234 | (1) |
|
Deploying high-level dependencies to the green infrastructure |
|
|
235 | (3) |
|
Using a canary deployment to the green infrastructure |
|
|
238 | (5) |
|
Performing regression testing |
|
|
243 | (2) |
|
Deleting the blue infrastructure |
|
|
245 | (2) |
|
Additional considerations |
|
|
247 | (1) |
|
9.3 Stateful infrastructure |
|
|
248 | (5) |
|
|
248 | (1) |
|
|
249 | (1) |
|
|
250 | (3) |
|
|
253 | (30) |
|
10.1 Minimizing the refactoring impact |
|
|
254 | (8) |
|
Reduce blast radius with rolling updates |
|
|
255 | (1) |
|
Stage refactoring with feature flags |
|
|
256 | (6) |
|
10.2 Breaking down monoliths |
|
|
262 | (21) |
|
Refactor high-level resources |
|
|
263 | (12) |
|
Refactor resources with dependencies |
|
|
275 | (5) |
|
Repeat refactoring workflow |
|
|
280 | (3) |
|
|
283 | (18) |
|
11.1 Restoring functionality |
|
|
284 | (3) |
|
Rolling forward to revert changes |
|
|
285 | (1) |
|
Rolling forward for new changes |
|
|
286 | (1) |
|
|
287 | (7) |
|
|
288 | (1) |
|
|
289 | (3) |
|
Check for differences in environments |
|
|
292 | (2) |
|
|
294 | (7) |
|
|
294 | (3) |
|
Reconcile differences in environments |
|
|
297 | (1) |
|
Implement the original change |
|
|
298 | (3) |
|
12 Cost of cloud computing |
|
|
301 | (32) |
|
|
302 | (13) |
|
Implement tests to control cost |
|
|
304 | (4) |
|
|
308 | (7) |
|
|
315 | (11) |
|
Stop untagged or unused resources |
|
|
315 | (1) |
|
Start and stop resources on a schedule |
|
|
316 | (2) |
|
Choose the correct resource type and size |
|
|
318 | (2) |
|
|
320 | (2) |
|
Set a resource expiration tag |
|
|
322 | (4) |
|
|
326 | (7) |
|
Build environments on demand |
|
|
327 | (1) |
|
|
328 | (1) |
|
Assess data transfer between regions and clouds |
|
|
329 | (1) |
|
|
330 | (3) |
|
|
333 | (20) |
|
13.1 Using open source tools and modules |
|
|
334 | (5) |
|
|
334 | (2) |
|
|
336 | (1) |
|
|
337 | (2) |
|
|
339 | (7) |
|
|
340 | (1) |
|
|
341 | (2) |
|
Breaking changes in upgrades |
|
|
343 | (3) |
|
|
346 | (3) |
|
|
346 | (1) |
|
|
347 | (2) |
|
|
349 | (4) |
Appendix A Running examples |
|
353 | (12) |
Appendix B Solutions to exercises |
|
365 | (8) |
Index |
|
373 | |