Preface |
|
xv | |
Introduction to Serverless |
|
xxi | |
|
Part I The Path to Production |
|
|
|
|
1 | (12) |
|
What Is a Distributed System? |
|
|
1 | (2) |
|
Why Do We Want a Distributed System? |
|
|
3 | (1) |
|
The Harsh Realities of Distributed Systems |
|
|
3 | (5) |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
6 | (1) |
|
|
7 | (1) |
|
|
7 | (1) |
|
What Am I Responsible For? |
|
|
8 | (1) |
|
What Do You Need to Consider When Designing a Distributed System? |
|
|
8 | (3) |
|
Loose Coupling (or Decoupling) |
|
|
9 | (1) |
|
|
9 | (1) |
|
Generating Unique (Primary) Keys |
|
|
10 | (1) |
|
|
10 | (1) |
|
|
11 | (1) |
|
|
11 | (1) |
|
|
12 | (1) |
|
|
13 | (12) |
|
Why Do You Want to Use Microservices? |
|
|
14 | (2) |
|
Improved Developer Velocity |
|
|
14 | (1) |
|
Increased Developer Freedom |
|
|
15 | (1) |
|
Issues with Microservices |
|
|
16 | (2) |
|
|
16 | (1) |
|
Proper DevOps Practices and Resources Needed |
|
|
17 | (1) |
|
Challenges with Local Development and Testing |
|
|
17 | (1) |
|
How Do You Use Microservices Effectively? |
|
|
18 | (2) |
|
|
18 | (1) |
|
|
19 | (1) |
|
How Micro Is a Microservice? |
|
|
20 | (1) |
|
Choosing Between Monoliths and Microservices |
|
|
21 | (3) |
|
When Should You Use a Monolith? |
|
|
21 | (3) |
|
When Do You Want to Use Microservices? |
|
|
24 | (1) |
|
|
24 | (1) |
|
3 Serverless Architecture and Patterns |
|
|
25 | (20) |
|
|
26 | (1) |
|
What Do You Need to Know to Be an Architect? |
|
|
27 | (1) |
|
|
27 | (4) |
|
|
28 | (1) |
|
Documenting Your Decisions |
|
|
28 | (1) |
|
How Do We Make Decisions? |
|
|
29 | (1) |
|
When Do We Make Decisions? |
|
|
30 | (1) |
|
Cloud Provider Components |
|
|
31 | (6) |
|
|
31 | (1) |
|
|
31 | (1) |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
33 | (1) |
|
|
34 | (1) |
|
|
34 | (1) |
|
|
35 | (1) |
|
|
35 | (1) |
|
|
35 | (1) |
|
|
36 | (1) |
|
|
36 | (1) |
|
Events from Your Cloud Provider |
|
|
37 | (1) |
|
|
37 | (1) |
|
|
38 | (6) |
|
Example 1 Serverless Monolith |
|
|
38 | (1) |
|
Example 2 Incoming Webhook |
|
|
39 | (1) |
|
Example 3 Using Your Cloud Provider for User Authentication |
|
|
40 | (1) |
|
Example 4 Generic Background Task Pattern |
|
|
41 | (1) |
|
Example 5 Streaming Extract, Transform, Load |
|
|
41 | (1) |
|
Example 6 Create Your Own Polling Integration |
|
|
41 | (1) |
|
Example 7 Processing Files and Images |
|
|
42 | (1) |
|
Example 8 Migration Service Pattern |
|
|
43 | (1) |
|
|
43 | (1) |
|
|
44 | (1) |
|
|
45 | (18) |
|
Interfaces: Some Assembly Required |
|
|
46 | (1) |
|
|
46 | (1) |
|
|
46 | (1) |
|
|
46 | (1) |
|
|
47 | (1) |
|
Automatic Retries and Dead Letter Queues |
|
|
47 | (1) |
|
Finite Versus Infinite Scale |
|
|
48 | (1) |
|
Designing Your Interfaces |
|
|
48 | (4) |
|
|
49 | (1) |
|
|
50 | (1) |
|
|
50 | (1) |
|
Interface Versus Implementation |
|
|
51 | (1) |
|
|
52 | (1) |
|
Designing the Unhappy Path |
|
|
52 | (3) |
|
|
53 | (1) |
|
|
53 | (2) |
|
Strategies for Integrating with Other Services |
|
|
55 | (4) |
|
|
55 | (1) |
|
|
56 | (1) |
|
|
57 | (1) |
|
|
57 | (1) |
|
Evaluating External Services |
|
|
58 | (1) |
|
|
58 | (1) |
|
|
59 | (4) |
|
|
|
5 The Serverless Framework |
|
|
63 | (22) |
|
Why Use the Serverless Framework? |
|
|
64 | (1) |
|
When the Serverless Framework Isn't for You |
|
|
65 | (2) |
|
AWS Is the Only First-Class Citizen |
|
|
66 | (1) |
|
AWS CloudFormation Is Not Perfect |
|
|
66 | (1) |
|
Relying on Strangers for Your Infrastructure |
|
|
66 | (1) |
|
What to Know Before You Start |
|
|
67 | (5) |
|
|
68 | (1) |
|
|
69 | (1) |
|
Cloud Resources and Permissions |
|
|
69 | (2) |
|
|
71 | (1) |
|
|
71 | (1) |
|
|
71 | (1) |
|
The Components of a serverless.yml File |
|
|
72 | (6) |
|
|
72 | (2) |
|
|
74 | (1) |
|
|
74 | (1) |
|
|
75 | (1) |
|
|
75 | (1) |
|
|
76 | (1) |
|
|
77 | (1) |
|
Namespacing for Sanity and Security |
|
|
77 | (1) |
|
Using the serverless Command |
|
|
78 | (4) |
|
|
78 | (1) |
|
Setting Up Serverless with Credentials |
|
|
79 | (1) |
|
Pulling in Templates Using serverless install |
|
|
79 | (1) |
|
Inspecting the Package of Our Sample Project (What's Inside) |
|
|
80 | (1) |
|
|
80 | (1) |
|
Invoking the Function, and Viewing Logs |
|
|
81 | (1) |
|
|
81 | (1) |
|
|
81 | (1) |
|
|
82 | (1) |
|
Real-World serverless.yml |
|
|
82 | (2) |
|
Setting Environment Variables |
|
|
83 | (1) |
|
|
83 | (1) |
|
|
84 | (1) |
|
6 Monitoring, Observability, and Alerting |
|
|
85 | (16) |
|
|
85 | (2) |
|
Why Do We Need Monitoring? |
|
|
86 | (1) |
|
How Does Monitoring Relate to Serverless? |
|
|
86 | (1) |
|
The On-Ramp to Automation |
|
|
87 | (1) |
|
|
87 | (2) |
|
|
88 | (1) |
|
Self-Hosted and Open Source |
|
|
88 | (1) |
|
|
89 | (7) |
|
|
89 | (4) |
|
|
93 | (1) |
|
|
94 | (1) |
|
|
95 | (1) |
|
A Selection of Advanced Practices |
|
|
96 | (4) |
|
|
96 | (1) |
|
Smoke Testing and/or Canaries |
|
|
97 | (1) |
|
The Most Important Metric in the World |
|
|
98 | (1) |
|
|
99 | (1) |
|
Cleaning Up Metrics and Alerts over Time |
|
|
100 | (1) |
|
|
100 | (1) |
|
|
101 | (14) |
|
What Does It Mean to Log? |
|
|
102 | (1) |
|
|
103 | (1) |
|
When to Rely on Logs Instead of Metrics |
|
|
104 | (1) |
|
|
104 | (2) |
|
|
106 | (1) |
|
|
107 | (4) |
|
|
108 | (1) |
|
|
109 | (1) |
|
More Effective Debugging with Logs |
|
|
109 | (1) |
|
|
110 | (1) |
|
Exception Logging (Sentry) |
|
|
110 | (1) |
|
|
111 | (1) |
|
|
111 | (1) |
|
|
112 | (1) |
|
Encrypting Logs for Privacy and Compliance |
|
|
112 | (2) |
|
Encrypt Only the Values of Sensitive Fields |
|
|
113 | (1) |
|
Encrypt the Entire Log Statement |
|
|
113 | (1) |
|
|
114 | (1) |
|
8 Changes, Automation, and Deployment Pipelines |
|
|
115 | (18) |
|
|
116 | (1) |
|
|
116 | (2) |
|
|
117 | (1) |
|
Getting Your Code Ready for Production |
|
|
118 | (1) |
|
|
119 | (1) |
|
Database Changes (Migrations) |
|
|
120 | (1) |
|
|
121 | (1) |
|
|
122 | (1) |
|
Decisions to Make Regarding Your Pipeline |
|
|
123 | (1) |
|
Canaries and Blue/Green Deployments |
|
|
123 | (2) |
|
|
124 | (1) |
|
Why Do You Need a Pipeline? |
|
|
125 | (1) |
|
Key Phases of a Deployment Pipeline |
|
|
125 | (4) |
|
|
126 | (1) |
|
|
126 | (1) |
|
|
127 | (1) |
|
Step 4 Publish the Artifact |
|
|
127 | (1) |
|
Step 5 Deploy to the Target Environment |
|
|
128 | (1) |
|
Step 6 Validate Deployment |
|
|
128 | (1) |
|
Step 7 Roll Back if Necessary (and Possible) |
|
|
128 | (1) |
|
Handling Pipeline Failures |
|
|
129 | (1) |
|
|
130 | (3) |
|
|
|
9 Security, Permissions, and Privacy |
|
|
133 | (20) |
|
Everyone Is Responsible, but You Are Especially Responsible |
|
|
134 | (1) |
|
|
135 | (4) |
|
Understanding Your Threats and Your Attackers |
|
|
136 | (1) |
|
|
137 | (2) |
|
Limit, Track, and Review All Secrets and Access |
|
|
139 | (1) |
|
|
140 | (5) |
|
|
141 | (1) |
|
|
142 | (1) |
|
|
142 | (3) |
|
Validate All User Input and Double-Check Those Settings |
|
|
145 | (6) |
|
Monitoring Your System for Anomalies |
|
|
146 | (1) |
|
|
146 | (1) |
|
Select Dependencies Carefully and Keep Your Software Up to Date |
|
|
147 | (2) |
|
Prioritize Privacy for Your Data and Your Customers' Data |
|
|
149 | (1) |
|
Don't Mess with Production |
|
|
149 | (2) |
|
|
151 | (1) |
|
|
151 | (1) |
|
|
151 | (2) |
|
10 Quality, Testing, and Staging |
|
|
153 | (16) |
|
|
154 | (3) |
|
|
155 | (1) |
|
|
156 | (1) |
|
|
157 | (7) |
|
What to Test and What Not to Test |
|
|
158 | (1) |
|
|
158 | (5) |
|
|
163 | (1) |
|
|
164 | (1) |
|
|
164 | (4) |
|
|
168 | (1) |
|
|
169 | (8) |
|
Introduction: Understand It, Even if You Don't Manage It |
|
|
169 | (1) |
|
|
170 | (2) |
|
Exercise: Finding Your Failure Points |
|
|
171 | (1) |
|
|
172 | (1) |
|
|
173 | (1) |
|
|
174 | (1) |
|
|
175 | (1) |
|
Monitor Your Cloud Provider |
|
|
175 | (1) |
|
Know Your (Service) Limits |
|
|
176 | (1) |
|
|
176 | (1) |
|
|
177 | (6) |
|
|
178 | (1) |
|
|
179 | (1) |
|
Gather the Advice of Others |
|
|
179 | (1) |
|
What to Do When You Get Stuck |
|
|
180 | (1) |
|
Taking the Next Step in Your Career |
|
|
180 | (3) |
Index |
|
183 | |