AWS SAA summary-Exam 01

 

1 Overview introduction

SAA 备考目的是为了提高职场竞争力和自我能力实现。这是对近3个月的学习所做的知识点总结,这里将基于这个图例,从外而内的剖析每个部件的功能特征,归纳总结知识点。

这是一个基础框架,很多专业的知识点未被展示在这张图中,而对于学习备考和将来的使用又是非常必要的,这里也会做对应的扩展延申总结,比如ELB, RDS, IAM, EBS, SNS, SQS等。由于报考语言选择英语,这中间有很多从sample question 中复制的解析,或者是PPT截图,均为英文版,故内容为中英混合。

clip_image002

Figure 1 Architecture overview Diagram

2 IAM

2.1 IAM overview

IAM – Identity access management, 这个功能是入门AMS将接触的第一功能。备考时,你首先要注册一个免费的AWS 账号,这就涉及IAM的功能,包含账号和角色管理,其底层依赖都是Policy。

IAM由以下部分组成:

· 用户 users

· 组 groups

· 角色 roles

· 策略 policies

clip_image004

Figure 2 IAM Structure

策略案例:

{

"Id": "Policy1547623824130",

"Version": "2012-10-17",

"Statement": [

{

"Sid": "Stmt1547623806374",

"Action": [

"s3:DeleteBucket"

],

"Effect": "Allow",

"Resource": "arn:aws:s3:::elasticbeanstalk-ap-northeast-1-609617148900",

"Principal": "*"

}

]

}

clip_image006

clip_image008

clip_image010

clip_image012

clip_image014

clip_image016

clip_image018

clip_image020 clip_image022 clip_image024 clip_image026 clip_image028 clip_image030 clip_image032

IAM的功能特性:

· IAM是全局的,不单应用于某个区域,它就是AWS的中心

· Root account只是在创建AWS账户时的一个账号,它具有全部的admin access

· 第一次创建的New user没有 permission,应当分配适当的permission (minimal)

· Permission是通过Policies来管理的,Policies是用JSON写的

· IAM 预定义了“Managed policies”

· 首次创建用户时,需要选择AWS access type,这里有2个类型供选择

o Programmatic access

§ 要分配Access key ID & secret access key. 他们不同于密码,你不能用Access key ID & secret access key登录到console,然而你可以通过AWS API, CLI, SDK, and 其他开发工具访问AWS.

§ 你只能看见一次Access key ID & secret access key,如果你丢失了他们,你需要重新生成,因此应该将他们保存在安全的地方。

o AWS Management Console access

§ Enables a password that allows users to sign-in to the AWS Management Console.

§ 需要为用户提供登录url,如:https://ganyu.signin.aws.amazon.com/console

· 总是需要为 root account 设置多因素身份认证MFA

· 你可以创建和定义自己的密码轮换策略

· 角色比存储Access key ID & secret access key在具体的EC2上更安全

· 角色很容易管理

· 创建EC2实例后,可以通过console & command line分配角色

· 角色是全局的,你可以使用在任意region

· IAM 联合(federation)

§ 大型企业通常会将自己的用户库集成到IAM中,通过这中方式,用户可以通过自己的公司凭证登录到AWS

§ 身份联合使用SAML标准 (Active directory)

IAM的 1v1 brain dump:

· 一个IAM用户对应一个自然人

· 一个角色对应一个应用程序

· 绝不能share IAM 凭证

· 绝不能把IAM 凭证写在代码中

· 不要提交你的 IAM凭证

· 除了初始设置时,永远不要使用root account

· 不要使用root account 凭证

Exam tips:

· IAM controls permissions for resource-to-resource interaction as well as user access to the AWS console. It does not provide an authentication interface or single sign-on.

· IAM only applies to permissions for users, roles, and groups and does not affect billing or cost or specific application feature accessibility.

· It does not handle hosted application permissions or relate to SNS

· IAM is not the managed service for handling MFA Delete setup on S3 buckets.

· Users, groups, roles, permissions, and similar constructs are part of IAM. Organizations and organizational units are part of AWS Organizations, a different facility.

· There are four types of policies in IAM:

identity-based

resource-based

organization SCPs

access control lists (ACLs)

· IAM policies can be attached to users, groups, and roles in the case of identity based policies, and AWS services and components via resource-based policies.

· AWS Organizations provides logical groupings and account management.

