For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine.
The author and publisher have made every effort to ensure that the information in this book was correct at press time. The author and publisher do not assume and hereby disclaim any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from negligence, accident, or any other cause, or from any usage of the information herein.
Manning Publications Co.Development editor:Helen Stergius and Toni Arritola
20 Baldwin RoadTechnical development editor:John Guthrie PO Box 761Review editor:Aleksandar Dragosavljević Shelter Island, NY 11964Production editor:Deirdre S. Hiam
Copy editor:Christian Berk
Proofreader:Katie Tennant
Technical proofreader:Borko Djurkovic
Typesetter:Gordan Salinovic
Cover designer:Marija Tudor
ISBN 9781617297335
Printed in the United States of America
To Shannon
brief contents
1 ■ Introduction to AWS security1
2 ■ Identity and access management17
3 ■ Managing accounts44
4 ■ Policies and procedures for secure access55
5 ■ Securing the network: The virtual private cloud81
6 ■ Network access protection beyond the VPC112
7 ■ Protecting data in the cloud141
8 ■ Logging and audit trails173
9 ■ Continuous monitoring199
10 ■ Incident response and remediation227
11 ■ Securing a real-world application245
contents
prefacexii acknowledgmentsxiv about this bookxvi about the authorxix about the cover illustrationxx
1 Introduction to AWS security1
1.1The shared responsibility model2 What is AWS responsible for?2 ■ What are you responsible for?4
1.2Cloud-native security tools5 Identity and access management5 ■ Virtual private cloud7 And many more13
1.3A new way of operating14 Speed of infrastructure development14 ■ Shifting responsibilities15
2.2Using common patterns in AWS IAM35 AWS managed policies35 ■ Advanced patterns35
2.3Attribute-based access control with tags40 Tagged resources40 ■ Tagged principals41
3 Managing accounts44
3.1Securing access between multiple accounts44 The wall between accounts45 ■ Cross-account IAM roles47 Managing multiple accounts with AWS organizations48
3.2Integration with existing access management systems50 Integrating with Active Directory and other SAML systems50 Integrating with OpenID Connect systems51
4 Policies and procedures for secure access55
4.1Establishing best practices for IAM58 Why create best practices?59 ■ Best practices example: MFA59 Enforceable best practices60
4.2Applying least privilege access control62 Why least privilege is hard63 ■ Policy wildcards64 ■ AWS managed policies66 ■ Shared permissions (groups and managed policies)68
4.3Choosing between short- and long-lived credentials69 The risk of long-lived credentials69 ■ Trade-offs associated with credential rotation70 ■ A balance with IAM roles71
4.4Reviewing IAM permissions71
Why you should review IAM resources72 ■ Types of reviews72 Reducing the review burden77
5 Securing the network: The virtual private cloud81
5.1Working with a virtual private cloud83 VPCs84 ■ Subnets86 ■ Network interfaces and IPs87 Internet and NAT gateways89
11.5Implementing authentication and authorization end to end271
Setting up Cognito271 ■ Securing the API gateway endpoints275
index279
preface
When I first joined AWS, I knew almost nothing about security on the platform. I was fortunate to sit and talk with many of the different security teams and get an introduction to everything AWS security. I remember one of the teams I met with early on was the Automated Reasoning Group. They built several security tools based on automated reasoning, but one really stood out to me: Zelkova. At the time, you could give it two IAM policies, and it would tell if they were effectively the same or if one was more permissive (or not comparable). The tool does much more now, and powers features in S3, Config, GuardDuty, and Trusted Advisor. But even back then, it was an incredible tool. The team had many examples of IAM policies that had unexpected behavior that wasn’t obvious by just reading them. Then, they showed how you could easily identify the issues with Zelkova.
I remember being so excited after that demo that I talked about it to everyone I knew who used AWS. But instead of excitement, I mostly got questions. And not questions about Zelkova but basic questions about IAM, like “What’s a resource policy?” IAM, like a lot of security tools on AWS, is necessarily complicated. And for most people, the information on how these services work isn’t readily discoverable. Sure, there’s documentation on resource policies, but you wouldn’t know to look for it if you didn’t know that it exists. That was when I first thought about writing this book. I had been given a crash course in AWS security by learning from the people who were building all of these tools and services, and I wanted to find a way to share this information with everyone outside of the company who doesn’t have the same access.
AWS and cloud computing in general are growing nonstop, and security is such an important piece of it that I find this topic almost inescapable. Even while working at other companies that don’t use AWS for their primary infrastructure, AWS security knowledge has still come in handy. In my current role at Facebook, I review security and privacy concerns for companies we acquire, and almost all of them run on AWS. It’s getting harder and harder to find organizations that don’t use AWS in some way or another. Part of the growth of the platform is due to how fast AWS pushes out new features and services. They’re constantly improving and making it easier to build new things. But every new addition makes the platform a little more complex and makes securing it just a little bit harder. I hope the information in this book will help you to navigate that complexity and better secure the applications you run on AWS.
acknowledgments
Over the last couple years, I’ve learned how hard it is to write a book and that you can’t do it without a great deal of support from others. I’d like to thank those people who helped me get to this point.
I have to start by thanking you, my wife, Shannon. Thank you for supporting me throughout the whole process and for encouraging me whenever I felt like I couldn’t do it.
Thank you, the incredible leaders I worked for in AWS Security, who brought me into the space and helped me get started: Chris Kasprowicz, Eric Schultze, and Andrew Doane. Thank you, Ralph Flora, Yogesh Pandey, Anand Sharma, Sandeep Lagisetty, Craig Pearce, Ely Kahn, and everyone else I worked with at AWS who taught me everything I know about cloud security.
I’d also like to thank my editors at Manning: Susan Ethridge, Helen Stergius, and Toni Arritola. Thank you for everything you’ve taught me about writing. Thank you for wanting to make this a great book and for pushing to make that happen. I couldn’t have done this without all of your support. Thanks as well go to John Guthrie, the technical editor. I can’t thank you enough for all of your comments. I appreciated you being a sounding board, especially in the early chapters when I was trying to find my footing. Thank you, everyone else at Manning: Deirdre Hiam, my project editor; Christian Berk, my copyeditor; and Katie Tennant, my proofreader.
Thank you, everyone who read the manuscript while it was in progress: Alex Lucas, Amado Gramajo, Antonio Pessolano, Borko Djurkovic, Bryan Miller, Burkhard Nestmann, David Hartley, Enrico Mazzarella, Hilde Van Gysel, Ilya Sakayev, Jeremy Chen,
Jörg Discher, Jorge Ezequiel Bo, Kelly E. Hair, Michael Langdon, Peter Singhof, Sanjeev Jaiswal, Sau Fai Fong, Sébastien Portebois, Shawn P. Bolan, Thorsten Weber, Tony Mullen, Tyler Flaagan, Victor Durán, Wendell Beckwith, and Yakov Boglev. Thank you for taking the time to help shape this project. It’s a better book for all of your comments. Thank you, the MEAP readers, who posted questions and comments in the forum.
Lastly, I’d like to thank you, Dad, for getting me interested in security. I remember feeling like a spy when you would teach me how to break different substitution ciphers as a kid.
about this book
AWS Security was written to help you build more secure applications on AWS. The book covers many of the most common services you’ll likely use as well as popular thirdparty tools. It also provides resources for identifying the most common threats to an application and recommended ways of mitigating them.
Who should read this book
AWS Security is for software, DevOps, or security engineers who want to learn more about security on AWS. Software and DevOps engineers who work on AWS will learn how to better secure the applications they build and manage. Security engineers who are new to AWS will learn about the core security services and how to apply security best practices in this new environment.
How this book is organized: A roadmap
This book is divided into 11 chapters. It starts with best practices in core services, then it moves on to more general topics like threat detection and incident response. Finally, it ends with walking through a sample application using the skills learned through the book:
■ Chapter 1 discusses the shared responsibility model, describing what AWS does for you and what you have to do yourself. It also introduces several key security services and why they are important for your organization.
■ Chapter 2 dives into identity and access management (IAM), introducing roles, policies, and all of the other building blocks for managing permissions on AWS.
■ Chapter 3 builds further on IAM, looking at how permissions are handled with multiple AWS accounts and how to integrate these permissions into existing access management systems outside of AWS.
■ Chapter 4 goes into best practices for access management as well as a framework for building your own set of guidelines that fit the needs of your organization.
■ Chapter 5 talks about network security, starting with network configuration and simple firewall tools like security groups and network ACLs.
■ Chapter 6 continues to build on network security, discussing more advanced tools for managing network access.
■ Chapter 7 focuses on data security. It looks at several common data storage systems in AWS and how to protect them.
■ Chapter 8 discusses services like CloudTrail that log events in your account. This chapter talks about how to set up these kinds of logging and audit trails to aid you in identifying and responding to certain types of threats.
■ Chapter 9 looks at how to run continuous monitoring of your account for potential security issues.
■ Chapter 10 discusses incident response planning and issue remediation.
■ Chapter 11 describes a sample application, identifies the most likely threats for the application, and then details how they could be remediated.
Chapters 2, 3, and 4 all build successively on IAM and should be read in order. This is similarly true for chapters 5 and 6 on VPCs and networking. The rest of the chapters can be read out of order, with the exception of chapter 11, as it takes lessons from all the previous chapters and applies them in a real-world scenario.
About the code
This book contains many examples of source code both in numbered listings and in line with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text.
In many cases, the original source code has been reformatted; we’ve added line breaks and reworked indentation to accommodate the available page space in the book. In some cases, even this was not enough, and listings include line-continuation markers (➥). Additionally, comments in the source code have often been removed from the listings when the code is described in the text. Code annotations accompany many of the listings, highlighting important concepts.
You can get executable snippets of code from the liveBook (online) version of this book at https://livebook.manning.com/book/aws-security . The complete code for the examples in the book is available for download from the publisher’s website at https:// www.manning.com/books/aws-security, and on GitHub at https://github.com/ DylanShields/AWS-Security-Book . This repository contains the source for the code listings in all 11 chapters. Many of these code listings are either Python code or commands using the AWS command-line interface. These listings were tested using Python 3.8 and AWS CLI version 2.2.5.
liveBook discussion forum
Purchase of AWS Security includes free access to liveBook, Manning’s online reading platform. Using liveBook’s exclusive discussion features, you can attach comments to the book globally or to specific sections or paragraphs. It’s a snap to make notes for yourself, ask and answer technical questions, and receive help from the author and other users. To access the forum, go to https://livebook.manning.com/book/ aws-security/discussion. You can also learn more about Manning’s forums and the rules of conduct at https://livebook.manning.com/discussion Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking him some challenging questions lest his interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.
Other online resources
Looking for additional information?
■ Find more details about AWS security best practices and reference architectures from the AWS Architecture Center: https://aws.amazon.com/architecture/ security-identity-compliance.
■ The AWS Developer Forums are a great place to ask questions about specific AWS services: https://forums.aws.amazon.com/
about the author
DYLAN SHIELDS is an engineer who has worked in the security and privacy spaces at Amazon, Google, and Facebook. He spent several years working on external security services for AWS, including being the first engineer on AWS Security Hub.
about the cover illustration
The figure on the cover of AWS Security is “Persan,” or “A Man from Persia,” taken from a collection by Jacques Grasset de Saint-Sauveur, published in 1797. Each illustration is finely drawn and colored by hand.
In those days, it was easy to identify where people lived and what their trade or station in life was just by their dress. Manning celebrates the inventiveness and initiative of the computer business with book covers based on the rich diversity of regional culture centuries ago, brought back to life by pictures from collections such as this one.
Introduction to AWS security
This chapter covers
Understanding the shared responsibility model
Using AWS-native security services
Adapting to working in the cloud
The public cloud is growing fast, and AWS is a huge part of that. There seems to be an endless stream of blog posts and whitepapers and case studies about companies moving to AWS. I’m sure you’ve heard the common refrains about high availability, pay-for-use, and rapid development. Of all the reasons we’ve heard for moving to the cloud, the most contentious is security.
Is it really more secure to run your applications on AWS? Some people seem to think so, like Capital One CIO Rob Alexander, who believes they can “operate more securely in the public cloud than we can in our own data centers.” This is particularly powerful coming from a bank, which certainly has a lot of money riding on getting security right. And there are several other banks running workloads on AWS as well, like JPMorgan Chase and National Bank of Canada.
But then, how do we justify this with the constant news of big companies with data breaches on AWS? Among many others in 2021, there were Facebook, Dow Jones, and Uber. These are organizations with highly skilled security teams and talented engineers. Can it really be more secure to run on AWS if even these companies still have issues? I can’t tell you whether running on AWS will be more or less secure than running your own on-premises infrastructure, but I can tell you it’s different. One of the keys to a secure environment on AWS is understanding the differences and what you need to do about them. The sections in this chapter will illustrate some of the major differences and introduce you to the basic concepts of security on AWS.
1.1The shared responsibility model
Let’s start with the good news about the differences on AWS. If you run an application on AWS’s cloud, they agree to provide a certain level of security under their shared responsibility model. The shared responsibility model is an outline of what AWS provides to you in terms of security and what they expect you to do on your own. Figure 1.1 gives you a rough idea of the responsibility split.
data
Platform, applications, identity, and access management
Operating system, network, and firewall configuration
Customer
Responsible for security IN the cloud
Responsible for security OF the cloud
Client-side data Encryption and data
authentication
global infrastructure
Briefly, the shared responsibility model says that AWS manages security of the cloud, while you are responsible for security in the cloud. Let’s take a look at what that means in practice.
1.1.1What is AWS responsible for?
What exactly is AWS doing for you? Let’s start with an example. Imagine you have a simple web application like a WordPress site running on an EC2 instance. We’ll first go over some of the things that AWS is doing to secure that application that you might have had to do yourself if you were managing your own servers.
Figure 1.1The shared responsibility model
PHYSICAL AND ENVIRONMENTAL SECURITY
AWS ensures that its datacenters are safe from physical and environmental security risks. Physical access to the machine running your EC2 instance is protected by security staff; even access to the facility is strictly controlled. AWS also manages power backup systems, so your EC2 instance will not shut down in the event of a power failure. Other environmental risks to your application, like a fire or other temperature issues, are monitored by AWS with safeguards in place to prevent one of these events from affecting your host.
HOST SECURITY
Figure 1.2 shows the basic model of host virtualization that AWS uses for creating the virtual machines used in EC2.
The guest OS in the diagram is your EC2 instance. AWS operates the hardware, the host OS, and the hypervisor, and manages the security of those layers. When you run applications on virtualized hosts, there are two new attack vectors you want to be aware of. The first is an attacker gaining access to the host OS and messing with your guest OS. The second is an attacker with a guest OS on the same machine escaping its virtualized environment and gaining access to yours, often called VM escape. Preventing these kinds of attacks is entirely the responsibility of AWS.
NETWORK SECURITY
Let’s say for you want to allow SSH connections only between your EC2 instance and your home IP address for your web application. These controls are possible with VPC security groups, which we’ll discuss later in the book. While it is your responsibility to correctly configure those security groups, it is the responsibility of AWS to ensure that those controls are enforced. Once you create the controls, it is AWS’s job to make sure that no one can initiate an SSH connection to your EC2 instance that did not originate from your IP address. It’s also AWS’s responsibility to ensure the integrity of all the traffic within its network.
GENERALIZING
The example with EC2 shows how AWS’s responsibility is to secure all of the behindthe-scenes infrastructure, such as the host OS that runs your EC2 instance, and to manage the implementation of the security controls, such as by preventing certain network access to your instance. These kinds of responsibilities apply to the rest of
Figure 1.2Common virtualization model
AWS’s services as well. AWS secures the infrastructure that powers its compute, database, storage, and all other kinds of services. It also ensures that the security controls you create in services, like Identity and Access Management (IAM) and Virtual Private Cloud (VPC), are correctly enforced.
Before we start talking about what that leaves for you to secure, I want to point out that all of these things are the responsibility of AWS to secure. They are not guaranteed to be secure. To illustrate the difference, in early 2018, the Spectre and Meltdown speculative execution vulnerabilities were discovered. AWS is responsible for securing the EC2 hypervisors, but they were still vulnerable to that threat at one point. The nature of IT security is that AWS cannot guarantee you will be secure from every possible attack. But the shared responsibility model does mean it is the responsibility of AWS to protect against all of the known attacks and to protect against new attacks as soon as possible, as they did with Spectre and Meltdown.
1.1.2What are you responsible for?
In short, you are responsible for everything you do in AWS’s cloud. Continuing the example of a web application on EC2, let’s look at a couple of things you are responsible for:
Configuring access controls —You are responsible for correctly configuring the VPC security group controls mentioned earlier for restricting network access to your instance. You are also responsible for managing programmatic or AWS Console access to the EC2 service through AWS IAM. In addition to creating those controls, you also need to ensure the safety of your credentials.
Application vulnerability protection —You are responsible for protecting against vulnerabilities in the web application and any other software that runs on your EC2 instance. This ranges from patching outdated software on your host to preventing denial of service attacks on your application to removing security bugs in your web application.
In general, with any AWS service you use, you are going to be responsible for correctly utilizing the security controls offered by AWS as well as the security of any software you run on top of their services.
WHAT DOES THIS BOOK COVER?
Unfortunately, everything you ought to know to secure your applications doesn’t fit into a single book. For that reason, this book focuses on the aspects that are specific to running on AWS. Earlier, I mentioned you were responsible for protecting against denial of service attacks on your application. This book will show you how you can prevent or mitigate these kinds of attacks with VPC security group controls, network ACLs (access-control lists), or an AWS web application firewall. This book will not cover other techniques for preventing denial of service attacks, like rate limiting, that are not specific to AWS. Table 1.1 below shows some characteristic examples of what is and is not covered in this book.
Authentication
Use multi-factor authorization for IAM.
Rotate IAM user credentials often.
Logging
Record and monitor all network traffic with VPC flow logs.
Record and monitor all AWS account activity with CloudTrail.
Enforce strong customer passwords.
Utilize strong password reset mechanisms for customer accounts.
Log a complete audit trail for all high-value activity in your application.
Ensure that sensitive information is removed from logs before storage.
Broadly speaking, this book covers security concepts (e.g., vulnerabilities, attacks, and tools) that are specific to, or sufficiently different when, running on AWS.
1.2Cloud-native security tools
One of the fundamental pieces of securing your AWS resources is controlling who has access to them. AWS has built-in services for managing these access controls, and they are something you will need to familiarize yourself with. The first is IAM. The term identity and access management has a much broader meaning outside of AWS, often referring to all the tools and policies used for controlling access to technical assets. Within AWS and this book, IAM refers to the specific AWS service used for controlling access to AWS services. The other service to be familiar with is VPC. Virtual Private Cloud is a service used for creating isolated virtual networks, allowing you to control the network access to and from your resources, primarily EC2 instances and derivative compute resources.
In addition to access control tools, AWS has a large suite of services dedicated to securing your applications. These services are convenient because they can take advantage of integrations with the services you’re already using and are built specifically for workloads running on AWS. For example, AWS Key Management Service (AWS KMS) integrates with many storage and database services, like S3 and DynamoDB, to provide one-click options to enable encryption at rest. Amazon GuardDuty integrates with CloudTrail to continuously monitor all the activity on your account and alerts you when there is unauthorized or malicious behavior. These tools can help you secure your applications without much additional work.
1.2.1Identity and access management
If you’ve been using AWS, you’re probably already somewhat familiar with IAM. This section offers a quick overview of IAM and an example of it in practice. Chapters 2 through 4 will expand on IAM, covering the implementation of secure controls and policies for maintaining security, respectively. So let’s start with two of the most basic resources in IAM—the user and the policy:
Table 1.1Comparison of techniques covered and not covered in this book
User —A user is a representation of a person or application. A person or application can only access AWS services by first authenticating as an IAM user.
Policy —A policy is a JSON document that describes what actions a user can take within AWS services. For example, a policy might let a user list all of the DynamoDB tables.
We can combine these two resources to start granting access to AWS services. If we create a new IAM user named Alice, then we can attach our policy to that user, and then Alice can list the DynamoDB tables in the account. Let’s try that. First, let’s use the IAM console to create the user. From the IAM console, click on the Users tab and press the Add User button. Fill in the user name, and enable programmatic access, then do not enable AWS management console access. Do not add any groups or tags to the user at this point; we will add permissions separately. Review the settings so far, and create the user. At this point you should see a screen similar to that shown in figure 1.3. Record the access key ID and the secret access key, or download them as a file. Either way, you will not be able to view the secret access key later.
Figure 1.3Screenshot of successful IAM user creation
Set up a profile for the Alice user on the AWS CLI, using the access key ID and secret access key from before. See the appendix for instructions on setting up the AWS CLI and profiles.
Now, we can try to list the tables as Alice, using the following command:
$ aws dynamodb list-tables
You should get a response that says something like:
An error occurred (AccessDeniedException) when calling the ListTables operation: User: arn:aws:iam::123456789012:user/Alice is not authorized to perform: dynamodb:ListTables on resource: arn:aws:dynamodb:us-east1:123456789012:table/*
This policy is allowing permissions.
Listing1.1A sample IAM policy document
We were denied access; this is good. We have not yet added a policy to the Alice user that grants ListTables access. All actions in AWS are denied unless they are explicitly permitted by an IAM policy. Let’s now attach a policy to Alice that grants permission to list all tables. We’ll use the IAM console again to add this policy. In the IAM console, navigate to the Users tab and click on the Alice user. In the permissions tab, click on the Add Inline Policy link. Click on the JSON tab, and copy in the policy from the following listing. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "dynamodb:ListTables", "Resource": "*" } ] }
The allowed permission is the ListTables method from the DynamoDB service.
The ListTables action is not specific to a single resource, so we use * to refer to all resources.
Click to review the policy, and give it a name. Then, click the button to create the policy. Now, we can try to call list-tables again as Alice, and this time it should work. Use the same command again:
$ aws dynamodb list-tables
It works! After adding the policy, we are now able to use the ListTables action. The policy in listing 1.1 allows the user to do this because of the Effect, Action, and Resource values specified. Effect designates whether the policy is allowing or denying permissions. The Action value shows which AWS service call is going to be allowed or denied. In this case, the Action is the ListTables method from the DynamoDB service. The resource field determines which AWS resources this policy applies to. In listing 1.1 the policy applies to all DynamoDB tables.
This example illustrates two of the basic concepts of IAM: users and policies. Securing logical access to your AWS resources through IAM will require you to be very familiar with these concepts as well as others, like roles and managed policies. Chapter 2 will expand on these concepts to show you how to make managing IAM controls easier and more secure.
1.2.2Virtual
private cloud
In this section, we’ll go over the basics of VPCs, and then we’ll use those concepts to configure a bastion host for SSH access to your private EC2 instances.
To understand the components of VPCs, you first need to understand how AWS’s network of datacenters is organized. First, datacenters are grouped into large geographic areas, called regions. One of the largest regions is US-EAST-1, which resides in Northern Virginia. Within regions are availability zones. Availability zones, shortened as AZs, are
What is a bastion host?
A bastion host is a server that sits between a private network and the rest of the internet. The only way to access the private network from the internet is through that bastion host. It’s a good practice to use a bastion host for access to private networks to reduce your attack surface.
smaller, isolated collections of datacenters much closer together. Some AWS services operate at the AZ level, like EC2, which lets you pick which AZ to run your instance in. Other services run at the region level, like S3, letting you select in which region to store your objects. And lastly, some services are global, like IAM, with resources that are shared across all regions and AZs. The main reason for organizing it this way, as you might be able to guess from the name, is for high availability of AWS’s services. While failure of an entire datacenter is unlikely, failure of an entire AZ is even less likely, and failure of an entire region that much more improbable. Services that operate at the region and AZ levels allow you to architect your own applications for high availability, using the same concepts. For a visualization of these concepts, see figure 1.4.
Availability zoneAvailability zone
Datacenter
Datacenter
Datacenter
Datacenter
Figure 1.4Regions, availability zones, and datacenters
Datacenter
Now, back to VPCs. A VPC is a private network you can create that exists within a region. A VPC allows you to create secure network connections between AWS resources and other network resources you want to connect to, while blocking access to anything you don’t. There are various tools used to define what connections are permitted in and out of a VPC and between resources within the VPC. The primary native tools are security groups and network access control lists. We’ll explore both of these concepts later, but for right now we’ll focus on security groups. A security group is a stateful firewall that allows you to define a set of inbound and outbound rules for allowed connections. All other connections not specified will be denied. You can then apply those security group rules to an EC2 instance in a VPC by associating the instance with the security group.