· IAM aids in scalability primarily by consolidating and centralizing management of permissions, both to AWS users and from instances to services. Use case:

o It allows assignment of permissions to users en masse via groups.

o It allows consistency in access from instances to managed AWS services across large numbers of instances.

· Power user access is a predefined policy that allows access to all AWS services with the exception of group or user management within IAM.

· The Power User group provides access to developer-related services, but not all services (like IAM).

· AWS defines and keeps updated a number of IAM policies for users, including Administrator, Billing, and Power User.

· A policy document is a collection of permissions in IAM.

· IAM users are global to an AWS account and are not region-specific.

· You should never store your application keys on an instance, in an AMI, or anywhere else permanent on the cloud. application keys are for programmatic access, not console access.

· You can only assign a single role to an instance.

· Remember that AWS provides a principle of least privilege and always wants to limit access to only what a user (or service) needs. Therefore, new IAM users do not have any access to AWS services and must be granted access to any service explicitly

You can choose from several different types of accounts when you add new users. Each type of account comes with different privileges:

  • An "administrator" has full access to the account with all permissions including account maintenance, users, billing information, and subscriptions.
  • A "power user" has similar permissions to an administrator except they can't edit or view subscriptions or other users and they do not have access to billing information.
  • A "user" is the most limited role. They can only view the account. They can't view subscriptions, other users on the account or access billing information.
  • The "no login" role essentially disables the user. They won't be able to log into the account.

2.2 IAM summary

MultiFactor Authentication

· Security token-based, 6位数字设备

· SMS text

policy

· An explicit allow overrides default deny

· 语法 Principal, action,Effect,Resource,condition

· Capability policies, Resource policies, IAM policies

Role delegation

· Identity Providers

· Amazon Cognito

· SAML

· Custom Identity broker Federation

· Cross account access

· EC2 has role, app inside can take role

2.3 WIF

WIF---Web Identity Federation, web身份联合,允许用户通过基于web的身份提供者,如Amazon,Facebook或Google,身份验证成功后,可以访问AWS的资源。身份验证成功,用户从web ID 提供者接收身份验证code,并将其转换为临时的AWS安全凭证。

Amazon Cognito 为WIF 提供了以下功能:

· 注册并登录你的应用程序 sign-up and sign-in

· 以guest身份访问

· 充当应用程序和web ID提供者之间的身份代理(identity broker),因此不需要编写任何额外代码

· 为多个设备同步用户数据

· 推荐用于所有 mobile app 的AWS 服务

Cognito 用户池

用户池是用于管理移动和web应用程序的注册和登录功能的用户目录。用户可以直接登录到用户池,或使用Amazon,Facebook或Google。Cognito充当应用程序和web ID提供者之间的中介。成功的身份验证将生成一个JSON Web令牌 JWTs。

Cognito 身份池

身份池允许提供临时的AWS凭证来访问AWS服务,如S3 或DynamoDB

clip_image034

Figure 3 Cognito in action

Cognito 用例

推荐使用Facebook等社交媒体账户的web 身份联合。

clip_image036

Figure 4 FaceBook with WIF

Cognito在应用程序和Facebook或Google之间进行代理,以提供映射到IAM角色的临时凭证,从而允许访问所需资源。不需要应用程序在设备本地嵌入或存储AWS凭证,它为用户提供跨所有移动设备的无缝体验。

Cognito追踪用户身份和他们登录的不同设备之间的联系,为你的应用程序提供无缝的用户体验,cognito使用push同步来跨多个设备推送更新和同步用户数据。当存储在云中的数据发生变化时,cognito使用SNS向所有与给定用户身份相关的设备发送通知。

clip_image038

Figure 5 Push synchronization using SNS

3 VPC

3.1 VPC concept

Amazon VPC -- Virtual private cloud允许您在 AWS 云中私有、隔离的部分创建虚拟网络环境,从中可以对私有 IP 地址范围、子网、路由表和网络网关等方面进行全面控制。借助 Amazon VPC,您可以定义虚拟网络拓扑和自定义网络配置,使其非常类似于您在自己的数据中心所操作的传统 IP 网络。使用 VPC 的一个好处在于:您可以运行面向公众的 Web 应用程序,同时仍旧在私有子网中保持非公开访问的后端服务器。您可以为 Web 服务器创建一个可以访问 Internet 的公有子网,并将后端 RDS 数据库实例置于不能访问 Internet 的私有子网中。默认情况下,一个aws账号最多可以创建5个VPC, 当然,如果业务需要,可以向aws申请创建更多VPC.

这里还需要提出另外2个概念,图中并未体现。一是区域(region),二是可用区(Availability zone)。 区域是aws在全球范围内所建立的数据中心,根据地理位置我们把某个地区的基础设施服务集合称为一个区域。通过AWS的区域,一方面可以使得AWS云服务在地理位置上更加靠近我们的用户,另一方面使得用户可以选择不同的区域存储他们的数据以满足法规遵循方面的要求。AWS的不同区域之间是相对独立的,但是它们的独立程度与区域的类别有关。根据目前10个区域的各自特点我们可以把它们分成3个不同的类别。

· 第一类是GovCloud区域,主要是服务美国的政府机构和部分美国客户。

· 第二类是中国区域,这也是一个与其他区域独立的专门服务中国客户的区域。

· 最后一类的是目前其他8个区域。这8个区域是面向所有用户的,且共享同一个账户体系,所以用户注册AWS账户后可以使用所有这8个区域的服务。

对于那些需要同时使用AWS这8个区域和AWS中国区域的用户来说,他们同时需要两个账户——一个在中国的区域使用,另一个在其他8个区域使用。

A region is an area geographically that has redundancy within it, through at least two availability zones. Each AZ is separate from other AZs and each is in essence a virtual data center. A region contains virtual data centers; it is not itself a virtual data center.

AWS的每个区域一般由多个可用区(AZ)组成,而一个可用区一般是由多个数据中心组成。AWS引入可用区设计主要是为了提升用户应用程序的高可用性。因为可用区与可用区之间在设计上是相互独立的,也就是说它们会有独立的供电、独立的网络等,这样假如一个可用区出现问题时也不会影响另外的可用区。在一个区域内,可用区与可用区之间是通过高速网络连接,从而保证有很低的延时。

VPC的组成部分:

· Virtual Private Cloud:AWS 云中逻辑隔离的虚拟网络。从所选范围内定义 VPC 的 IP 地址空间。

· 子网 subnet:VPC 的 IP 地址范围内的一个区段,其中可放置隔离的资源组。

· 互联网网关IGW:公有 Internet 连接的 Amazon VPC 端。

· NAT 网关:一款高度可用的托管网络地址转换 (NAT) 服务,便于私有子网中的资源访问互联网。

· 虚拟私有网关Virtual Private gateway VGW:VPN 连接的 Amazon VPC 端。

· 对等连接 VPC Peering:对等连接使您可以通过私有 IP 地址在两个对等 VPC 之间路由流量。

· VPC 终端节点 endpoint:支持建立从您的 VPC 到 AWS 中托管的服务的私有连接,无需使用互联网网关、VPN、网络地址转换 (NAT) 设备或防火墙代理。

· 仅传出互联网网关Egress Only Internet Gateways:有状态网关,仅提供从 VPC 到 Internet 的 IPv6 流量传出访问权限。

3.2 VPC network

对于VPC的网络划分,这里将引入子网(subnet)的概念。在一个可用区中,可以包含200个子网,而一个子网只能属于一个可用区。也就是说,子网与可用区是一对一 的,而可用区与子网是一对多的关系。开通aws账号,会默认在每个区域(3类)都创建一个default VPC,VPC可以跨同一区域的可用区。例如,在区域us-east-1中创建一个VPC,该区域中的所有可用区都能被VPC 选择使用。subnets can communicate with each other across availability zones by default.

clip_image040

Figure 6 VPC and subnet

所有子网,可以根据配置,分为公有子网和私有子网。 所谓公有子网, 是一个对世界开放的子网,只要公共子网有一个互联网网关(IGWà通过配置路由表来实现连接,那么公共子网中的任何主机实例都可以被访问;而私有子网则无此配置,只能在内部网络中使用,无法通过互联网访问,实例/主机只能在私有子网内互相通信。如果将IGW附加到私有子网,它将成为公共子网。一个私有子网将没有IGW,因此他们使用Bastion和NAT连接到互联网。

Exam tips:

· Egress-only internet gateways are stateful and support IPv6 traffic.

· An egress-only gateway is for use with IPv6 traffic and only allows outbound traffic.

· Egress always has a cost associated with it, while ingress is always free.

· Transferring data across regions is treated the same as transfers to the Internet. Only inter-AZ data transfer is guaranteed to be costless

3.3 Create VPC

这里首先介绍新创建的VPC将会获得什么样的配置,然后将其和default VPC做对比。新建VPC, 你需要指定:

· Name tagà Creates a tag with a key of 'Name' and a value that you specify.

· IPv4 CIDR BlockàThe range of IPv4 addresses for your VPC in CIDR block format, for example, 10.0.0.0/24. Block sizes must be between a /16 netmask and /28 netmask. IPv6 CIDR Block是可选的,VPC中可以没有IPv6地址段。

· The default VPC has a CIDR block of /16, but the default subnet in each AZ is a /20.

· There is no default CIDR block for custom VPCs, custom VPCs must have this entered in.

· 5 VPCs are allowed per region, per account, unless you contact AWS to raise this default limit.

· This limit is your primary CIDR block and then, in addition, 4 secondary CIDR blocks, totally 5 CIDR blocks.

clip_image042

Figure 7 Create custom VPC

对比新建一个VPC之后,可以看出,后者不只是多出一个VPC,同时还多了一个route table, Network ACLs and Security group. 这里是没有新增internet 网关的,也就是说,默认情况下,custom VPC都是私有的, 而default VPC是公有的。

clip_image044

Figure 8 Compare VPC

Exam tips:

· All VPCs have NACLs, security groups, and route tables automatically created.

· However, only the default VPC has a default subnet and an internet gateway created as well.

· A VPC cannot be changed from dedicated hosting tenancy to default hosting. You have to re-create the VPC.

3.4 VPC Peering

AWS 使用现有 VPC 基础设施创建 VPC 对等连接,既不是网关,也不是 VPN 连接,因此不依赖某个独立的实体硬件。不会发生单点通信故障或带宽瓶颈。区域间 VPC 对等连接采用当前支持 VPC 的横向扩展、冗余且高度可用的技术。区域间 VPC 对等连接流量经过具有内置冗余和动态带宽分配的 AWS 骨干网。如果区域间对等连接出现故障,流量将不会通过 Internet 路由。

VPC Peering的功能特点

· 私有地使用AWS 网络连接两个VPC

· VPC建立对等连接后,就如同在一个网络中

· 必须确保没有重叠的CIDR

· VPC Peering不能转移,即AßàBßà C, 不等同于Aßà C

· 可以和其他账户的VPC建立对等连接

· 必须在每个VPC 子网中更新路由表,确保实例间可以正常通信

clip_image046

Figure 9 VPC Peering

VPC Peering 动手实验

clip_image048

Figure 10 VPC Peering hands on

Exam tips:

· AWS calls a connection between two VPCs via peering across regions an inter-region VPC peering connection.

· AWS does not support IPv6 inter-region communication.

· EC2-Classic was a flat network that offered very little in the way of multiple options. With VPCs, you can assign multiple IP addresses as well as multiple network interfaces

3.5 Endpoints and Flow logs

3.5.1 Endpoints

Endpoints是虚拟设备,它们是可以水平伸缩的、冗余的、高可用的VPC组件,允许VPC中的实例与服务之间进行通信,而不会对网络流量造成可用性风险或带宽限制。

VPC endpoints允许你将自己的VPC 私有地连接到受支持的AWS 服务和由PrivateLink提供支持的VPC 端点服务,而不需要Internet网关、NAT 设备、VPN 连接或AWS Direct连接(云专线)。VPC中的实例不需要公网IP来与服务中的资源进行通信,你的VPC和其他服务之间的流量不会离开Amazon网络。

A VPC endpoint provides a connection over the Amazon network between your VPC and a service, such as S3. This avoids leaving the network and routing over the public Internet, which inherently provides greater security for the traffic involved; endpoint is a private connection outside of these constructs altogether, which is part of why it is an attractive solution for internal AWS communication. VPC and endpoints must in same region.

这里有两种类型的VPC endpoints:

· Interface endpoint

· Gateway endpoint

§ 当前支持Amazon S3 和DynamoDB

Interface endpoint是一个具有私有IP的弹性网络接口,该私有IP 用作指向受支持服务的流量的入口点,支持以下服务:

clip_image050

Figure 11 Supported services by Interface endpoint

针对于gateway endpoint和S3之间的动手实验:

clip_image052

Figure 12 Gateway endpoint lab

Exam tips:

· An internet gateway is required to handle Internet traffic, and a VPC endpoint is ideal for connecting the instances to S3.

· An elastic network interface is virtual and can have multiple IPv4 and IPv6 addresses as well as security groups, a MAC address, and a source/destination check flag.

· An instance has a primary network interface in all cases but can have additional network interfaces attached

· Traffic follows the network interface rather than sticking to any particular instance.

· An elastic network interface can only be attached to a single instance at one time but can be moved from one instance to another.

· An instance’s primary network interface cannot be detached. You can detach secondary interfaces, attach multiple interfaces, and move network interfaces.

3.5.2 Flow logs

Flow logs是为了捕获关于进入接口的IP流量信息,分为一下三类

· VPC flow logs

· Subnet flow logs

· ENI flow logs

Flow logs 的功能特性:

· 帮助监视和排除连接问题

· 可以转到S3 / CloudWatch logs

· 从AWS管理的接口捕获网络信息 :ELB, RDS, ElastiCache, Redshift, WorkSpaces

· 除非 peer VPC在你的账户中,否则无法为与你的VPC 建立对等连接的VPC启用 Flow logs

· 不能标记 Flow log

· 创建 flow log后,不能更改配置,例如不能将不同的IAM role与之关联

· 不是所有的IP 流量都受到监控

  • 实例与Amazon DNS服务器联系时产生的流量。如果你使用自己的DNS 服务器,则会记录到该服务器的所有流量
  • 由一个用于Amazon windows license激活的windows 实例
  • 用于实例元数据的169.254.169.254来回的流量
  • DHCP 流量
  • 传输到默认VPC路由器的保留IP地址

3.6 VPN and Direct connect

3.6.1 VPN

虚拟专用网络(VPN)的功能是:在公用网络上建立专用网络,进行加密通讯。在企业网络中有广泛应用。VPN网关通过对数据包的加密和数据包目标地址的转换实现远程访问。VPN可通过服务器、硬件、软件等多种方式实现

Site-to-Site VPN 的组成部分

· 虚拟专用网关--是 Site-to-Site VPN 连接在 Amazon 一端的 VPN 集线器。您可以创建虚拟专用网关,并将其附加到要从中创建 Site-to-Site VPN 连接的 VPC。

· AWS Transit Gateway--中转网关 是一个中转中心,您可用它来互连 Virtual Private Cloud (VPC) 和本地网络。

· 客户网关--是指 Site-to-Site VPN 连接在您这一端的实体设备或软件应用程序。

clip_image054

Figure 13 Single VPN connection

使用中转网关的单一 Site-to-Site VPN 连接

 

Figure 14 VPN with transit gatewayclip_image056

如果您有多个 AWS Site-to-Site VPN 连接,您可以使用 AWS VPN CloudHub 在各个站点之间提供安全的通信。这可使您的远程站点彼此进行通信,而不只是与 VPC 进行通信。VPN CloudHub 在简单的星型拓扑连接模型上操作,您可以在使用或不使用 VPC 的情况下操作 VPN CloudHub。这种设计适合有多间分公司和现有 Internet 连接的客户,帮助他们实施方便、潜在低成本的星型拓扑连接模型,以便在这些远程办公室之间建立主要或备用连接。

clip_image058

Figure 15 VPN CloudHub architecture

要使用 AWS VPN CloudHub,必须创建具有多个客户网关的虚拟专用网关。您必须为每个客户网关使用唯一的边界网关协议 (BGP) 自治系统编号 (ASN)。客户网关可通过它们的 Site-to-Site VPN 连接传播适当的路由(BGP 前缀)。路由通告会被每个 BGP 对等体接收并重新通告,使每个站点都可以向其他站点发送或接受数据。站点的 IP 范围不得重叠。每个站点还可以发送和从 VPC 接收数据(与使用标准 Site-to-Site VPN 连接的方式相同)。

3.6.2 Direct connect

AWS Direct Connect ,也叫云专线,通过标准的以太网光纤电缆将您的内部网络链接到 AWS Direct Connect 位置。电缆的一端接到您的路由器,另一端接到 AWS Direct Connect 路由器。有了此连接以后,您就可以创建直接连接到公有 AWS 服务(如 Amazon S3)或 Amazon VPC 的虚拟接口,从而绕过您的网络路径中的 Internet 服务提供商。AWS Direct Connect 位置在其关联的区域提供对 AWS 的访问权限。您可以使用公有区域或 AWS GovCloud (US) 中的单个连接访问所有其他公有区域中的公有 AWS 服务。

AWS Direct Connect是一种网络服务,提供了一个使用 Internet 将客户的本地站点连接到 AWS 的替代解决方案。使用 AWS Direct Connect ,以前通过 Internet 传输的数据现在可以借助 AWS 和您的数据中心或公司网络之间的私有网络连接进行传输。许多情况下,私有网络连接可以降低成本、增加带宽,提供比基于 Internet 的连接更为一致的网络体验。

以下是您用于 AWS Direct Connect 的关键组件:

· 连接-- 在 AWS Direct Connect 位置创建连接 以建立从您的本地部署到 AWS 区域的网络连接。

· 虚拟接口-- 创建虚拟接口以启用对 AWS 服务的访问。公有虚拟接口允许对公有服务的访问,如 Amazon S3。私有虚拟接口允许对您 VPC 的访问

clip_image060

Figure 16 Direct connect

AWS Direct Connect相对于VPN的联网方式,具有更高的安全性,低延迟以及稳定性,它还有以下这个特点:

  • 专线,提供到AWS骨干网的私有连接线路
  • 能够创建到AWS的私有接口或公有接口
  • 减少出口带宽的开销(入向带宽免费)
  • 始终如一的网络性能
  • 冗余连接的可选择性
  • 可以在多个AWS区域中使用
  • 多个AWS账号可以共享同一个DX线路
  • 使用BGP (Border Gateway Protocol 边界网关协议) 来交换路由
  • 通过HIPPA法案
3.6.3 Direct connect vs VPN

Type

Direct connect

VPN

Expense

昂贵的设置和需要时间配置

便宜和立即

Connection

专用私人连接

Internet

Cost

减少数据传输成本

互联网数据传输成本

Consistent

一致的性能

互联网固有的可变性

Redundancy

不提供冗余

提供冗余

Table 1 Direct connect vs VPN

3.7 NAT and Bastion host

3.7.1 NAT concept

首先阐述NAT 的概念,NAT—Network Address Translation,即是网络地址转换之意,就是替换IP报文头部的地址信息。NAT通常部署在公有子网中,通过将内部网络IP地址替换为出口的IP地址提供公网可达性和上层协议的连接能力。使用NAT的目的,是节约公网IPv4地址,当前公网IPv4地址是稀缺的,如果有大量的私有主机有Internet访问需求,则NAT是最佳解决方案。在aws cloud 上,实现NAT 有两种方式,即NAT instance 和NAT gateway,接下来将介绍二者的区别联系。

3.7.2 NAT instance vs NAT gateway

NAT instance, 创建时,需要获取一个社区版的NAT AMI, 生成并启动实例后,在实例网络设置启用disable Source/destination check,这是由于destination本身就不唯一,编辑route table,允许internet访问NAT instance。私网中也必须增加一条路由,使其关联到NAT instance,NAT instance 能支持的流量取决于实例的大小,如果使用中遇到瓶颈,请考虑增加 instance size。你可以对实例创建高可用的自动伸缩组,在不同的AZ分别创建NAT 实例,实现容灾。

clip_image062

Figure 24 NAT instance

NAT gateway,这是完全托管在aws的服务,你不需要维护其可用性,default情况下,NAT gateway就是高可用的。创建NAT gateway 时,需要关联一个EIP—Elastic IP address, 这里需要注意的是EIP是收费的,为了考试而创建的免费账号,使用EIP时需慎重,不用时及时释放掉,不然aws会按照你所占有该EIP的时间来收取费用,不管这期间你有没有使用到此功能。

clip_image064

Figure 25 NAT gateway

NAT instance和 NAT gateway区别联系:

属性

NAT gateway

NAT instance

可用性

高度可用。每个可用区中的 NAT 网关都采用冗余实施。在每个可用区中创建一个 NAT 网关可确保架构不依赖于可用区。

使用脚本管理实例之间的故障转移。

带宽

可以扩展到 45 Gbps。

取决于实例类型的带宽。

维护

由 AWS 管理。您不需要进行任何维护。

由您管理,例如您需要对实例安装软件更新或操作系统补丁。

性能

软件经过优化以便处理 NAT 流量。

配置来执行 NAT 的通用 Amazon Linux AMI。

费用

费用取决于您使用的 NAT 网关的数量、使用时长以及您通过 NAT 网关发送的数据量。

费用取决于您使用的 NAT 实例的数量、使用时长以及实例类型和大小

公有 IP 地址

在创建时选EIP 地址与 NAT 网关关联。

为 NAT 实例使用弹性 IP 地址或公有 IP 地址。您随时可以通过将新的弹性 IP 地址与实例关联来更改公有 IP 地址。

私有 IP 地址

在您创建网关时自动从子网的 IP 地址范围中选择。

在您启动实例时,从子网的 IP 地址范围内分配特定的私有 IP 地址

安全组

无法与 NAT 网关关联。您可以将安全组与 NAT 网关之后的资源关联,以控制入站和出站流量。

与您的 NAT 实例和 NAT 实例之后的资源关联,以控制入站和出站流量。

网络 ACL

使用网络 ACL 控制进出您的 NAT 网关所在子网的流量。

使用网络 ACL 控制进出您的 NAT 实例所在子网的流量。

流日志

使用Flow logs捕获流量。

使用Flow logs捕获流量。

端口转发

不支持.

手动自定义配置以支持端口转发。

堡垒服务器

不支持。

用作堡垒服务器

IP 分段

支持转发 UDP 协议的 IP 分段数据包。

不支持 TCP 和 ICMP 协议的分段。将删除这些协议的分段数据包。

支持重组 UDP、TCP 和 ICMP 协议的 IP 分段数据包。

Table 2 NAT comparison

Exam tips:

· Elastic IP addresses are specifically for avoiding being tied to a specific instance

· Elastic IP addresses are, by definition, an IP address that will not change

· NAT gateway is deployed inside a subnet and it can scale only inside that subnet. For fault tolerance, it is recommended that you deploy one NAT gateway per availability zone

3.7.3 Bastion host concept

Bastion主机是位于公共子网内的实例,通常使用SSH或RDP访问它们。

一旦使用bastion主机建立了远程连接,它就充当一个“跳转”服务器,允许您使用SSH或RDP登录到网络深处的其他实例(在私有子网中)。

clip_image066

Figure 26 Bastion host

在上图中,它给出了一个想法,在为AWS基础设施设计bastion主机时,不应该将其用于任何其他目的,因为这会打开不必要的安全漏洞。你需要尽可能地把它锁起来。我建议您考虑加强所选操作系统的安全性。安全组对于维护严格的安全性至关重要,并且在解决方案工作中扮演重要角色。

Bastion hosts的功能特性:

· 可以用Bastion hosts ssh到私有实例

· Bastion hosts在可以连接到其他私有子网的公有子网中

· 必须加强Bastion hosts 安全组

· 确保只有来自所需IP的22端口流量,而不是来自其他实例的安全组

Bastions vs NAT

· NAT 是用于提供私有子网中EC2 instance路由 internet traffic

· Bastion是用于安全地管理EC2实例,使用SSH 或RDP, 也被称作 “Jump boxes in Australia”

· A bastion 可以看作是一个NAT instance的特例

· 不能使用NAT gateway 来当作 Bastion host.

Exam tips:

· A bastion host is a publicly accessible host that allows traffic to connect to it. Then, an additional connection is made from the bastion host into a private subnet and the hosts within that subnet.

· Because the bastion must be accessed by public clients, it must be exposed to the Internet.

· The security of the bastion must be different from the hosts in the private subnet.

· The bastion host should be hardened significantly as it is public, but also accessible; this is in many ways the opposite of the security requirements of hosts within a private subnet.

3.8 NACL and Security groups

3.8.1 NACL concept

NACL—Network Access Control List,网络地址控制列表, 可以将 NACL看作是一个位于VPC内部但位于子网外部的保护。它们是一个可选的安全层,您可以在VPC中使用它们来充当防火墙。NACL由一系列规则组成,这些规则允许限制特定类型的网络流量(如http、https、ssh等) 或IP范围。您可以创建许多规则,这些规则首先根据最小的数字按数字顺序计算。一个NACL可以被分配给多个子网,但是你不能把一个子网分配给多个NACL。NACL的一个示例用例是,如果希望将对公共子网的访问限制为只访问一小组IP地址。

所有的vpc在默认情况下都有一个NACL。这个特定的NACL将默认启用来自所有IP地址的所有流量。然而,当您手动创建一个NACL时,情况正好相反。这些将在默认情况下阻塞所有流量。

缺省网络ACL:将缺省网络ACL配置为允许所有流量进出与其关联的子网。每个网络ACL还包含一个规则号为星号的规则。这个规则确保如果一个包不匹配任何其他编号的规则,它就被拒绝。您不能修改或删除此规则。

以下是网络ACL规则的组成部分:

· 规则数:从编号最低的规则开始计算规则。只要规则与流量匹配,就会应用它,而不管可能与之冲突的任何编号更高的规则。

· 类型:流量的类型;例如SSH。您还可以指定所有流量或自定义范围。

· 协议:您可以指定任何具有标准协议号的协议。有关更多信息,请参见协议编号

· 如果指定ICMP作为协议,则可以指定任何或所有ICMP类型和代码。

· 端口范围:监听端口或通信的端口范围。例如,HTTP流量为80。

· 来源:【入站规则】流量的来源(CIDR范围)。

· 目的地:[仅适用于出站规则]流量的目的地(CIDR范围)。

· 允许/拒绝:是否允许或拒绝指定的流量。

下面是一个仅支持IPv4的VPC示例缺省网络ACL。clip_image068

Figure 27 Default NACL configuration

3.8.2 Security Groups

AWS安全组(SG)作为VPC的各个EC2实例的防火墙。它们并不适用于它们所在的整个子网。创建实例时,必须将其与安全组关联。否则,将分配VPCs默认的安全组。

与NACL类似,安全组由规则组成。这些规则允许并限制基于诸如流量协议(http、https、ssh等)和指定的IP范围等内容的流量进入实例。您可以创建许多规则,这些规则首先根据最小的数字按数字顺序计算。所有VPC在默认情况下都有一个安全组。Security groups disallow all traffic unless there are specific allow rules for the traffic in the security group. Security groups evaluate all the rules on the group before deciding how to handle traffic.

3.8.3 AWS NACL vs Security group comparison

AWS的认证经常会对VPC的这两个特性进行比较。这可能是因为安全组与NACL类似。然而,它们有一些关键的区别,我将在本节中强调这些区别。

clip_image070

Table 3 Security group and NACL comparison

· 安全组在EC2实例级起作用;NACL在子网级起作用。这是最明显的区别,很可能在考试中被提到。

· NACL允许分别为入站和出站流量定义allow/deny规则;安全组只能定义应用于入站和出站的allow规则,你不能为一个规则定义不同的行为。

· 安全组是有状态的, 任何允许流入的东西都会自动允许流出;而NACL是无状态的,这意味着NACL必须允许返回流量。例如,您需要一个入站规则和一个出站规则。

· 缺省情况,SG的outbound rule是允许所有流量流出, 如果删除此规则,则从instance 主动发起的流出请求将被拒绝, 而流入的流量仍然允许流出。

· NACL规则按数值顺序计算。SG在决定是否允许通信流进入实例之前,将处理所有安全组规则。

· 最后,NACL规则适用于子网中的所有实例。因此,如果流量在NACL级别被阻塞,但在实例级别被允许。它永远不会到达实例,因为它在应用安全组规则之前就被阻塞了。

clip_image072

Figure 28 Inbound rules comparison

clip_image074

Figure 29 Outbound rules comparison

Exap tips:

· A NACL is best for dealing with all traffic at a subnet or VPC level, as it is associated at the subnet level.

· Anytime you are protecting or limiting traffic to or from specific instances, a security group is your best choice. Security groups are associated with specific instances, so they can effectively limit traffic to some instances while allowing other instances—using different security groups—to still be accessible.

· NACL rules have a rule number, a protocol, a choice of ALLOW or DENY, and a CIDR range and port or port range for inbound and outbound traffic.

· Default security groups prevent all traffic in and allow all traffic out.

· without specific outbound rules, nothing is allowed to flow out. (Note that by default, there is an allowance for all outgoing traffic in security groups, although that can be removed.)

· whether an incoming connection automatically can get back out. Security groups are stateful

· A security group can be attached to multiple constructs, like an EC2 instance, but is ultimately associated with a network interface, which in turn is attached to individual instances.

· A security group can actually have no inbound or outbound rules, so A and D are not required. A security group does require a name and description, though.

posted @ 2021-01-03 17:47  逆流的鱼2016  阅读(985)  评论(0编辑  收藏  举报