1 Overview introductionSAA 備考目的是為了提高職場競爭力和自我能力實現(xiàn)。這是對近3個月的學習所做的知識點總結,這里將基于這個圖例,從外而內(nèi)的剖析每個部件的功能特征,歸納總結知識點。 這是一個基礎框架,很多專業(yè)的知識點未被展示在這張圖中,而對于學習備考和將來的使用又是非常必要的,這里也會做對應的擴展延申總結,比如ELB, RDS, IAM, EBS, SNS, SQS等。由于報考語言選擇英語,這中間有很多從sample question 中復制的解析,或者是PPT截圖,均為英文版,故內(nèi)容為中英混合。 Figure 1 Architecture overview Diagram 2 IAM2.1 IAM overviewIAM – Identity access management, 這個功能是入門AMS將接觸的第一功能。備考時,你首先要注冊一個免費的AWS 賬號,這就涉及IAM的功能,包含賬號和角色管理,其底層依賴都是Policy。 IAM由以下部分組成: · 用戶 users · 組 groups · 角色 roles · 策略 policies 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": "*" } ] } IAM的功能特性: · IAM是全局的,不單應用于某個區(qū)域,它就是AWS的中心 · Root account只是在創(chuàng)建AWS賬戶時的一個賬號,它具有全部的admin access · 第一次創(chuàng)建的New user沒有 permission,應當分配適當?shù)膒ermission (minimal) · Permission是通過Policies來管理的,Policies是用JSON寫的 · IAM 預定義了“Managed policies” · 首次創(chuàng)建用戶時,需要選擇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 其他開發(fā)工具訪問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 · 你可以創(chuàng)建和定義自己的密碼輪換策略 · 角色比存儲Access key ID & secret access key在具體的EC2上更安全 · 角色很容易管理 · 創(chuàng)建EC2實例后,可以通過console & command line分配角色 · 角色是全局的,你可以使用在任意region · IAM 聯(lián)合(federation) § 大型企業(yè)通常會將自己的用戶庫集成到IAM中,通過這中方式,用戶可以通過自己的公司憑證登錄到AWS § 身份聯(lián)合使用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:
2.2 IAM summaryMultiFactor Authentication · Security token-based, 6位數(shù)字設備 · 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 WIFWIF---Web Identity Federation, web身份聯(lián)合,允許用戶通過基于web的身份提供者,如Amazon,F(xiàn)acebook或Google,身份驗證成功后,可以訪問AWS的資源。身份驗證成功,用戶從web ID 提供者接收身份驗證code,并將其轉(zhuǎn)換為臨時的AWS安全憑證。 Amazon Cognito 為WIF 提供了以下功能: · 注冊并登錄你的應用程序 sign-up and sign-in · 以guest身份訪問 · 充當應用程序和web ID提供者之間的身份代理(identity broker),因此不需要編寫任何額外代碼 · 為多個設備同步用戶數(shù)據(jù) · 推薦用于所有 mobile app 的AWS 服務 Cognito 用戶池 用戶池是用于管理移動和web應用程序的注冊和登錄功能的用戶目錄。用戶可以直接登錄到用戶池,或使用Amazon,F(xiàn)acebook或Google。Cognito充當應用程序和web ID提供者之間的中介。成功的身份驗證將生成一個JSON Web令牌 JWTs。 Cognito 身份池 身份池允許提供臨時的AWS憑證來訪問AWS服務,如S3 或DynamoDB Figure 3 Cognito in action Cognito 用例 推薦使用Facebook等社交媒體賬戶的web 身份聯(lián)合。 Figure 4 FaceBook with WIF Cognito在應用程序和Facebook或Google之間進行代理,以提供映射到IAM角色的臨時憑證,從而允許訪問所需資源。不需要應用程序在設備本地嵌入或存儲AWS憑證,它為用戶提供跨所有移動設備的無縫體驗。 Cognito追蹤用戶身份和他們登錄的不同設備之間的聯(lián)系,為你的應用程序提供無縫的用戶體驗,cognito使用push同步來跨多個設備推送更新和同步用戶數(shù)據(jù)。當存儲在云中的數(shù)據(jù)發(fā)生變化時,cognito使用SNS向所有與給定用戶身份相關的設備發(fā)送通知。 Figure 5 Push synchronization using SNS 3 VPC3.1 VPC conceptAmazon VPC -- Virtual private cloud允許您在 AWS 云中私有、隔離的部分創(chuàng)建虛擬網(wǎng)絡環(huán)境,從中可以對私有 IP 地址范圍、子網(wǎng)、路由表和網(wǎng)絡網(wǎng)關等方面進行全面控制。借助 Amazon VPC,您可以定義虛擬網(wǎng)絡拓撲和自定義網(wǎng)絡配置,使其非常類似于您在自己的數(shù)據(jù)中心所操作的傳統(tǒng) IP 網(wǎng)絡。使用 VPC 的一個好處在于:您可以運行面向公眾的 Web 應用程序,同時仍舊在私有子網(wǎng)中保持非公開訪問的后端服務器。您可以為 Web 服務器創(chuàng)建一個可以訪問 Internet 的公有子網(wǎng),并將后端 RDS 數(shù)據(jù)庫實例置于不能訪問 Internet 的私有子網(wǎng)中。默認情況下,一個aws賬號最多可以創(chuàng)建5個VPC, 當然,如果業(yè)務需要,可以向aws申請創(chuàng)建更多VPC. 這里還需要提出另外2個概念,圖中并未體現(xiàn)。一是區(qū)域(region),二是可用區(qū)(Availability zone)。 區(qū)域是aws在全球范圍內(nèi)所建立的數(shù)據(jù)中心,根據(jù)地理位置我們把某個地區(qū)的基礎設施服務集合稱為一個區(qū)域。通過AWS的區(qū)域,一方面可以使得AWS云服務在地理位置上更加靠近我們的用戶,另一方面使得用戶可以選擇不同的區(qū)域存儲他們的數(shù)據(jù)以滿足法規(guī)遵循方面的要求。AWS的不同區(qū)域之間是相對獨立的,但是它們的獨立程度與區(qū)域的類別有關。根據(jù)目前10個區(qū)域的各自特點我們可以把它們分成3個不同的類別。 · 第一類是GovCloud區(qū)域,主要是服務美國的政府機構和部分美國客戶。 · 第二類是中國區(qū)域,這也是一個與其他區(qū)域獨立的專門服務中國客戶的區(qū)域。 · 最后一類的是目前其他8個區(qū)域。這8個區(qū)域是面向所有用戶的,且共享同一個賬戶體系,所以用戶注冊AWS賬戶后可以使用所有這8個區(qū)域的服務。 對于那些需要同時使用AWS這8個區(qū)域和AWS中國區(qū)域的用戶來說,他們同時需要兩個賬戶——一個在中國的區(qū)域使用,另一個在其他8個區(qū)域使用。 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的每個區(qū)域一般由多個可用區(qū)(AZ)組成,而一個可用區(qū)一般是由多個數(shù)據(jù)中心組成。AWS引入可用區(qū)設計主要是為了提升用戶應用程序的高可用性。因為可用區(qū)與可用區(qū)之間在設計上是相互獨立的,也就是說它們會有獨立的供電、獨立的網(wǎng)絡等,這樣假如一個可用區(qū)出現(xiàn)問題時也不會影響另外的可用區(qū)。在一個區(qū)域內(nèi),可用區(qū)與可用區(qū)之間是通過高速網(wǎng)絡連接,從而保證有很低的延時。 VPC的組成部分: · Virtual Private Cloud:AWS 云中邏輯隔離的虛擬網(wǎng)絡。從所選范圍內(nèi)定義 VPC 的 IP 地址空間。 · 子網(wǎng) subnet:VPC 的 IP 地址范圍內(nèi)的一個區(qū)段,其中可放置隔離的資源組。 · 互聯(lián)網(wǎng)網(wǎng)關IGW:公有 Internet 連接的 Amazon VPC 端。 · NAT 網(wǎng)關:一款高度可用的托管網(wǎng)絡地址轉(zhuǎn)換 (NAT) 服務,便于私有子網(wǎng)中的資源訪問互聯(lián)網(wǎng)。 · 虛擬私有網(wǎng)關Virtual Private gateway VGW:VPN 連接的 Amazon VPC 端。 · 對等連接 VPC Peering:對等連接使您可以通過私有 IP 地址在兩個對等 VPC 之間路由流量。 · VPC 終端節(jié)點 endpoint:支持建立從您的 VPC 到 AWS 中托管的服務的私有連接,無需使用互聯(lián)網(wǎng)網(wǎng)關、VPN、網(wǎng)絡地址轉(zhuǎn)換 (NAT) 設備或防火墻代理。 · 僅傳出互聯(lián)網(wǎng)網(wǎng)關Egress Only Internet Gateways:有狀態(tài)網(wǎng)關,僅提供從 VPC 到 Internet 的 IPv6 流量傳出訪問權限。 3.2 VPC network對于VPC的網(wǎng)絡劃分,這里將引入子網(wǎng)(subnet)的概念。在一個可用區(qū)中,可以包含200個子網(wǎng),而一個子網(wǎng)只能屬于一個可用區(qū)。也就是說,子網(wǎng)與可用區(qū)是一對一 的,而可用區(qū)與子網(wǎng)是一對多的關系。開通aws賬號,會默認在每個區(qū)域(3類)都創(chuàng)建一個default VPC,VPC可以跨同一區(qū)域的可用區(qū)。例如,在區(qū)域us-east-1中創(chuàng)建一個VPC,該區(qū)域中的所有可用區(qū)都能被VPC 選擇使用。subnets can communicate with each other across availability zones by default. Figure 6 VPC and subnet 所有子網(wǎng),可以根據(jù)配置,分為公有子網(wǎng)和私有子網(wǎng)。 所謂公有子網(wǎng), 是一個對世界開放的子網(wǎng),只要公共子網(wǎng)有一個互聯(lián)網(wǎng)網(wǎng)關(IGWà通過配置路由表來實現(xiàn)連接,那么公共子網(wǎng)中的任何主機實例都可以被訪問;而私有子網(wǎng)則無此配置,只能在內(nèi)部網(wǎng)絡中使用,無法通過互聯(lián)網(wǎng)訪問,實例/主機只能在私有子網(wǎng)內(nèi)互相通信。如果將IGW附加到私有子網(wǎng),它將成為公共子網(wǎng)。一個私有子網(wǎng)將沒有IGW,因此他們使用Bastion和NAT連接到互聯(lián)網(wǎng)。 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這里首先介紹新創(chuàng)建的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. Figure 7 Create custom VPC 對比新建一個VPC之后,可以看出,后者不只是多出一個VPC,同時還多了一個route table, Network ACLs and Security group. 這里是沒有新增internet 網(wǎng)關的,也就是說,默認情況下,custom VPC都是私有的, 而default VPC是公有的。 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 PeeringAWS 使用現(xiàn)有 VPC 基礎設施創(chuàng)建 VPC 對等連接,既不是網(wǎng)關,也不是 VPN 連接,因此不依賴某個獨立的實體硬件。不會發(fā)生單點通信故障或帶寬瓶頸。區(qū)域間 VPC 對等連接采用當前支持 VPC 的橫向擴展、冗余且高度可用的技術。區(qū)域間 VPC 對等連接流量經(jīng)過具有內(nèi)置冗余和動態(tài)帶寬分配的 AWS 骨干網(wǎng)。如果區(qū)域間對等連接出現(xiàn)故障,流量將不會通過 Internet 路由。 VPC Peering的功能特點 · 私有地使用AWS 網(wǎng)絡連接兩個VPC · VPC建立對等連接后,就如同在一個網(wǎng)絡中 · 必須確保沒有重疊的CIDR · VPC Peering不能轉(zhuǎn)移,即A?àB?à C, 不等同于A?à C · 可以和其他賬戶的VPC建立對等連接 · 必須在每個VPC 子網(wǎng)中更新路由表,確保實例間可以正常通信 Figure 9 VPC Peering VPC Peering 動手實驗 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 logs3.5.1 EndpointsEndpoints是虛擬設備,它們是可以水平伸縮的、冗余的、高可用的VPC組件,允許VPC中的實例與服務之間進行通信,而不會對網(wǎng)絡流量造成可用性風險或帶寬限制。 VPC endpoints允許你將自己的VPC 私有地連接到受支持的AWS 服務和由PrivateLink提供支持的VPC 端點服務,而不需要Internet網(wǎng)關、NAT 設備、VPN 連接或AWS Direct連接(云專線)。VPC中的實例不需要公網(wǎng)IP來與服務中的資源進行通信,你的VPC和其他服務之間的流量不會離開Amazon網(wǎng)絡。 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的彈性網(wǎng)絡接口,該私有IP 用作指向受支持服務的流量的入口點,支持以下服務: Figure 11 Supported services by Interface endpoint 針對于gateway endpoint和S3之間的動手實驗: 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 logsFlow logs是為了捕獲關于進入接口的IP流量信息,分為一下三類 · VPC flow logs · Subnet flow logs · ENI flow logs Flow logs 的功能特性: · 幫助監(jiān)視和排除連接問題 · 可以轉(zhuǎn)到S3 / CloudWatch logs · 從AWS管理的接口捕獲網(wǎng)絡信息 :ELB, RDS, ElastiCache, Redshift, WorkSpaces · 除非 peer VPC在你的賬戶中,否則無法為與你的VPC 建立對等連接的VPC啟用 Flow logs · 不能標記 Flow log · 創(chuàng)建 flow log后,不能更改配置,例如不能將不同的IAM role與之關聯(lián) · 不是所有的IP 流量都受到監(jiān)控 § 實例與Amazon DNS服務器聯(lián)系時產(chǎn)生的流量。如果你使用自己的DNS 服務器,則會記錄到該服務器的所有流量 § 由一個用于Amazon windows license激活的windows 實例 § 用于實例元數(shù)據(jù)的169.254.169.254來回的流量 § DHCP 流量 § 傳輸?shù)侥JVPC路由器的保留IP地址 3.6 VPN and Direct connect3.6.1 VPN虛擬專用網(wǎng)絡(VPN)的功能是:在公用網(wǎng)絡上建立專用網(wǎng)絡,進行加密通訊。在企業(yè)網(wǎng)絡中有廣泛應用。VPN網(wǎng)關通過對數(shù)據(jù)包的加密和數(shù)據(jù)包目標地址的轉(zhuǎn)換實現(xiàn)遠程訪問。VPN可通過服務器、硬件、軟件等多種方式實現(xiàn) Site-to-Site VPN 的組成部分 · 虛擬專用網(wǎng)關--是 Site-to-Site VPN 連接在 Amazon 一端的 VPN 集線器。您可以創(chuàng)建虛擬專用網(wǎng)關,并將其附加到要從中創(chuàng)建 Site-to-Site VPN 連接的 VPC。 · AWS Transit Gateway--中轉(zhuǎn)網(wǎng)關 是一個中轉(zhuǎn)中心,您可用它來互連 Virtual Private Cloud (VPC) 和本地網(wǎng)絡。 · 客戶網(wǎng)關--是指 Site-to-Site VPN 連接在您這一端的實體設備或軟件應用程序。 Figure 13 Single VPN connection 使用中轉(zhuǎn)網(wǎng)關的單一 Site-to-Site VPN 連接 Figure 14 VPN with transit gateway 如果您有多個 AWS Site-to-Site VPN 連接,您可以使用 AWS VPN CloudHub 在各個站點之間提供安全的通信。這可使您的遠程站點彼此進行通信,而不只是與 VPC 進行通信。VPN CloudHub 在簡單的星型拓撲連接模型上操作,您可以在使用或不使用 VPC 的情況下操作 VPN CloudHub。這種設計適合有多間分公司和現(xiàn)有 Internet 連接的客戶,幫助他們實施方便、潛在低成本的星型拓撲連接模型,以便在這些遠程辦公室之間建立主要或備用連接。 Figure 15 VPN CloudHub architecture 要使用 AWS VPN CloudHub,必須創(chuàng)建具有多個客戶網(wǎng)關的虛擬專用網(wǎng)關。您必須為每個客戶網(wǎng)關使用唯一的邊界網(wǎng)關協(xié)議 (BGP) 自治系統(tǒng)編號 (ASN)??蛻艟W(wǎng)關可通過它們的 Site-to-Site VPN 連接傳播適當?shù)穆酚桑˙GP 前綴)。路由通告會被每個 BGP 對等體接收并重新通告,使每個站點都可以向其他站點發(fā)送或接受數(shù)據(jù)。站點的 IP 范圍不得重疊。每個站點還可以發(fā)送和從 VPC 接收數(shù)據(jù)(與使用標準 Site-to-Site VPN 連接的方式相同)。 3.6.2 Direct connectAWS Direct Connect ,也叫云專線,通過標準的以太網(wǎng)光纖電纜將您的內(nèi)部網(wǎng)絡鏈接到 AWS Direct Connect 位置。電纜的一端接到您的路由器,另一端接到 AWS Direct Connect 路由器。有了此連接以后,您就可以創(chuàng)建直接連接到公有 AWS 服務(如 Amazon S3)或 Amazon VPC 的虛擬接口,從而繞過您的網(wǎng)絡路徑中的 Internet 服務提供商。AWS Direct Connect 位置在其關聯(lián)的區(qū)域提供對 AWS 的訪問權限。您可以使用公有區(qū)域或 AWS GovCloud (US) 中的單個連接訪問所有其他公有區(qū)域中的公有 AWS 服務。 AWS Direct Connect是一種網(wǎng)絡服務,提供了一個使用 Internet 將客戶的本地站點連接到 AWS 的替代解決方案。使用 AWS Direct Connect ,以前通過 Internet 傳輸?shù)臄?shù)據(jù)現(xiàn)在可以借助 AWS 和您的數(shù)據(jù)中心或公司網(wǎng)絡之間的私有網(wǎng)絡連接進行傳輸。許多情況下,私有網(wǎng)絡連接可以降低成本、增加帶寬,提供比基于 Internet 的連接更為一致的網(wǎng)絡體驗。 以下是您用于 AWS Direct Connect 的關鍵組件: · 連接-- 在 AWS Direct Connect 位置創(chuàng)建連接 以建立從您的本地部署到 AWS 區(qū)域的網(wǎng)絡連接。 · 虛擬接口-- 創(chuàng)建虛擬接口以啟用對 AWS 服務的訪問。公有虛擬接口允許對公有服務的訪問,如 Amazon S3。私有虛擬接口允許對您 VPC 的訪問 Figure 16 Direct connect AWS Direct Connect相對于VPN的聯(lián)網(wǎng)方式,具有更高的安全性,低延遲以及穩(wěn)定性,它還有以下這個特點:
3.6.3 Direct connect vs VPN
Table 1 Direct connect vs VPN 3.7 NAT and Bastion host3.7.1 NAT concept首先闡述NAT 的概念,NAT—Network Address Translation,即是網(wǎng)絡地址轉(zhuǎn)換之意,就是替換IP報文頭部的地址信息。NAT通常部署在公有子網(wǎng)中,通過將內(nèi)部網(wǎng)絡IP地址替換為出口的IP地址提供公網(wǎng)可達性和上層協(xié)議的連接能力。使用NAT的目的,是節(jié)約公網(wǎng)IPv4地址,當前公網(wǎng)IPv4地址是稀缺的,如果有大量的私有主機有Internet訪問需求,則NAT是最佳解決方案。在aws cloud 上,實現(xiàn)NAT 有兩種方式,即NAT instance 和NAT gateway,接下來將介紹二者的區(qū)別聯(lián)系。 3.7.2 NAT instance vs NAT gatewayNAT instance, 創(chuàng)建時,需要獲取一個社區(qū)版的NAT AMI, 生成并啟動實例后,在實例網(wǎng)絡設置啟用disable Source/destination check,這是由于destination本身就不唯一,編輯route table,允許internet訪問NAT instance。私網(wǎng)中也必須增加一條路由,使其關聯(lián)到NAT instance,NAT instance 能支持的流量取決于實例的大小,如果使用中遇到瓶頸,請考慮增加 instance size。你可以對實例創(chuàng)建高可用的自動伸縮組,在不同的AZ分別創(chuàng)建NAT 實例,實現(xiàn)容災。 Figure 24 NAT instance NAT gateway,這是完全托管在aws的服務,你不需要維護其可用性,default情況下,NAT gateway就是高可用的。創(chuàng)建NAT gateway 時,需要關聯(lián)一個EIP—Elastic IP address, 這里需要注意的是EIP是收費的,為了考試而創(chuàng)建的免費賬號,使用EIP時需慎重,不用時及時釋放掉,不然aws會按照你所占有該EIP的時間來收取費用,不管這期間你有沒有使用到此功能。 Figure 25 NAT gateway NAT instance和 NAT gateway區(qū)別聯(lián)系:
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 conceptBastion主機是位于公共子網(wǎng)內(nèi)的實例,通常使用SSH或RDP訪問它們。 一旦使用bastion主機建立了遠程連接,它就充當一個“跳轉(zhuǎn)”服務器,允許您使用SSH或RDP登錄到網(wǎng)絡深處的其他實例(在私有子網(wǎng)中)。 Figure 26 Bastion host 在上圖中,它給出了一個想法,在為AWS基礎設施設計bastion主機時,不應該將其用于任何其他目的,因為這會打開不必要的安全漏洞。你需要盡可能地把它鎖起來。我建議您考慮加強所選操作系統(tǒng)的安全性。安全組對于維護嚴格的安全性至關重要,并且在解決方案工作中扮演重要角色。 Bastion hosts的功能特性: · 可以用Bastion hosts ssh到私有實例 · Bastion hosts在可以連接到其他私有子網(wǎng)的公有子網(wǎng)中 · 必須加強Bastion hosts 安全組 · 確保只有來自所需IP的22端口流量,而不是來自其他實例的安全組 Bastions vs NAT · NAT 是用于提供私有子網(wǎng)中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 groups3.8.1 NACL conceptNACL—Network Access Control List,網(wǎng)絡地址控制列表, 可以將 NACL看作是一個位于VPC內(nèi)部但位于子網(wǎng)外部的保護。它們是一個可選的安全層,您可以在VPC中使用它們來充當防火墻。NACL由一系列規(guī)則組成,這些規(guī)則允許限制特定類型的網(wǎng)絡流量(如http、https、ssh等) 或IP范圍。您可以創(chuàng)建許多規(guī)則,這些規(guī)則首先根據(jù)最小的數(shù)字按數(shù)字順序計算。一個NACL可以被分配給多個子網(wǎng),但是你不能把一個子網(wǎng)分配給多個NACL。NACL的一個示例用例是,如果希望將對公共子網(wǎng)的訪問限制為只訪問一小組IP地址。 所有的vpc在默認情況下都有一個NACL。這個特定的NACL將默認啟用來自所有IP地址的所有流量。然而,當您手動創(chuàng)建一個NACL時,情況正好相反。這些將在默認情況下阻塞所有流量。 缺省網(wǎng)絡ACL:將缺省網(wǎng)絡ACL配置為允許所有流量進出與其關聯(lián)的子網(wǎng)。每個網(wǎng)絡ACL還包含一個規(guī)則號為星號的規(guī)則。這個規(guī)則確保如果一個包不匹配任何其他編號的規(guī)則,它就被拒絕。您不能修改或刪除此規(guī)則。 以下是網(wǎng)絡ACL規(guī)則的組成部分: · 規(guī)則數(shù):從編號最低的規(guī)則開始計算規(guī)則。只要規(guī)則與流量匹配,就會應用它,而不管可能與之沖突的任何編號更高的規(guī)則。 · 類型:流量的類型;例如SSH。您還可以指定所有流量或自定義范圍。 · 協(xié)議:您可以指定任何具有標準協(xié)議號的協(xié)議。有關更多信息,請參見協(xié)議編號 · 如果指定ICMP作為協(xié)議,則可以指定任何或所有ICMP類型和代碼。 · 端口范圍:監(jiān)聽端口或通信的端口范圍。例如,HTTP流量為80。 · 來源:【入站規(guī)則】流量的來源(CIDR范圍)。 · 目的地:[僅適用于出站規(guī)則]流量的目的地(CIDR范圍)。 · 允許/拒絕:是否允許或拒絕指定的流量。 下面是一個僅支持IPv4的VPC示例缺省網(wǎng)絡ACL。 Figure 27 Default NACL configuration 3.8.2 Security GroupsAWS安全組(SG)作為VPC的各個EC2實例的防火墻。它們并不適用于它們所在的整個子網(wǎng)。創(chuàng)建實例時,必須將其與安全組關聯(lián)。否則,將分配VPCs默認的安全組。 與NACL類似,安全組由規(guī)則組成。這些規(guī)則允許并限制基于諸如流量協(xié)議(http、https、ssh等)和指定的IP范圍等內(nèi)容的流量進入實例。您可以創(chuàng)建許多規(guī)則,這些規(guī)則首先根據(jù)最小的數(shù)字按數(shù)字順序計算。所有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 comparisonAWS的認證經(jīng)常會對VPC的這兩個特性進行比較。這可能是因為安全組與NACL類似。然而,它們有一些關鍵的區(qū)別,我將在本節(jié)中強調(diào)這些區(qū)別。 Table 3 Security group and NACL comparison · 安全組在EC2實例級起作用;NACL在子網(wǎng)級起作用。這是最明顯的區(qū)別,很可能在考試中被提到。 · NACL允許分別為入站和出站流量定義allow/deny規(guī)則;安全組只能定義應用于入站和出站的allow規(guī)則,你不能為一個規(guī)則定義不同的行為。 · 安全組是有狀態(tài)的, 任何允許流入的東西都會自動允許流出;而NACL是無狀態(tài)的,這意味著NACL必須允許返回流量。例如,您需要一個入站規(guī)則和一個出站規(guī)則。 · 缺省情況,SG的outbound rule是允許所有流量流出, 如果刪除此規(guī)則,則從instance 主動發(fā)起的流出請求將被拒絕, 而流入的流量仍然允許流出。 · NACL規(guī)則按數(shù)值順序計算。SG在決定是否允許通信流進入實例之前,將處理所有安全組規(guī)則。 · 最后,NACL規(guī)則適用于子網(wǎng)中的所有實例。因此,如果流量在NACL級別被阻塞,但在實例級別被允許。它永遠不會到達實例,因為它在應用安全組規(guī)則之前就被阻塞了。 Figure 28 Inbound rules comparison 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. 4 EC24.1 EC2 conceptAmazon Elastic Compute Cloud (Amazon EC2) 是一種 Web 服務,在云中提供大小可調(diào)的計算容量。該服務旨在讓開發(fā)人員能更輕松地進行 Web 級的計算。All EC2 instances in the default VPC have both a public and private IP address. They do not have an elastic IP address, and the security group that is created by default does not allow any inbound traffic (until changed manually) 4.2 EC2 instance type按需實例(On-Demand Instances ) 按秒為啟動的實例付費。 · Applications with spiky workloads are reasons to use on-demand, as on-demand can scale up and down quickly · on-demand instances are best for users with no initial payment ability · On-demand instances are ideal for any usage that swings wildly in unpredictable patterns, particularly if a job cannot be halted · Anytime you’re testing a new application, on-demand is a good choice 預留實例 (Reserved Instances)以大幅折扣購買一年期到三年期的始終可用的實例。 · Reserved instances can be paid for in no up-front, partial up-front, and all up-front models, where all up-front is the least expensive and no up-front is the most expensive. · steady-state usage is ideal for reserved instances · Steady-state usage is also a use case for reserved instances, to gain cost savings · If usage is predictable, a long-running job might benefit from a reserved instance · Reserved instances are locked to the region in which they are created · AWS suggests using reserved instance pricing in TCO calculations, as it is closest to on-premises servers in an apples-to-apples comparison · Standard reserved instances often provide up to a 75% discount as compared to on-demand instances. Spot 實例 (Spot Instances)請求未使用的 EC2 實例,這可能會顯著降低您的 Amazon EC2 成本。 · Spot instances offer you significant costs savings as long as you have flexibility and application processes can be stopped and started. · Spot instances via the spot market are the potentially least expensive option, given that your compute has flexible timing and needs · Spot instances also make heavy compute affordable when it would not be on other instance types · Large and immediate additional capacity needs are best facilitated by spot instances · spot market is where you purchase spot instances, the spot market provides instances that can stop and start at any time; · Spot instances are recommended for applications with flexible start and end times, that need to run with low compute prices, or that may have urgent compute needs for large amounts of additional capacity · If the job can be stopped, then spot instances would be better. Exam tips: · Dedicated hosts can be purchased as an on-demand instance or as a reservation for significant savings · On-demand instances are ideal for any usage that swings wildly in unpredictable patterns, particularly if a job cannot be halted. If usage is predictable, a long-running job might benefit from a reserved instance, and if the job can be stopped, then spot instances would be better. 4.3 Launch new EC2 instance新建EC2實例,需要考慮VPC, 可用區(qū)(包含子網(wǎng)),安全組及放置組(placement group)。 如過EC2用于存儲,不需要對外部網(wǎng)絡提供服務,則應考慮將其放在私有網(wǎng)絡中,而如果需要對外提供服務,如web服務,則要考慮放置在公有子網(wǎng)中。如果考慮網(wǎng)絡延遲,則需要將一組同質(zhì)的EC2 實例放置一個Placement group。 這里引出一個新的概念—Placement group,即單個可用區(qū)域內(nèi)實例的邏輯分組。使用放置組時應用程序能夠參與低延遲、10 Gbps的網(wǎng)絡,放置組不能跨越多個可用區(qū)域。Cluster placement groups (the default type of placement group) must be made up of instances that exist within a single availability zone Spread Placement group-- 分散放置組有助于降低集群或?qū)嵗M中失敗的可能性。Amazon EC2擁有集群放置組,這使應用程序能夠獲得許多HPC應用程序典型的緊密耦合節(jié)點到節(jié)點通信所需的低延遲網(wǎng)絡性能?,F(xiàn)在,使用分散的放置組,成員實例將放置在不同的硬件上,從而減少了硬件故障對應用程序的影響。分散放置組能跨越多個可用區(qū)域,一個組內(nèi)的單個AZ內(nèi)最多有7個EC2實例。 A placement group is concerned primarily with network throughput and reducing latency among EC2 instances within a single availability zone. AWS does support a placement group spanning multiple AZs via spread placement groups, but unless “spread” is specifically mentioned, you should assume the question references a “normal” (or “cluster”) placement group. 比較Placement group和Spread Placement group · Placement groups are typically in a single availability zone, but now spread placement groups can be placed across availability zones. · A spread placement group can have a maximum of seven running instances per AZ. · Spread placement groups primarily offer reduced network lag between instances · Spread placement groups cannot be set up across regions · You must specify the distinct underlying hardware for spread placement groups 對于公網(wǎng)和私網(wǎng)的區(qū)分,則是以能否正常訪問internet為關鍵點。公網(wǎng)中的EC2 實例,可以自動獲取公網(wǎng)IP,能正常訪問internet。而私網(wǎng)的EC2實例,則不能分配到公網(wǎng)IP,如需訪問internet,則需要借助于公網(wǎng)中的NAT 服務,如NAT 實例或NAT 網(wǎng)關。 新建EC2 實例,需要指定AMI,獲取AMI的渠道,有以下三種:自己創(chuàng)建AMI、通過aws marketplace購買、還有是社區(qū)版AMI, 這里將包含免費的AMI.在SAA 備考階段,使用免費的AMI即可。For all new AWS accounts, 20 instances are allowed per region. However, you can increase this limit by requesting it via AWS support. Figure 17 AMI channel EC2 需要指定VPC 和subnet,如果創(chuàng)立在default VPC 中,這兩項都可以選默認配置。如果指定在custom VPC中,則需要提前創(chuàng)建subnet。默認情況下,新建的VPC中沒有subnet。 Figure 18 Put ec2 into a VPC and subnet 如果是上圖中的情況,可以單擊 Create new subnet進入創(chuàng)建subnet頁面。如下頁面,需要指定 VPC和AZ, 同時要定義CIDR 塊,此CIDR 必須隸屬于VPC的CIDR。如果定義該subnet 為public,則需要對此子網(wǎng)Enable auto-assign public IPv4 address,同時還需要配置路由表,使其關聯(lián)到IGW (Internet gateway)。而由于custom VPC 中不包含IGW,這兒仍然需要新建一個IGW, 并attach到 custom VPC. Figure 19 Create subnet 配置路由表,增加一條路由記錄, 使IGW 可以訪問internet。 Figure 20 Config route table 可以高級配置中預寫入腳本,讓實例啟動時,自動安裝服務, Figure 21 Advanced details 將實例關聯(lián)到security group,可以選擇VPC中默認創(chuàng)建的security group,也可以新建一個security group,并自定義inbound規(guī)則。這里需要在security group 的inbound中增加SSH 協(xié)議,允許 0.0.0.0/0訪問,不然則無法遠程連接到實例。接下來需要選擇已存在的key pair或生成新的key pair, 用于連接到EC2實例。實例啟動成功后,會自動分配一個公網(wǎng)IP,但由于此IP 是通過DHCP 動態(tài)分配,如果通過console reboot 實例,則該公網(wǎng)IP 會重新回到地址池而獲取到一個新的IP,通過CLI reboot,則公網(wǎng)IP可以被保持。 檢查實例是否有Internet連接,可以在登錄實例后,通過命令curl or dig任意網(wǎng)絡主機。 如果啟動的實例在私網(wǎng)中,則只能通過公網(wǎng)中的實例ssh 遠程登錄,或者使用bastion host,無法從internet上的任意主機直接登錄。私網(wǎng)中的實例也沒有正常的網(wǎng)絡訪問權限,如果需要網(wǎng)絡訪問,需要配置 NAT 實例或NAT gateway。 4.4 EC2 summaryplacement group Amazon Instance Store/EBS-backed instance security · EC2 Key Pairs · Security Groups · Connection Tracking · IAM Role Tags · billing Allocation report · Restriction · Maximum tags 10 · Maximum key length – 128 Unicode characters in UTF-8 · Maximum value length – 256 Unicode characters in UTF-8 Show · keyName = value1|value2|value3 or keyName = key1|value1;key2|value2 5 EBS and EFSEBS-- Elastic Block Store和EFS-- Elastic File System 都提供存儲服務,而對適當?shù)拇鎯x項如何做出決策。我們將比較彈性塊存儲(EBS)和彈性文件系統(tǒng)(EFS)這兩種非常流行的存儲選項,以確定哪種存儲方式最適合哪種情況。 5.1 EBS conceptAWS EBS是一個塊存儲服務,專門用于EC2實例。它為許多用例提供了高性能選項,并且可以用于各種數(shù)據(jù)庫(關系數(shù)據(jù)庫和非關系數(shù)據(jù)庫)、廣泛的應用程序和大數(shù)據(jù)分析。 EBS通過提供卷來工作,這些卷是小型網(wǎng)絡附加塊的集合,您可以將它們視為“磁盤”。卷有不同的類型,無論您需要最好的性能,需要個位數(shù)的毫秒延遲,還是您只是在尋找高吞吐量,都有一個EBS卷可以滿足您的需求。 注意,彈性塊存儲卷獨立于EC2實例,可以在任何時候進行附加和分離。當它們被掛載時,可以用作任何其他塊存儲。我們的塊存儲系列引入了EBS塊級存儲,并深入研究了兩個主要塊存儲類別:ssd支持的卷和hdd支持的卷。目前,EBS提供了四種卷類型。 · AWS EBS General Purpose SSD (gp2): A balanced volume type § Uses: boot volumes, small or medium database, dev or test env · Provisioned IOPS SSD (io1): A volume designed for latency-sensitive transactional workloads § Uses: boot volumes, critical business application, large db : Cassandra, MongoDB, SQL Sever, Oracle, PostgreSQL, MySQL · Throughput Optimized HDD (st1): A low-cost volume for frequently accessed and throughput intensive workloads § Uses: Big data, Data warehouse, Log processing · Cold HDD (sc1): A lowest-cost volume for less frequently accessed data § Uses: Inexpensive storage, ideal for infrequently accessed sequential workloads Exam tips: · HDD types are not available to use as boot volumes. · An SSD volume is best for transactional workloads with a large number of small I/O sized read/write operations. · An HDD-backed volume is best for streaming workloads where throughput needs to be maximized over IOPS. · EBS volumes can be encrypted when they are created. · There are four types of data encrypted when an EBS volume is encrypted: § data at rest on the volume, § data moving between the volume and the instance, § any snapshots created from the volume, § any volumes created from those snapshots. · If you have a larger database workload, provisioned IOPS SSD is ideal. · EBS does not offer lifecycle management · Default behavior is EBS will stop I/O to the volume if it detects potential data inconsistencies in the volume. This is to prevent data corruption. Volume status check would report this condition as Impaired. · There are couple of ways in which you change the encryption keys associated with an EBS volume: Change the key during snapshot copy process. Another option is: from an EC2 instance, mount a new EBS volume with the desired key and copy data from old volume to new volume EBS是網(wǎng)絡驅(qū)動的,通過網(wǎng)絡來和EC2實例通訊,也就意味著這兒可能會有延遲。它可以從ec2實例中分離出來,并快速地附加到另一個實例上。EBS卷被設計為非常持久的,并且在可用區(qū)(AZ)內(nèi)復制它們。然而,這意味著它們被限制在一個AZ中,因此您不能移動一個卷,除非您創(chuàng)建它的快照并在其他地方重新創(chuàng)建它。只有GP2和IO1可以用做boot 卷。 By default, EBS root volumes are terminated when the associated instance is terminated. and by default, additional EBS volumes attached to an instance are not. However, this is only the default value,these settings can be changed! You can use the AWS CLI (or the console) to set the root volume to persist after instance termination. Officially, instances can have up to 28 attachments. One of those attachments is the network interface attachment, leaving 27 attachments available for EBS volumes. However, the better approach is to remember that an instance can attach to a root volume and several more volumes (more than two); Additionally, instances cannot have unlimited attachments. 5.1.1 EBS RAID這里首先介紹一個概念,磁盤陣列(Redundant Arrays of Independent Disks,RAID),有“獨立磁盤構成的具有冗余能力的陣列”之意。 磁盤陣列是由很多塊獨立的磁盤,組合成一個容量巨大的磁盤組,利用個別磁盤提供數(shù)據(jù)所產(chǎn)生加成效果提升整個磁盤系統(tǒng)效能。利用這項技術,將數(shù)據(jù)切割成許多區(qū)段,分別存放在各個硬盤上。 EBS 已經(jīng)是冗余存儲的,但如果你要考慮增加IOPS,則需要考慮使用RAID 技術,前提是你的OS 支持 RAID. RAID 可配置選項為: · RAID0 · RAID1 · RAID5(Not recommend) · RAID6(Not recommend) 推薦使用的是RAID0—性能優(yōu)先,RAID1— 容災優(yōu)先。 Figure 22 RAID0 Figure 23 RAID1 general · attached in same AZà EBS volumes are created at AZ level · create snapshot cross AZ (any AZ in the region) · copy snapshot to another region (disaster recovery, expansion) · Root EBS volume is deleted, by default · persists independently encrypted · Public or shared snapshots of encrypted volumes are not supported · Existing unencrypted volumes cannot be encrypted directly. Can migrate from copy encripted snapshot · Supported on all Amazon EBS volume types, not instance type performence · use raid0 , raid1 improve iops · EBS optimized with IOPS EBS price · charge with storage, I/O requests and snapshot storage · EBS backed EC2, every stop/start it will be charged as a separate hour · Snapshot 5.2 EFS conceptAWS EFS是一種存儲服務,它提供了一個共享的彈性文件系統(tǒng),提供了幾乎無限的可伸縮性支持。它被設計用于Linux實例(并支持4.0和4.1網(wǎng)絡文件系統(tǒng)(NFS)協(xié)議),并且它提供了持久的、高可用的存儲,可以同時被數(shù)千臺服務器使用。AWS EFS是一個可自動伸縮的完全托管的服務。這意味著,當您向文件系統(tǒng)添加或刪除文件時,文件系統(tǒng)的大小實際上會增加或減少。 從表面上看,AWS EFS聽起來像一個簡單的服務,但是當您深入挖掘時,會發(fā)現(xiàn)它還有更多的功能。當EFS的文件系統(tǒng)的大小擴展時,它的性能也隨之擴展。這是一個有點奇怪的選擇,因此,對于低利用率,EFS的性能可能會有點令人失望。然而,如果使用得更多,AWS EFS可以提供高達10gb /s的性能,以及500,000個IOPS。 使用EFS的一個好處是您現(xiàn)有的環(huán)境不需要任何更改。您的應用程序和服務只需附加文件系統(tǒng)即可運行。EFS的使用不限于AWS云。對于那些運行混合云環(huán)境的人,AWS EFS也可以由本地實例使用。該特性極大地擴展了EFS的可能用例。 EFS最近也得到了更新,獲得了一個新的存儲層。現(xiàn)在,除了提供標準存儲之外,EFS還提供了不常用的訪問。使用它只需要啟用一個生命周期管理,它將根據(jù)所需的策略移動數(shù)據(jù)。您仍然可以正常使用EFS。您不需要對基礎設施或應用程序進行任何更改,因為EFS在幕后為您處理所有事情。與大多數(shù)AWS服務一樣,EFS只對客戶使用的內(nèi)容收費。EFS標準層存儲的成本為每月每GB 0.30美元。使用AWS EFS非頻繁訪問層存儲的成本大大降低了—每個月為每GB 0.025美元。但是,請記住,在使用這個層檢索數(shù)據(jù)時,會產(chǎn)生額外的成本(每傳輸GB 0.01美元)。 5.3 Compare EBS and EFS雖然EBS和EFS都提供了很好的特性,但這兩個存儲解決方案實際上是為兩種完全不同的用途構建的。EBS卷被限制為一個實例,更重要的是,一次只能被一個實例訪問。使用EFS,您可以有成百上千個實例同時訪問文件系統(tǒng)。這使得AWS EFS非常適合任何需要良好執(zhí)行的集中式共享存儲(如媒體處理或共享代碼存儲庫)的使用。您還可以使用AWS EFS來提供web內(nèi)容、保存各種備份并減少存儲開銷。雖然EFS的成本確實比EBS高(EFS為0.30美元/ GB, EBS為0.10美元/ GB),但您只需為每個EFS文件系統(tǒng)支付一次費用。這意味著,如果您為它附加了12個實例,您仍然需要支付與僅為它附加了一個實例相同的金額。使用EBS卷,您需要為每個卷付費。因此,為了節(jié)省存儲成本,EFS有時可以替代EBS。 EFS根據(jù)容量來衡量性能,雖然在某些情況下這可能非常有益,但它也可能是一個顯著的缺點。您可能沒有足夠高的利用率來達到所需的文件系統(tǒng)吞吐量。因為AWS EBS為您提供了穩(wěn)定且可預測的性能,所以EBS幾乎總是更適合您,除非您需要多個實例同時訪問您的存儲。 EBS is a much better choice than EFS for a single-instance application 6 AWS Storage Gateway classification網(wǎng)關類型6.1 Gateway typeAWS storage gateway is a virtual appliance and is not available as a hardware appliance. The file gateway enables you to store and retrieve objects in Amazon S3 using file protocols, such as NFS. Objects written through file gateway can be directly accessed in S3. The volume gateway provides block storage to your applications using the iSCSI protocol. Data on the volumes is stored in Amazon S3. To access your iSCSI volumes in AWS, you can take EBS snapshots which can be used to create EBS volumes. The tape gateway provides your backup application with an iSCSI virtual tape library (VTL) interface, consisting of a virtual media changer, virtual tape drives, and virtual tapes. Virtual tape data is stored in Amazon S3 or can be archived to Amazon Glacier. A tape gateway is ideal for replacing off-site tape directories. The gateway is a virtual tape directory and avoids the costs of transporting actual tapes to an expensive off-site location. 6.2 File gateway文件網(wǎng)關 – 文件網(wǎng)關 支持連接到 Amazon Simple Storage Service (Amazon S3) 的文件接口并將服務和虛擬軟件設備組合在一起。通過使用此組合,可以使用行業(yè)標準文件協(xié)議(如網(wǎng)絡文件系統(tǒng) (NFS))和服務器消息塊 (SMB) 在 Amazon S3 中存儲和檢索對象。軟件設備 (也就是網(wǎng)關) 作為運行在 VMware ESXi 或 Microsoft Hyper-V 管理程序上的虛擬機 (VM) 部署到您的本地環(huán)境中。利用網(wǎng)關,可以將 S3 中的對象作為文件或文件共享掛載點進行訪問。利用文件網(wǎng)關,您可以:
文件網(wǎng)關簡化了 Amazon S3 中的文件存儲,通過行業(yè)標準文件系統(tǒng)協(xié)議集成到現(xiàn)有應用程序中,并提供了對本地存儲的經(jīng)濟高效的替代方法。它還通過透明本地緩存提供對數(shù)據(jù)的低延遲訪問。文件網(wǎng)關管理與 AWS 之間的數(shù)據(jù)傳輸,緩沖應用程序避免網(wǎng)絡擁堵,并行優(yōu)化和流式處理數(shù)據(jù),以及管理帶寬消耗。文件網(wǎng)關與 AWS 服務集成,例如與以下服務集成:
6.3 Volume gateway卷網(wǎng)關– 卷網(wǎng)關提供了支持云的存儲卷,可以從本地應用程序服務器將該存儲卷作為 Internet 小型計算機系統(tǒng)接口 (iSCSI) 設備安裝。該網(wǎng)關支持以下卷配置:
All data is backed up to S3 asynchronously when a stored volume is used. This ensures that no lag is incurred by clients that interact with the stored volumes on-site. 6.4 Tape gateway磁帶網(wǎng)關 – 通過使用磁帶網(wǎng)關,您可以采用經(jīng)濟高效且持久的方式在 GLACIER 或 DEEP_ARCHIVE 中存檔備份數(shù)據(jù)。虛擬磁帶庫提供了虛擬磁帶基礎設施,該基礎設施可根據(jù)您的業(yè)務需求以無縫方式擴展,并可消除預配置、擴展和維護物理磁帶基礎設施的運營負擔。 您可以在本地將 AWS Storage Gateway 作為 VM 設備運行,或者在 AWS 中將其作為 Amazon Elastic Compute Cloud (Amazon EC2) 實例運行。您可以在 EC2 實例上部署網(wǎng)關,以便在 AWS 中預配置 iSCSI 存儲卷。您可以使用 EC2 實例上托管的網(wǎng)關進行災難恢復、數(shù)據(jù)鏡像以及為 Amazon EC2 上托管的應用程序提供存儲。 A storage gateway using stored volumes will store all data locally, providing low latency access to that data. Further, the entire dataset is backed up to S3 for disaster recovery. S3 is durable and available, but not as fast as accessing local data. A VTL provides a tape backup interface, but not necessarily fast data access. A tape gateway is ideal for replacing off-site tape directories. The gateway is a virtual tape directory and avoids the costs of transporting actual tapes to an expensive off-site location. 7 Route537.1 Route53 conceptAmazon Route 53 提供高可用且可擴展的域名系統(tǒng) (DNS)、域名注冊和運行狀況檢查 Web 服務。設計用于為開發(fā)人員和企業(yè)提供一種非??煽壳医?jīng)濟高效的方式,把名稱(如 example.com)轉(zhuǎn)換為計算機用于互相連接的數(shù)字 IP 地址(如 192.0.2.1),從而將最終用戶路由到 Internet 應用程序。您可以將 DNS 與運行狀況檢查服務組合使用,路由流量到運行正常的終端節(jié)點,或者獨立監(jiān)控終端節(jié)點和/或?qū)ζ涮峁┚瘓蟆D€可以購買和管理域名(例如 example.com),并自動為域配置 DNS 設置。Route 53 高效地將用戶請求連接到 AWS 中運行的基礎設施,例如 Amazon EC2 實例、Elastic Load Balancing 負載均衡器或 Amazon S3 存儲桶,還可以將用戶轉(zhuǎn)接到 AWS 外部的基礎設施。 借助 Amazon Route 53,您可以創(chuàng)建和管理公有 DNS 記錄。與電話簿相似,Route 53 可讓您管理 Internet 的 DNS 電話簿中為您的域名所列的 IP 地址。Route 53 也應答將此類特定域名轉(zhuǎn)換為對應的 IP 地址(如 192.0.2.1)的請求。您可以使用 Route 53 創(chuàng)建新域的 DNS 記錄,或轉(zhuǎn)換現(xiàn)有域的 DNS 記錄。Route 53 具有簡單的標準型 REST API,可讓您輕松創(chuàng)建、更新和管理 DNS 記錄。Route 53 還額外提供運行狀況檢查,可以監(jiān)控應用程序的運行狀況和性能,還能監(jiān)控 Web 服務器和其他資源。您還可以注冊新的域名或者將現(xiàn)有域名轉(zhuǎn)移到 Route 53 中進行管理。 Route 53 supports up to 50 domain names by default, but this limit can be raised if requested. Route 53 does support zone apex (naked) domain records. DNS是一組規(guī)則和記錄的集合,幫助客戶端了解如何通過url訪問服務器。在AWS中,最常用的記錄是: · A: URL to IPv4 · AAAA: URL to IPv6 · CNAME: URL to URL · Alias: URL to aws resource A記錄示例 Figure 30 Diagram for A record 7.2 Routing policyRoute53 可以用于你擁有或購買的公有域名,例如application.mypublicdomain.com, 也可以用于你的VPC內(nèi)實例解析的私有域名,如application1.company.internal. Route53有高級的特性,例如: · 負載均衡(通過DNS—也叫客戶端負載均衡) · 健康檢查 · 路由策略—simple, failover, geolocation, latency, weighted, multi value. 以下重點介紹路由策略。 7.2.1 Simple routing policy· 將一個域映射到一個url · 使用場景: 當需要重定向到單個資源時使用 · 不能將健康檢查附加到簡單路由策略 · 當返回多個值時,客戶端將隨機選擇一個 Figure 31 Simple routing policy 7.2.2 Weighted routing policyWRR--加權輪詢可讓您為資源記錄集合分配權重,以便指定不同回復所服務的頻率。您可能希望使用此功能來執(zhí)行 A/B 測試,發(fā)送一小部分流量到進行了軟件更改的服務器。例如,假設您向一個 DNS 名稱關聯(lián)了兩個記錄集合,其中一個的權重為 3,另一個的權重為 1。此情形中,75% 時間內(nèi) Route 53 將返回權重為 3 的記錄集合,25% 時間內(nèi) Route 53 將返回權重為 1 的記錄集合。權重可以是 0 到 255 范圍內(nèi)的任意數(shù)字。 Figure 32 WRR Policy 7.2.3 Latency routing policyLBR(基于延遲的路由)是 Amazon Route 53 的一項新功能,有助于您提高應用程序?qū)θ蚴鼙姷男阅堋D梢栽诙鄠€ AWS 地區(qū)運行應用程序,Amazon Route 53 則通過其遍布全球的節(jié)點將最終用戶路由到可提供最低延遲性的 AWS 地區(qū)。 只需通過 AWS 管理控制臺或簡單的 API,就能快速而輕松地使用 Amazon Route 53 的全新 LBR 功能。只需創(chuàng)建包含 IP 地址或各個 AWS 終端節(jié)點的 ELB 名稱的記錄集合,再將該集合標記為支持 LBR 的記錄集合,這與將記錄集合標記為加權記錄集合非常相似。Amazon Route 53 將負責其余的工作 – 為各個請求確定最佳的終端節(jié)點并相應地路由最終用戶,與 Amazon CloudFront 這一 Amazon 全球內(nèi)容傳輸服務非常相似。 LBR特性: · 重定向到延遲最少的服務器 · 當用戶延遲是一個優(yōu)先級時超級有用 · 延遲是基于用戶設計的AWS區(qū)域來評估的 · 如果是延遲最低的,那么德國用戶的請求可能會重定向到美國 7.2.4 Geolocation地理定位-- Route 53 Geo DNS 會根據(jù)請求發(fā)出的地理位置將其送至特定的終端節(jié)點,以此幫助調(diào)整負載平衡。Geo DNS 可以自定義本地化的內(nèi)容,例如以正確的語言展示詳情頁面或限制將內(nèi)容分配到已授權的市場。Geo DNS 通過一種可以預見而又易于管理的方式讓您實現(xiàn)負載平衡,確保每一個終端用戶地點始終路由到相同的終端節(jié)點。Geo DNS 提供三種地理粒度級別:洲、國家/地區(qū)和州/省,Geo DNS 還提供全球記錄,當終端用戶的地點與您創(chuàng)建的特定 Geo DNS 記錄不匹配時,全球記錄可在這種情況下發(fā)揮作用。您還可以將 Geo DNS 與其他路由類型(例如基于延遲的路由和 DNS 故障轉(zhuǎn)移)進行組合,以實現(xiàn)多種低延遲的容錯架構。 Geoproximity policy: 地理鄰近性,這個策略在當前的route53中看不到了,但是在考試中仍然可能會出現(xiàn),這和Geolocation類似。 7.2.5 Multi value answer routing policyRoute 53 現(xiàn)在支持使用多值回答響應 DNS 查詢。在 DNS 查詢響應中返回多個可檢查運行狀況的 IP 地址這一功能并非負載均衡器的替代,這是使用 DNS 提高可用性和負載均衡能力的一種方式。如果您希望將流量隨機路由到多個資源 (如 Web 服務器),您可以為每個資源創(chuàng)建一條多值回答記錄,然后選擇性地將 Amazon Route 53 運行狀況檢查與每條記錄關聯(lián)。Amazon Route 53 最多支持使用八條正常記錄響應每條 DNS 查詢。 7.2.6 Failover routing policy當您希望創(chuàng)建主動/被動設置時,將使用故障轉(zhuǎn)移路由策略。 例如,你想把你的主站點放在us-west-2,而從DR 站點在AP-Southeast-2。Route53將使用健康檢查檢查你的主站點健康情況,一旦發(fā)現(xiàn)主站點丟失,就會將流量路由轉(zhuǎn)發(fā)到從站點上。 Figure 33 Failover routing 7.3 CNAME vs AliasCNAME: · 將一個url指向任何其他url. Application.mypublic.comàblabla.anything.com · 只能用于非頂點域名 Alias: · 將一個url指向AWS 資源。Application.mypublic.comàblabla. · 可以用于頂點域名和非頂點域名 · 免費 · 本地健康檢查
Table 4 CNAME vs Alias Exam tips: · A simple routing policy allows single and multiple resources for both the primary and secondary resources. Weighted policies do honor health checks ,and weight numbers do not affect health checks. 8 S3-- Simple storage serviceAmazon S3--Simple storage service, 是一種對象存儲,專為從 Internet 上的任意位置存儲和檢索任意數(shù)量的數(shù)據(jù)而構建。它是一種簡單的存儲服務,以非常低的成本提供極其持久、高度可用并可無限擴展的數(shù)據(jù)存儲基礎設施。您可以存儲的總數(shù)據(jù)容量和對象個數(shù)不受限制。各個 Amazon S3 對象的大小范圍可以從最小 0 字節(jié)到最大 5TB??稍趩蝹€ PUT 中上傳的最大數(shù)據(jù)對象為 5 GB。對于大于 100MB 的數(shù)據(jù)對象,客戶應該考慮使用分段上傳功能。 Amazon S3 提供一系列適合不同使用案例的存儲類。這包括 S3 標準(適用于頻繁訪問的數(shù)據(jù)的通用存儲);S3 智能分層(適用于具有未知或變化的訪問模式的數(shù)據(jù));S3 標準 - 不頻繁訪問(S3 標準 - IA)和 S3 單區(qū) - 不頻繁訪問(S3 單區(qū) - IA),適用于長期存在、但訪問不太頻繁的數(shù)據(jù);以及 Amazon S3 Glacier (S3 Glacier) 和 Amazon S3 Glacier 深度存檔(S3 Glacier 深度存檔),適用于長期存檔和數(shù)字保留。 Exam tips: · While S3 does use availability zones to store objects in buckets, you do not choose the availability zone yourself. Even S3 One Zone-IA does not allow you to specify the AZ for use. By default, all AWS accounts can create up to 100 buckets. However, this limit can easily be raised by AWS if you request an upgrade. · Multipart Upload is ideal for large objects on stable networks. But it also helps handle less-reliable networks as smaller parts can fail while others get through, reducing the overall failure rate. · All S3 and S3-IA data is stored in a single region and within at least three availability zones within that region · The problem here is trying to tag individual folders. You can use IAM for permissions, but a particular folder cannot be tagged separately from other folders; only an entire bucket can be tagged. · This is important because it reflects a recent change by AWS. Until 2018, there was a hard limit on S3 of 100 PUTs per second, but that limit has now been raised to 3500 PUTs per second. 8.1 S3 features· S3是基于對象的存儲,允許你上傳文件 · object文件大小可以從0B 到5T · 沒有存儲限制 · 對于大于 100MB 的數(shù)據(jù)對象,客戶應該考慮使用分段上傳功能。 · 文件存儲在buckets中 · S3使用全局的命名空間,也就是說名字必須是全局唯一的 · Bucket是在region level定義的 · 不適合于安裝OS · 成功上傳文件后將會生成 HTTP 200狀態(tài)碼 · Permissions § User based policiesà roles (IAM) § Resource based policies § Bucket Policies § Access control lists · Bucket ACL · Object ACL · 缺省條件下,所有新建的bucket都是PRIVATE,你可以配置訪問控制 · S3可以配置創(chuàng)建訪問日志,記錄所有訪問S3 Bucket的請求。這個log可以發(fā)送到其他bucket,即使是屬于其他賬號的bucket也可以。 · cross-origin requests § not support https custom domain · Request Authorization § Permission Delegation § Operation Authorization · Lifecycle Management § Transition § Expiration · price § request + storage + data transfer · Versioning enable 后不能被disable, 只能被suspended · 任何文件,在啟動Versioning 前,version 均為 “null” s3是基于對象的,你可以把對象簡單考慮為文件,以下是對象的組成部分: § Key: 這簡單的指object 名字 § Value :這是簡單的數(shù)據(jù),由一個字節(jié)序列組成 § Version ID: 這對versioning 來說很重要 § Metadata: 有關您正在存儲的數(shù)據(jù)的數(shù)據(jù) § Subresources § Access control lists § Torrent S3提供了兩種數(shù)據(jù)一致性模式 § Read after write consistency for PUTS of new objectsà new object can be read immediately § Eventual consistency for overwrite PUTS and DELETES (can take some time to propagate) § Stale read possible after updates and deletes (until change is fully propagated) § Lowest read latency § Highest read throughput Bucket 命名規(guī)則: § 不含大寫字母 § 不含下劃線 § 3-63個字符長度 § 沒有IP § 必須以小寫字母或數(shù)字開頭 By default, newly created S3 buckets are private. They can only be accessed by a user that has been granted explicit access. 8.2 S3 replication8.3 S3 use cases and comparison8.3.1 S3 use cases§ S3 standard: 冗余地存儲在多個設備中的多個設備上,旨在同時承受兩個設備的損失 § S3-Intelligent tier: 設計用于成本優(yōu)化,通過自動將數(shù)據(jù)移動到最具成本效益的訪問層,而不影響性能或操作開銷層 § S3-IA: 對于不頻繁訪問的數(shù)據(jù),但需要時可以快速訪問。 費用比S3 標準低,但將會產(chǎn)生檢索費用 § S3 One zone – IA : 對于不頻繁訪問而又追求低成本存儲的數(shù)據(jù),不要求多AZ 恢復 § S3 Glacier: 是一種安全,持久且低成本的數(shù)據(jù)歸檔存儲,檢索時間從幾分鐘到數(shù)小時 § S3 Glacier deep Archive: 這是S3 最低成本的存儲,但檢索時間12小時則是可接受的 8.3.2 S3 comparison所有的S3存儲類型,都具有相同的持久性,即 11 9s??荚囍谐?键c是在可用性和SLA的區(qū)別。 Table 5 S3 comparison 8.4 S3 encryption for objects在S3中,有4種方法來對object進行加密,考試中要重點了解那種方法適用于那種場景。 § SSE-S3: 使用aws 處理和管理的密鑰來加密S3 object § SSE-KMS: S3利用指定的aws KMS 來管理密鑰 § SSE-C: S3 使用用戶每次請求提供密鑰 § 客戶端加密 In general, SSE-S3 is the “starter” option for encryption. It’s by no means a simple or amateur approach to security, but it is low cost compared to KMS and has much less overhead than client-side or SSE-C encryption keys. SSE-S3—Object是在server 端進行加密的,使用AES-256加密類型,header 必須設置為: “x-amz-server-side-encryption”: “AES256” 。使用此方法加密,其可靠性低,因為數(shù)據(jù)被檢索后會自動解密,無論是合法還是非法的檢索。 Figure 34 SSE-S3 SSE-KMS –> KMS的優(yōu)勢是用戶控制和審計追蹤,當題干中有audit出現(xiàn),則應考慮的加密方式即為 SSE-KMS。Object是在server 端進行加密的,header 必須設置為: “x-amz-server-side-encryption”: “aws:kms” Figure 35 SSE-KMS SSE-Cà Object還是在server 端進行加密,但使用完全由客戶在AWS外部管理的數(shù)據(jù)密鑰,S3中保存用戶的加密密鑰。其他幾種加密方式,傳輸時都是http 或https可選。但SSE-C必須使用https進行傳輸,且每個http請求都必須在header中提供加密密鑰。 Figure 36 SSE-C Client side encryption: § 客戶端庫,如amazon s3加密客戶端 § 數(shù)據(jù)發(fā)送到S3前,客戶端必須自己先加密 § 當從S3檢索數(shù)據(jù)時,客戶端必須自己解密 § 客戶完全管理密鑰和加密周期 For client-side encryption, you’ll need a master key, which can either be a KMSmanaged key or a client-side master key. You’ll also need an SDK for encrypting the client-side data Figure 37 Client side encryption 8.5 S3 Websitess3可以托管靜態(tài)網(wǎng)站并在Internet上訪問它們,網(wǎng)站的url有2中形式: § <bucket-name>.s3-website-<AWS-region>. § Or § <bucket-name>.s3-website.<AWS-region>. 如:http:// mybucket.s3-website.eu-west-2. 如果訪問時得到403錯誤碼,請確保 bucket policies是允許公網(wǎng)讀取的。 This is a matter of carefully looking at each URL. Bucket names—when not used as a website—always come after the fully qualified domain name (FQDN); in other words, after the forward slash. Where website hosting is concerned, the bucket name is part of the FQDN; where direct bucket access is concerned, the bucket name comes after the FQDN. This is an essential distinction. you need to recall that the s3-website portion of the FQDN is always connected to the region; in other words, it is not a subdomain. S3 supports two styles of bucket URLs: virtual-hosted-style and path-style URLs. Virtual-hosted-style URLs are of the form http://bucket.s3-aws-region ., and path-style URLs are the traditional URLs you’ve seen: https://s3-aws-region./bucket-name. https://ytmProfilePictures.s3-website-us-east-2./images S3 buckets have names based upon the S3 identifier (s3), the region (us-east-1 in this case), and the domain. Then, the bucket name appears after the domain. That results in a URL like https://s3-us-east-1./ prototypeBucket32. However, buckets in US East are a special case and should use the special, unique endpoint s3. Only the root account can enable MFA Delete. Even the console user that created the bucket—if it isn’t the root user—cannot enable MFA Delete on a bucket. Object URL https://myawssaatest01.s3./versioning+test.txt Figure 38 Object not public S3 CORS à Cross-Origin Resource Sharing 如果你請求的數(shù)據(jù)來自另一個S3 bucket, 你就需要enable CORS, CORS允許您限制可以在s3中請求文件的網(wǎng)站的數(shù)量,并限制您的成本。常見的考試場景如下圖: Figure 39 CORS case 8.6 S3 lifecycle managementDefine rules based on: § Object age § Current and previous version Filter based on: § Prefix (images/, logs/) § Object tags (name= PHI) 9 Database9.1 Database overview introduction數(shù)據(jù)庫是“按照數(shù)據(jù)結構來組織、存儲和管理數(shù)據(jù)的倉庫”。是一個長期存儲在計算機內(nèi)的、有組織的、可共享的、統(tǒng)一管理的大量數(shù)據(jù)的集合。數(shù)據(jù)庫是以一定方式儲存在一起、能與多個用戶共享、具有盡可能小的冗余度、與應用程序彼此獨立的數(shù)據(jù)集合,可視為電子化的文件柜——存儲電子文件的處所,用戶可以對文件中的數(shù)據(jù)進行新增、查詢、更新、刪除等操作。 數(shù)據(jù)庫的分類,從大的方面來看,分為兩大類,即關系型數(shù)據(jù)庫(SQL)和非關系型數(shù)據(jù)庫(NoSQL)。 關系型數(shù)據(jù)庫,存儲的格式可以直觀地反映實體間的關系。關系型數(shù)據(jù)庫和常見的表格比較相似,關系型數(shù)據(jù)庫中表與表之間是有很多復雜的關聯(lián)關系的。 常見的關系型數(shù)據(jù)庫有MySQL、MariaDB、Oracle、Aurora、SQL Server 或 PostgreSQL等。在輕量或者小型的應用中,使用不同的關系型數(shù)據(jù)庫對系統(tǒng)的性能影響不大,但是在構建大型應用時,則需要根據(jù)應用的業(yè)務需求和性能需求,選擇合適的關系型數(shù)據(jù)庫。 隨著近些年技術方向的不斷拓展,大量的NoSql數(shù)據(jù)庫如DynamoDB、MongoDB、Redis、HBase、Memcache出于簡化數(shù)據(jù)庫結構、避免冗余、影響性能的表連接、摒棄復雜分布式的目的被設計。NoSQL數(shù)據(jù)庫適合追求速度和可擴展性、業(yè)務多變的應用場景。 對于非結構化數(shù)據(jù)的處理更合適,如文章、評論,這些數(shù)據(jù)如全文搜索、機器學習通常只用于模糊處理,并不需要像結構化數(shù)據(jù)一樣,進行精確查詢,而且這類數(shù)據(jù)的數(shù)據(jù)規(guī)模往往是海量的,數(shù)據(jù)規(guī)模的增長往往也是不可能預期的,而NoSQL數(shù)據(jù)庫的擴展能力幾乎也是無限的,所以NoSQL數(shù)據(jù)庫可以很好的滿足這一類數(shù)據(jù)的存儲。NoSQL數(shù)據(jù)庫利用key-value可以大量的獲取大量的非結構化數(shù)據(jù),并且數(shù)據(jù)的獲取效率很高,但用它查詢結構化數(shù)據(jù)效果就比較差。 RDS provides two (and only two) methods for backing up RDS databases at this point: automated backups and automated snapshots. All the major databases supported by RDS—MariaDB, SQL Server, MySQL, Oracle, and PostgreSQL—allow up to 16 TB of storage for a provisioned IOPS volume. 9.2 SQL database introduction9.2.1 RDS (OLTP)Amazon Relational Database Service 也稱為 Amazon RDS,是一種托管服務,可以簡化在云中設置、操作和擴展關系數(shù)據(jù)庫的過程。它在管理耗時的數(shù)據(jù)庫管理任務的同時,提供經(jīng)濟高效的可調(diào)容量,使您能夠騰出時間專注于應用程序和業(yè)務。與所有 Amazon Web Services 相同,您無需預先投資,而且只需為所使用的資源付費。如果您的應用程序需要更多的數(shù)據(jù)庫實例,您可以通過此申請表申請更多數(shù)據(jù)庫實例。 · 管理 MySQL、MariaDB、Oracle、SQL Server 或 PostgreSQL ,這意味著您當前用于現(xiàn)有數(shù)據(jù)庫的代碼、應用程序和工具也可以無縫用于 Amazon RDS。 · Amazon RDS 可以自動備份您的數(shù)據(jù)庫,并使您的數(shù)據(jù)庫軟件版本保持最新。 · 您可以靈活方便地擴展與關系數(shù)據(jù)庫實例相關聯(lián)的計算資源或存儲容量,并從中受益。此外,Amazon RDS 還可通過復制輕松增強數(shù)據(jù)庫可用性、改進數(shù)據(jù)耐久性或擴展讀取密集型數(shù)據(jù)庫工作負載中單一數(shù)據(jù)庫實例的容量限制。 · 默認情況下,客戶最多可以擁有 40 個 Amazon RDS 數(shù)據(jù)庫實例。全都可用于“BYOL” (Bring Your Own License) 模式下的 Amazon Aurora、MySQL、MariaDB、PostgreSQL 以及 Oracle。 · 適用于 SQL Server 的 RDS 在單個數(shù)據(jù)庫實例上有最多擁有 100 個數(shù)據(jù)庫的限制。 · 必須提供EC2實例和EBS卷類型和大小 · 通過CloudWatch 監(jiān)控 · 備份/快照/時間點恢復功能 · RDS 在虛擬機上運行,但你不能登錄這些OS · AWS 負責RDS OS 的安全,用戶負責使用ssl在DB中設置KMS, Security group, IAM policies和授權用戶 · RDS 不是 serverless · 支持 read replica § 用于增加性能 § 必須開啟自動備份 § 可以在不同的regions § 支持Multi AZ § 可以是Aurora 或MariaDB, MySQL,Oracle, and PostgreSQL § 可以提升為master,但這將打破read replica § You can have up to five read replicas at a time for a single instance · 通過rebooting RDS實例,你可以強制災難恢復從一個AZ到另一個AZ 將數(shù)據(jù)導入 Amazon RDS 的方式有很多并且非常簡單,例如對于 MySQL 使用 mysqldump 或 mysqlimport 實用程序,對于 Oracle 使用數(shù)據(jù)泵、Import/Export 或 SQL Loader,對于 SQL Server 使用 Import/Export 向?qū)А⑼暾麄浞菸募?bak 文件)或 Bulk Copy Program (BCP),或?qū)?PostgreSQL 使用 pg_dump。有關數(shù)據(jù)導入和導出的更多信息,請參閱 MySQL 數(shù)據(jù)導入指南、Oracle 數(shù)據(jù)導入指南、SQL Server 數(shù)據(jù)導入指南、PostgreSQL 數(shù)據(jù)導入指南。 靜態(tài)加密支持Aurora、MySQL、SQL Server、MariaDB、PostgreSQL 以及 Oracle。使用AWS的密鑰管理服務(KMS )來完成加密。一旦RDS實例被加密,就會加密底層存儲中的靜態(tài)數(shù)據(jù),以及它的自動備份、read replicas和snapshots。 Exam tips: · Read replicas use asynchronous replication, pushing data to the read replicas whenever possible, for improved read performance. Read replicas are intended to provide scalability for your application by adding additional instances for increased reads from applications. you can set up a read replica in an on-premises instance. Additionally, read replicas are often created in separate regions from the primary instance, to improve performance for clients closer to different regions than the primary instance. · A read replica configuration is aimed squarely at increasing database performance, specifically the performance of reading data from an RDS instance. Read replicas are updated via asynchronous replication— the most performant approach—from the primary database. · read replicas are not a backup strategy, nor do they cause automatic backups to be set up. However, you must turn on automatic backups for the primary database instance to enable read replicas. · Read replicas do not create automatic backups, but the primary database instance must have automatic backups enabled to create read replicas. · Amazon RDS does not support circular replication, which means one database reads from a second database but then is replicated back by that second database. However, it is absolutely permissible for one database to replicate another database and then be the source for a third database. · Currently, read replicas in RDS are only supported by MariaDB, MySQL,Oracle, and PostgreSQL. · A Multi-AZ setup is about disaster recovery, and therefore durability. They provide automatic backups, upgrades happen on the primary database and then are replicated, and there is a primary and usually a single secondary instance · A Multi-AZ setup is focused on disaster recovery and fault tolerance, while read replicas provide performance and scalability. · Replication occurs synchronously from a primary instance to a secondary instance in a Multi-AZ setup. Asynchronous replication only occurs in a read replica setup (which can be enabled in addition to a Multi-AZ setup). · RDS provides for SQL interaction as well as access through the RDS web APIs. RDS instances do not allow access via SSH or RDP. · AWS does not support circular replication through RDS. While some of the databases supported by RDS do, RDS itself does not provide access to this functionality. 9.2.2 Aurora· 以10GB為起點,10GB 為增量增加到64T,存儲可自動伸縮 · 計算資源可以縱向擴展到32Vcpu ,244G 內(nèi)存 · 至少有3個可用區(qū),每個可用區(qū)包含2個副本,也即是你的數(shù)據(jù)至少6個副本 · 當主機故障: § 一個read replica將自動晉升為主機(60秒內(nèi)) § 如果沒有read replica,將自動lauch 新的替代主機 · 你可以分享Aurora snapshots給其他AWS 賬戶 · 缺省情況下,Aurora開啟自動備份 · Aurora 是 serverless · Aurora 速度是MySQL 5倍, PostgreSQL 3倍 · AWS 負責Aurora OS 的安全,用戶負責使用ssl在DB中設置KMS, Security group, IAM policies Figure 40 The comparison between MySQL and Aurora 9.2.3 RDS summaryBackup · preferred backup window · backup retention period · I/O suspension for single · Point-In-Time Recovery Snapshot · DB Snapshots make entire DB instance · from one region to another region, a copy retain in that region · Because KMS encryption keys are specific to the region that they are created in, encrypted snapshot cannot be copied to another region · DB Snapshot Sharing § DB snapshot that uses an option group with permanent or persistent options cannot be shared · KMS key policy must first be updated by adding any accounts to share the snapshot with, before sharing an encrypted DB snapshot Replication · routing read queries from applications to the Read Replica · Failover mechanism automatically changes the DNS record of the DB instance to point to the standby DB instance Multi-AZ deployment · read-only traffic, use a Read Replica. · synchronous standby replica in a different Availability Zone · must be in same region · For multi-AZ high availability, RDS uses synchronous replication between primary and standby systems. If standby is slow, transactions will take longer to complete. RDS Read Replica on the other hand uses asynchronous replication and any slowness in Read Replica instance would simply cause data lag in the read - replica. Transactions in primary is impacted Read Replica · RDS sets up a secure communications channel between the source DB instance and the Read Replica, if that Read Replica is in a different AWS region from the DB instance · replication link is broken, A Read Replica can be promoted to a new independent source DB · use some tools like HAPROXY, with two url, one for write one tor read Security · Encryption enabled at creating, can not change key later · Once encryption, log, snapshot, autobackup and replica are encripted · Cross region replicas and snapshots copy does not work since the key is only available in a single region · Database security groups default to a “deny all” access mode Monitor · 監(jiān)控的metric 16 項, ReplicaLag · Backup not notify for snapshot Maintenance · Multi-AZ deployment, preform standby, promote standby, preform old primary · RDS takes two DB snapshots, before upgrade, after upgrade 9.3 NoSQL database introduction9.3.1 ElastiCache使用ElastiCache來增加數(shù)據(jù)庫和web應用程序的性能,它具有如下特性: · 管理 Redis / Memcache. (類似于RDS,但用于緩存) · 內(nèi)存數(shù)據(jù)存儲,延遲低于毫秒級 · 必須提供EC2實例類型 · 支持集群(Redis)和 Multi AZ, Read replicas (sharding) · 安全是通過IAM, Security group, KMS, Redis Auth · 備份/快照/時間點恢復功能 · 通過CloudWatch 監(jiān)控 · AWS 負責OS 的安全,用戶負責使用ssl在DB中設置KMS, Security group, IAM policies,users (Redis Auth) Figure 41 Redis vs Memcached Exam tips: · ElastiCache, when used through AWS, handles all of these tasks and more: hardware provisioning, software patching, setup, configuration, monitoring, failure recovery, and backups. à Means everything handled by ElastiCache · ElastiCache is an in-memory data store that shards across instances. It is not in itself a data distribution mechanism. And it is not a monitoring solution at all. · ElastiCache is ideal for high-performance and real-time processing as well as heavyduty business intelligence. · Consider ElastiCache as only useful for storing transient data. Further, it’s not a persistent store; therefore, it’s great for caching data from a message queue or providing very fast ephemeral storage. · ElastiCache uses shards as a grouping mechanism for individual redis nodes. · ElasticCache § ElastiCache currently allows access only from the EC2 network § Memcache not support multi-AZ § REDIS replica read can not across regions § Redis Replication Groups, max 5 replica § Redis Multi-AZ with Automatic Failover, promote one replica as primary, disabled Failover, create new instance and sync with exist replica 9.3.2 DynamoDBAWS DynamoDB是一個快速和靈活的NoSQL數(shù)據(jù)庫服務,適用于所有需要一致的、任何規(guī)模的延遲在個位數(shù)的應用程序,他是一個完全托管的數(shù)據(jù)庫,支持文檔和Key-value數(shù)據(jù)模型。它靈活的數(shù)據(jù)模型和可靠的性能使它非常適合于移動、web、游戲、廣告技術、IoT和許多其他應用程序。mobile, web, gaming, ad-tech, IoT, and many other applications. Primary key: Simpleàsingle attribute Compositeà Two attribute (partition key, sort key) · AWS 專有的技術,NoSQL 數(shù)據(jù)庫管理 · 存儲在SSD存儲器中 · 高可用,分布在3個地理上不同的數(shù)據(jù)中心 · 缺省是最終的一致性 讀?。╡ventual consistent reads) § 所有數(shù)據(jù)副本之間的一致性通常在1秒內(nèi)到達。在短時間內(nèi)重復讀取應該會返回更新后的數(shù)據(jù)(最后的讀性能) · 支持強一致讀取 (Strongly consistent reads) § 強一致的讀將返回一個結果,該結果反應在讀之前收到成功響應的所有寫操作 § Cost 是最終一致性的2倍 · Serverless,配置容量,自動擴展 · 具有備份/恢復功能,全局表功能 · 可以代替ElastiCache作為 key-value存儲,例如存儲會話數(shù)據(jù) · 通過CloudWatch 監(jiān)控 · 安全—身份認證和授權是通過IAM 完成的 · 只能查詢主key,排序key和 index · Use case: 無服務器應用程序開發(fā),分布式無服務器緩存,不支持SQL 查詢語言 DynamoDB · synchronously replicates data across three AZ’s in a region · durability with shared data · secutiry&permission · IAM Role that allows write access to the DynamoDB, · Launch an EC2 Instance with the IAM Role included · Secondary Indexes · global, an index with a hash and range key that can be different from those on the table · batch read up to 100 items (using primary keys) · batch up to 25 individual putitem and deleteitem request 9.4 RedshiftRedshift 是基于PostgreSQL的,但它并不用于OLTP-- online transation processing,而是用于OLAP—online analytical processing,作為分析和數(shù)據(jù)倉庫。其性能是其他數(shù)據(jù)倉庫的10倍,可擴展到PB級的數(shù)據(jù)。存儲時基于列存儲而不是行存儲,支持大規(guī)模的并行查詢(MPP—Massively Parallel Query Execution), 且高可用。由SQL 接口來執(zhí)行查詢。根據(jù)所提供的實例按需付費,集成了BI 工具,如 AWS Quicksight或tableau。 Redshift具有如下特性: · 單節(jié)點—160Gb · 多節(jié)點 § Leader節(jié)點,管理客戶端連接和接收查詢 § Compute節(jié)點,存儲數(shù)據(jù)和執(zhí)行查詢即計算,可擴展到128個計算節(jié)點 · 數(shù)據(jù)從S3、DynamoDB、DMS和其他DBs加載 · cluster can be restored from snapshot in same region · Redshift spectrum: 可以直接針對S3執(zhí)行查詢,不需要加載 · Redshift增強了VPC路由功能,復制和卸載(unload)都經(jīng)過VPC · Backups § 默認啟用,保留一天 § 最長保存期為35天 § Redshift總是試圖維護至少3個數(shù)據(jù)副本:計算節(jié)點上的original和replica,以及Amazon S3中的備份 § Redshift還可以異步復制你的snapshots到另一個區(qū)域的S3中,進行災難恢復 · Redshift的可用性: § 當前只支持1個AZ § 有自動愈合功能—auto healing § 可以在停機時將snapshots恢復到新的 AZ (same region) § 可用于商業(yè)智能(Business intelligence) · 操作類似于RDS · 安全也類似于RDS: IAM, VPC, KMS,SSL Redshift is one of AWS’s OLAP (online analytics processing) tools and is a database service. While it does processing, it is primarily intended to receive large amounts of data and operate upon that data, as a database would (in loose terms). Redshift is optimized for batched write operations and for reading high volumes of data. Columnar storage minimizes I/O and maximize data throughput by retrieving only the blocks that contain data for the selected columns. It is not meant for high frequency update use cases typically seen in OLTP systems 9.5 How to connect to a RDS database instance in one VPC通過 VPC 內(nèi)部署的 EC2 實例可以訪問同一 VPC 內(nèi)部署的數(shù)據(jù)庫實例。如果這些 EC2 實例部署在具有關聯(lián)彈性 IP 的公共子網(wǎng)中,您可以通過 Internet 訪問 EC2 實例。對于 VPC 內(nèi)部署的數(shù)據(jù)庫實例,可通過 VPN 或您在公有子網(wǎng)中可以啟動的堡壘主機,或使用 Amazon RDS 可公開訪問選項通過 Internet 或從 VPC 外部的 EC2 實例進行訪問。 要使用堡壘主機,您需要設置一個包含用作 SSH 堡壘的 EC2 實例的公開子網(wǎng)。該公有子網(wǎng)的 Internet 網(wǎng)關和路由規(guī)則必須允許通過 SSH 主機引導流量,然后必須將請求轉(zhuǎn)發(fā)到 RDS 數(shù)據(jù)庫實例的私有 IP 地址。 簡單創(chuàng)建數(shù)據(jù)庫實例,并將“可公開訪問”選項設定為“是”,即可使用公共連接。默認情況下,當“可公開訪問”選項可用時,從您的 VPC 外部可實現(xiàn)對 VPC 內(nèi)數(shù)據(jù)庫實例的完全訪問。這表示您無需配置 VPN 或堡壘主機來允許對實例的訪問。 您也可以設置一個 VPN 網(wǎng)關,將公司網(wǎng)絡擴展到 VPC,然后允許訪問該 VPC 中的 RDS 數(shù)據(jù)庫實例。有關詳細信息,請參閱 Amazon VPC 用戶指南。我們強烈建議您使用 DNS 名稱來連接數(shù)據(jù)庫實例,因為基礎 IP 地址可能會發(fā)生變化(例如,在故障轉(zhuǎn)移時)。 數(shù)據(jù)庫實例遷移:可以從VPC外部遷移到內(nèi)部,但不能從內(nèi)部遷移到外部。 · 如果數(shù)據(jù)庫實例未在 VPC 中,您可以使用 AWS 管理控制臺輕松將數(shù)據(jù)庫實例移至 VPC 中。 · 對 VPC 外部的數(shù)據(jù)庫實例拍攝快照,然后通過指定您要使用的數(shù)據(jù)庫子網(wǎng)組,將其還原到 VPC。此外,您也可以執(zhí)行“還原到時間點”操作。 · 不支持將數(shù)據(jù)庫實例從 VPC 內(nèi)部遷移到外部。出于安全考慮,無法將 VPC 內(nèi)數(shù)據(jù)庫實例的數(shù)據(jù)庫快照還原到 VPC 外部。同樣,也無法執(zhí)行“還原到時間點”功能。 9.6 RDS Database configuration如果您的 AWS 賬戶是在 2013 年 12 月 4 日之前創(chuàng)建的,那么您或許可以在 Amazon Elastic Compute Cloud (EC2)-Classic 環(huán)境中運行 Amazon RDS。無論使用 EC2-Classic 還是 EC2-VPC,Amazon RDS 的基本功能完全相同。無論數(shù)據(jù)庫實例部署在 VPC 內(nèi)部還是外部,Amazon RDS 都能管理備份、軟件補丁、自動故障檢測、只讀副本和恢復。 數(shù)據(jù)庫子網(wǎng)組是您希望為 VPC 中的 RDS 數(shù)據(jù)庫實例委派的子網(wǎng)集合。每個數(shù)據(jù)庫子網(wǎng)組都應在指定區(qū)域中的每個可用區(qū)內(nèi)擁有至少一個子網(wǎng)。在 VPC 中創(chuàng)建數(shù)據(jù)庫實例時,您需要選擇一個數(shù)據(jù)庫子網(wǎng)組。然后,Amazon RDS 使用該數(shù)據(jù)庫子網(wǎng)組和您首選的可用區(qū)來選擇子網(wǎng)以及該子網(wǎng)內(nèi)的 IP 地址。Amazon RDS 創(chuàng)建彈性網(wǎng)絡接口,并通過該 IP 地址將其關聯(lián)到您的數(shù)據(jù)庫實例。請注意,我們強烈建議您使用 DNS 名稱來連接數(shù)據(jù)庫實例,因為基礎 IP 地址可能會變化(例如,在故障轉(zhuǎn)移時)。 對于多可用區(qū)部署,為一個區(qū)域內(nèi)的所有可用區(qū)定義子網(wǎng)可允許 Amazon RDS 在需要時在其他可用區(qū)中創(chuàng)建新的備用實例。即使是單一可用區(qū)部署,您也需要這樣做,以防以后需要將它們轉(zhuǎn)換為多可用區(qū)部署。 以多可用區(qū)部署模式運行我的數(shù)據(jù)庫實例時,不可以使用備用副本來執(zhí)行讀取或?qū)懭氩僮鳌6嗫捎脜^(qū)備用副本不能服務讀取請求。多可用區(qū)部署旨在增強數(shù)據(jù)庫可用性和持久性,而非獲得讀取擴展優(yōu)勢。因此,該功能在主副本和備用副本之間采用同步復制。我們的實施可確保主副本和備用副本一直處于同步狀態(tài),但不能使用備用副本執(zhí)行讀取或?qū)懭氩僮鳌?/p> 需要先啟用數(shù)據(jù)庫實例的自動備份,然后才能創(chuàng)建只讀副本。將備份保留時間設置為 0 以外的任何值,以此在添加只讀副本之前啟用源數(shù)據(jù)庫實例的自動備份。要使只讀副本能夠運行,必須保持備份的啟用狀態(tài)。借助 Amazon RDS for MySQL、MariaDB、PostgreSQL 和 Oracle,最多可為給定的源數(shù)據(jù)庫實例創(chuàng)建 5 個只讀副本。Amazon RDS 支持跨區(qū)域只讀副本。數(shù)據(jù)寫入源數(shù)據(jù)庫實例與數(shù)據(jù)在只讀副本上可用之間的時間長度取決于兩個區(qū)域之間的網(wǎng)絡延遲,只讀副本使用這些引擎的本機異步復制執(zhí)行。Amazon Aurora 使用的是一種不同但仍然是異步的復制機制。 10 HA10.1 Load balancersAWS上有3中不同類型的負載均衡器 · Application Load balancersàALB, 最適合于http & https流量的負載均衡,工作在layer7,即應用層。你可以創(chuàng)建高級路由請求,將特定的請求發(fā)送到指定的 web server; ALBs are redundant across at least two subnets. · Network Load balancersàNLB, 最適合于需要極端性能的TCP 流量的負載均衡,工作在網(wǎng)絡層(layer4),NLB能夠處理每秒百萬級的請求,同時能維持極低的延遲。Network load balancers can handle the extremely high request load · Classic Load balancersà ELB,這是傳統(tǒng)的彈性負載均衡器,可以均衡 http/https應用層,如x-forward 和sticky會話;對于完全依賴于TCP協(xié)議的應用程序,也可以用于嚴格的layer4負載均衡。 An ALB offers SSL termination and makes the SSL offload process very simple through tight integration with SSL processes. While an ELB will handle SSL termination, it does not offer the management features that ALBs do. ALBs offer the most flexibility in routing and load distribution. Classic load balancers support both IPv4 and IPv6. They support HTTP/1 and HTTP/1.1, but only application load balancers support HTTP/2. Further, you must register individual instances, rather than target groups, with classic load balancers; registering target groups is a functionality only available with application load balancers. 如果你的應用程序停止了響應,ELB將響應504 error。這意味著應用程序有問題,這可能是web server的問題,也可能是 database的問題。失敗應用程序的故障點,如果可能,可以進行橫向或縱向擴展。 · 被ELB監(jiān)控的實例都會上報 InService, or OutService · 健康檢查通過域?qū)嵗换z查實例健康狀況 · 負載均衡器有他們自己的DNS 名稱,不需要指定IP Figure 42 No Cross AZ LB Figure 43 Cross AZ LB Figure 44 Cross AZ LB1 高級負載均衡器理論: · ELB將每個請求獨立地路由到負載最小的已注冊的EC2實例 · 跨區(qū)負載均衡器,使你能夠跨越多個可用區(qū)進行負載均衡 · Path patterns允許你根據(jù)請求中包含的url將流量定向到不同的EC2實例 Figure 45 Path pattern · Sticky session允許你將用戶的會話綁定到特定的EC2實例。這確保了在會話期間來自用戶的所有請求都會發(fā)送到同樣的instance · 你也可以為ALB啟用sticky session,但是流量會被發(fā)送到目標組級別 · ALBs are redundant across at least two subnets. Figure 46 sticky session ELB · Pre-Warming · Connection Draining · Client-Side SSL certificates · Server Order Preference · Cross-Zone · SSL termination · ELB HTTPS listener does not support Client-Side SSL certificates 10.2 Auto scaling group通過使用 AWS Auto Scaling,您可以在幾分鐘內(nèi)為作為您的應用程序的AWS 資源配置自動擴展。AWS Auto Scaling 控制臺提供了一個單一的用戶界面,可以統(tǒng)一管理多個 AWS 服務的自動擴展功能。您可以為單個資源或整個應用程序配置自動擴展。 AWS Auto Scaling 對流量存在每日或每周變化的應用程序很有用,這包括: · 周期性流量,例如正常營業(yè)時間內(nèi)的高資源利用率和夜間的低資源利用率 · 打開和關閉工作負載模式,例如批處理、測試或定期分析 · 可變的流量模式,例如具有峰值增長的營銷活動 對于auto scaling,用戶是希望每次伸縮都遵從一定的規(guī)則,比如說基于CPU、memory、Disk的使用量,達到某個閾值在多長時間范圍內(nèi),自動彈起或關閉一定數(shù)量的instance,并進行健康檢查。新的instance和existing instance 提供同樣的服務,從而提高系統(tǒng)性能。 新建ASG launch configuration,這相當于是為以后彈起的實例做了一個template,這就需要你按照業(yè)務需求,對實例進行相應的配置。 Figure 47 Create launch configuration 新建伸縮組ASG,這里需要指定已有的launch configuration,VPC及subnet(AZ)??紤]到高可用,可以指定幾個AZ。 Figure 48 Create ASG 進一步設置 scaling policy, 包括范圍,實例數(shù)量,伸縮指標等。 Figure 49 Config ASG 配置好以后的實際效果 Figure 50 ASG example Exam tips: · When creating an Auto Scaling group, you can specify the minimum and maximum size as well as a desired capacity and scaling policy. You cannot specify how many instances to add at once, nor the desired cost. · While you can specify triggers that are used to grow or shrink the group, you can not specify a memory allocation or a minimum processing threshold (neither is an actual AWS term). · A launch configuration contains an AMI ID, key pair, instance type, security groups, and possibly a block device mapping. · A launch configuration needs a single AMI ID to use for all instances it launches. · There are a number of valid scaling policies for Auto Scaling: Maintain current instance levels, manual scaling, schedule-based scaling, and demand-based scaling § You can choose to maintain current instance level at all times. This is essentially ensuring that no instances are added unless an instance fails its health checks and needs to be restarted or replaced. § Demand-based scaling allows you to specify parameters to control scaling. One of those parameters can be CPU utilization, so this is the policy you’d use for this use case. § Schedule-based scaling allows you to specify a particular time period during which resources should scale up or down. § Manual scaling allows you to specify a minimum and maximum number of instances as well as a desired capacity. The Auto Scaling policy then handles maintaining that capacity. autoscaling · Scheduled scaling cannot be overlap · choose greatest impact when Multiple Policies · cooldown period · Termination Policy 10.3 API gateway只需要在AWS管理控制臺中的幾次點擊,你就可以創(chuàng)建一個API當作“前門”,為應用程序訪問數(shù)據(jù)、業(yè)務邏輯或從后臺服務的功能,如應用程序運行在AWS EC2上,代碼運行在AWS lambda上或任意的web 應用程序。 API網(wǎng)關的功能特性: · 暴露https endpoint來定義RESTful API · 無服務器地連接到類似Lambda和DynamoDB · 將每個API endpoint發(fā)送到不同的目標 · 低成本高效運行 · 輕松伸縮 · 通過API key追蹤和控制使用情況 · 限制請求以防止攻擊 · 連接到CloudWatch記錄所有請求,用于監(jiān)控 · 維護多版本的API 如何配置API網(wǎng)關: · 定義API(容器) · 定義資源和嵌套資源 (url路勁) · 為每個資源 § 選擇受支持的http方法 § 設置安全 § 選擇目標,如EC2, Lambda,DynamoDB等 § 設置請求和響應轉(zhuǎn)換 Same origin policy--同源策略 在計算中,同源策略是web應用程序安全模型中的一個重要概念。根據(jù)該策略,web瀏覽器允許包含在第一個web頁面中的腳本訪問第二個web頁面中的數(shù)據(jù),但前提是兩個web頁面具有相同的來源。這樣做是為了防止跨站點腳本攻擊 · 由web瀏覽器強制執(zhí)行 · 被Postman和curl這樣的工具忽略 CORS—Cross-origin resource sharing是另一端的服務器(而不是瀏覽器中的客戶端代碼)輕松訪問同源策略的一種方式??缳Y源共享是一種機制,它允許從提供第一個資源的域之外的另一個域請求web頁面上的受限資源,例如fonts。 API網(wǎng)關考試提示: · 記住API網(wǎng)關是High level的 · API 網(wǎng)關有緩存功能,以提高性能 · 低成本,可自動擴展 · 限制請求以防止攻擊 · 可以將結果記錄到CloudWatch · 如果使用Javascript/AJAX,使用多域名的API網(wǎng)關,確保啟用了CORS · 客戶端可強制執(zhí)行CORS 10.4 HA—High AvailabilityHA—高可用,其設計目的是用于故障轉(zhuǎn)移和災難恢復。如果條件允許,盡可能將你的應用程序部署在不同的AZ,甚至在不同的region。一般情況,HA的設計至少含3個AZ,可以容忍其中的某個AZ故障,程序仍可以正常對外提供服務。 記住一下幾點: · HA總是為故障而設計 · 盡可能使用多個AZ和多個region · 了解RDS Multi-AZ和 Read replicas之間的區(qū)別 § Multi-AZ: 為了故障轉(zhuǎn)移和災難恢復 § Read replicas: 為了提升讀取性能 · 了解橫向擴展和縱向擴展的區(qū)別 § 橫向擴展:增加配置相同的機器,計算能力和帶寬同時擴展 § 縱向擴展:增加本身機器的配置,如CPU, memory,可能會有網(wǎng)絡瓶頸 Figure 51 HA architecture 11 CloudFormation, Elastic Beanstalk and Lambda11.1 CloudFormationCloudFormation的好處: · 基礎設施代碼(Infrastructure as code) § 不需要手動創(chuàng)建資源,這對控制非常好 § 可以使用git對代碼進行版本控制 § 對Infrastructure的更改,通過代碼進行審查 · 成本 cost § 棧(stacks)中的每個資源都用一個標識符標記,因此你很容易看到一個棧要花費多少錢 § 你可以通過CloudFormation模板來估算資源成本 § 節(jié)約策略:在開發(fā)中,你可以在下午5點自動刪除模板,并在早上8點安全地重新創(chuàng)建 · Productivity § 能夠在云上破壞和重建一個infrastructure § 為你的模板自動生成圖表(diagram) § 聲明式編程,不需要確定順序和編制 · 關注分離(separation): 為許多apps 和 layers創(chuàng)建許多堆棧(stacks) § VPC stacks § Network stacks § APP stacks · 不用重新開發(fā) don’t re-invent the wheel § 利用web上現(xiàn)有的模板 § 利用文檔 CloudFormation如何工作: · 模板必須在S3中上傳,然后在CloudFormation中引用 · 要更新模板,我們不能編輯以前的版本,我們必須要上傳新版的模板到AWS · Stacks通過名稱來標識 · 刪除stack,將刪除由CloudFormation創(chuàng)建的每個組件 · CloudFormation模板部署 § 手動方式 § 在CloudFormation設計器中編輯模板 § 使用控制臺輸入?yún)?shù) § 自動方式 § 在YAML文件中編輯模板 § 使用AWS CLI 部署模板 § 當你完全想要你的流程自動化時,推薦此方法 · CloudFormation的構建模塊 § 模板組件 § 資源:在模板中聲明的AWS 資源 (Mandatory) § 參數(shù):模板動態(tài)輸入 § Mapping: 模板的靜態(tài)變量 § 輸出: 參考已創(chuàng)建的內(nèi)容 § 條件:列出對資源創(chuàng)建的條件 § Metadata—元數(shù)據(jù) § 模板幫助器 § 參考 § 功能 CloudFormation allows you to automate provisioning and, in this case, to create standardized JSON scripts that can be lightly modified to stand up entire stacks for multiple applications that share a common structure. By default, CloudFormation ensures all or nothing deployment. If there is an error at any step and CloudFormation is not able to proceed, then it will remove all AWS resources in a stack that were created by CloudFormation 11.2 Elastic BeanstalkAWS Elastic Beanstalk 讓開發(fā)人員能夠更加輕松地在 AWS 云中快速部署和管理應用程序。開發(fā)人員只需上傳應用程序,Elastic Beanstalk 將自動處理容量預配置、負載均衡、Auto Scaling 和應用程序運行狀況監(jiān)控的部署細節(jié)。 Elastic Beanstalk 支持在 Go、Java、.NET、Node.js、PHP、Python 和 Ruby 中開發(fā)的應用程序。當您部署應用程序時,Elastic Beanstalk 構建選定的受支持的平臺版本并預置一個或多個 AWS 資源(如 Amazon EC2 實例)來運行您的應用程序。您可以使用 Elastic Beanstalk 控制臺、AWS Command Line Interface (AWS CLI) 或 eb(為 Elastic Beanstalk 專門設計的高級 CLI)與 Elastic Beanstalk 進行交互。 Figure 52 Elastic Beanstalk work flow AWS CloudFormation 與 AWS Elastic Beanstalk 有什么區(qū)別? 這些服務的設計目的是使二者相輔相成。AWS Elastic Beanstalk 提供了一個可在云中輕松部署和運行應用程序的環(huán)境。它與開發(fā)人員工具相集成,為您提供“一站式”的應用程序生命周期管理體驗。AWS CloudFormation 是一種便捷的預置機制,支持種類廣泛的 AWS 和第三方資源。它支持許多不同類型的應用程序的基礎設施需求,如現(xiàn)有的企業(yè)級應用程序、舊式應用程序、使用各種 AWS 資源構建的應用程序,以及基于容器的解決方案(包括使用 AWS Elastic Beanstalk 構建而成的解決方案)。 AWS CloudFormation 支持 Elastic Beanstalk 應用程序環(huán)境,將其作為其中一種 AWS 資源類型。例如,這可使您創(chuàng)建和管理 AWS Elastic Beanstalk 托管的應用程序,以及用于存儲應用程序數(shù)據(jù)的 RDS 數(shù)據(jù)庫。除了 RDS 實例,還可向該組添加任何其他受支持的 AWS 資源。 Exam tips: § Elastic Beanstalk is focused on code deployment. It provides that, and in the process, load balancing, Auto Scaling, health monitoring, and capacity provisioning § Elastic Beanstalk is an Amazon service that spins up and manages a number of other services, in particular, compute. Even though you can configure other services, though, Beanstalk is considered to primarily be a code deployment tool and therefore is focused on compute services. § Elastic Beanstalk can deploy your code and handle capacity provisioning, load balancing, and setting up Auto Scaling and health checks, all with very little oversight. Note that you’d still need personnel to keep an application like this running, but Elastic Beanstalk can reduce initial resources needed for application deployment. § Rolling deployment – Updates a batch of instances. Each batch is taken out of service and available capacity is reduced by the number of instances in the batch. All at once deploys new version to all instances simultaneously. Instances are out of service for a short period. Rolling with additional batch – Launches additional batch of instances to maintain full capacity during deployment. It deploys version in batches. Immutable – Deploys new version to a fresh set of instances 11.3 LambdaLambda基礎 Lambda是最終的提取層: · 數(shù)據(jù)中心 · 硬件 · 匯編代碼/協(xié)議 · 高級語言 · 操作系統(tǒng) · 應用層 /AWS APIs · AWS lambda 你可以用以下方式來使用lambda: · 作為一個事件驅(qū)動的計算服務,AWS運行你的代碼以響應事件。這些事件可以是對Amazon S3 bucket或Amazon DynamoDB表中的數(shù)據(jù)更改 · 作為一個計算服務,運行你的代碼以響應使用API網(wǎng)關的HTTP請求或使用AWS sdk進行的API調(diào)用。 Figure 53 Lambda classic 傳統(tǒng)架構 vs 無服務器架構 Figure 54 Traditional vs serverless Lambda考試提示: · Lambda自動進行橫向擴展,而不是縱向 · Lambda功能是獨立的,一個事件=一個功能 · Lambda是serverless · Lambda功能可以觸發(fā)其他Lambda功能,這也就意味著一個事件可以等于多個功能 · Lambda架構可以變得極其復雜,AWS X-ray允許你調(diào)試正在發(fā)生的事件 · Lambda可以做全局的事情,你可以用它把S3 bucket 備份到其他S3 bucket · 清楚知道你的觸發(fā)器是什么 · By default, Lambda allows 1000 concurrent executions across all functions within a region. You can increase this limit by contacting support. · By default, Lambda allows outbound calls to internet · With Lambda, you have to choose amount of memory needed to execute your function. Based on the memory configuration, proportional CPU capacity is allocated. · Lambda support versioning and you can maintain one or more versions of your lambda function. Each lambda function has a unique ARN. Lambda also supports Alias for each of your functions. Lambda alias is a pointer to a specific lambda function version. Alias enables you to promote new lambda function versions to production and if you need to rollback a function, you can simply update the alias to point to the desired version. Event source needs to use Alias ARN for invoking the lambda function. Serverless website 案例 Figure 55 Serverless website example 12 Mornitoring13 Other services13.1 AWS Organizations· 全局服務 · 允許管理多個AWS賬戶 · 主賬號是master account,你不能更改 · 其他賬戶是member account · member account只能是一個organization的一部分 · 跨所有賬戶合并賬單à單一付款方法 · 從合并用量中得到價格優(yōu)惠(容量打折) · API 可以用于自動創(chuàng)建AWS 賬戶 OU & Service control policies (SCPs) · Organization account 在organization unit(OU)中 § 可以是任何事: dev/test/prod or finance /HR/IT § 可以嵌套OU · 將SCPs用于OU § 允許/拒絕訪問AWS § SCP的語法類似于IAM § 它是對IAM 的過濾 · 有助于創(chuàng)建 sandbox賬戶 · 有助于分離開發(fā)和產(chǎn)品資源 · 有助于只允許已批準的服務 Figure 56 OU nest 13.2 AWS WorkSpaces· 托管的,安全的云桌面 · 極大地消除了On-promise VDI的管理 VDI(Virtual desktop infrastructure) · 按需的,根據(jù)使用付費 pay as you go · 安全,加密,網(wǎng)絡隔離 · 與Microsoft Access Directory 集成 Figure 57 WorkSpaces 13.3 AWS AppSync· 通過移動和web應用程序?qū)崟r存儲和同步數(shù)據(jù) · 使用GraphQL (來自Facebook的移動技術) · 客戶端代碼可自動生成 · 實時訂閱 · 與DynamoDB / Lambda集成 · 離線數(shù)據(jù)同步 (代替Cognito 同步) · 細粒度安全 13.4 AWS Single Sign On (SSO)· 跨多個AWS賬戶和業(yè)務程序(office365,salesforce,box),集中管理單點登錄 · 一次登錄就能讓你安全地訪問所有東西 · 與Microsoft Access Directory 集成 · 有助于減少公司設立SSO的過程 · 只對 web 瀏覽器有幫助,支持SAML2.0 的應用程序 13.5 ECSàElastic Container Service13.5.1 ECS conceptECS Cluster: 一系列EC2實例 ECS Service: 運行在 ECS cluster上的應用程序定義 ECS task + definition: 運行容器用于創(chuàng)建應用程序 ECS IAM roles: 分配給tasks的角色,用于與AWS交互 Figure 58 ECS cluster · ECS是一個容器編制服務 · ECS幫助你在EC2實例上運行docker容器 · ECS比較復雜,由以下組成: § ECS core:運行ECS在用戶提供的EC2實例是 § Fargate: 在由AWS 提供的計算服務上運行ECS task (serverless) § EKS: 在AWS 驅(qū)動的K8S(跑在EC2上) 上運行ECS § ECR: 由AWS托管的docker 容器注冊表 · ECS和Docker都是非常流行的微服務 · 目前只有ECS core和ECR 在考試范圍 · IAM 和角色是在ECS任務級 · ECS Scheduler is responsible for placing the tasks on container instances. Service is where you configure long running tasks and how many containers you need. · For each task copy, containers that are defined as part of a single task definition are placed together. 13.5.2 Docker· Docker是一個容器技術 · 運行容器程序在任意安裝了Docker的機器上 · 容器允許我們的運用程序以相同的方式運行在任何地方 · 容器是相互隔離的 · 你可控制分配容器的CPU和內(nèi)存 · 能夠做網(wǎng)絡規(guī)則限制 · 比虛擬機效率高 · 容器能看快速伸縮(秒級) AWS ECS use case · 運行微服務 § 能夠在同一機器上運行多個docker容器 § 對于通訊增強,可以輕松實現(xiàn)服務恢復 § 直接與ALB集成 § 自動伸縮 · 運行批處理 / 定時任務 § 計劃ECS 容器來運行 On-demand / reserved / spot 實例 · 遷移應用程序到云上 § 對在本地運行的遺留應用程序進行dockerize (容器化) § 將docker容器移到ECS上運行 13.5.3 AWS ECS 與ALB的集成:· ALB與ECS 有直接集成的特性,叫“port mapping”端口映射 · 這允許由相同應用程序的實例在同一個EC2機器上 · Use cases § 增加彈性,即時運行在一個EC2 實例上 § 最大化 CPU / cores的利用率 § 能夠執(zhí)行升級回滾,而不影響應用程序的運行 Figure 59 ECS-ALB ECS setup & config file 運行EC2實例,安裝ECS代理和配置文件 使用ECS-Ready的AMI,也需要修改配置文件 ECS 配置文件: /etc/ecs/ecs.config 13.5.4 ECRàElastic Container Registry· 在AWS 上存儲,管理和部署你的容器 · 完全與IAM & ECS集成 · 用HTTPS 傳輸和靜態(tài)加密 Figure 60 ECR workflow 13.6 Amazon EMR· EMRà Elastic MapReduce · EMR幫助創(chuàng)建Hadoop集群(大數(shù)據(jù)),用于分析和處理大量數(shù)據(jù) · 集群可由上百個EC2實例組成 · 支持Apache Spark,Hbase, Presto, Flink ………. · EMR關注所有的Provisioning 和 configuration · 自動伸縮和與spot實例集成 · Use case: 數(shù)據(jù)處理,機器學習,web 檢索,大數(shù)據(jù) 13.7 AWS Step Function· 對編排的你的lambda function,構建無服務器的可視化workflow · 代表流為JSON 狀態(tài)機 · 特點: 順序執(zhí)行,并行,條件,timeouts,錯誤處理…… · 可以與EC2, ECS, On premise servers, API 網(wǎng)關集成 · 最大執(zhí)行時間是1年 · 有能力實施人為批復特性 · Use cases § 順序執(zhí)行 order fulfillment § 數(shù)據(jù)處理 § Web 應用程序 § 任意workflow Figure 61 Step function 13.8 AWS SWF – Simple workflow serviceSWF是一種web 服務,它可以方便地跨分布式應用程序組件協(xié)調(diào)工作。SWF支持一序列的應用程序,包括media處理,web程序后端,業(yè)務流程工作流和分析 pipeline,將其設計為任務的協(xié)調(diào)。任務表示應用程序中的各種處理步驟,可由可執(zhí)行代碼、web服務調(diào)用、人工操作和腳本執(zhí)行。 · 協(xié)調(diào)運用程序間的工作 · 代碼運行在EC2上( not serverless) · 最長運行時間是1年 · “Activity step” 和 “Decision step” · 有人為干預的步驟 · 從web到warehouse交付是順序執(zhí)行的 · 對新的應用程序,推薦使用step function, 除了: § 如果你需要外部信號在過程中進行干預 § 如果你需要返回值到父進程的子進程 SWF Actors · Workflow starters--- 可以初始化啟動工作流的應用程序,這可以是電子商務網(wǎng)站下的訂單,也可以是移動app 搜索公交時間等 · Deciders---控制工作流執(zhí)行中的活動任務流,如果工作流中的某個任務完成或失敗了,Decider將決定下一步要做什么 · Activity workers---執(zhí)行活動任務 Exam tips: · SWF provides an API, but it is neither the AWS-specific API nor language specific. Instead, SWF supports standard HTTP requests and responses. · SWF is typically thought of as an asynchronous service, but it also supports synchronous tasking when needed. · A SWF domain is a collection of related workflows. 13.9 SQSà simple queue service· SQS 是基于pull,而不是push · 消息大小256kb · 消息可以在隊列里保留從1分鐘到14天,缺省條件下的保存期是4天 · 可見超時,是指讀取器獲取消息后,消息在SQS中是不可見的時間量。如果在可見超時過期前處理作業(yè),則消息將從隊列中刪除。如果在這段時間內(nèi)沒有處理作業(yè),則消息將再次可見,另一個讀取器將處理它。這可能導致相同消息被傳遞兩次 · 可見超時最長12小時 · SQS保證你的消息將至少被處理一次 · SQS 長輪詢是一種從SQS檢索消息的方法。常規(guī)的短輪詢是立即返回的,即使正在輪詢的消息隊列是空的,而長輪詢直到消息到達消息隊列或長輪詢超時才返回響應 · QS queues only make an “attempt” to deliver messages in order (more or less a FIFO approach) but do not guarantee FIFO. If strict FIFO is needed, that option can be selected. SWF vs SQS · SQS的最長保存期14天,SWF工作流執(zhí)行最多可持續(xù)1年 · SQS 提供一個面向消息message-oriented的API, SWF 提供一個面向任務task-oriented的API · 使用SQS,需要處理重復消息,這可能需要確保消息只能被處理一次;SWF確保任務只分配一次,并且不會重復 · 使用SQS,你要實現(xiàn)自己的應用程序級的跟蹤,特別是在應用程序使用多個隊列的情況下, SWF跟蹤應用程序中的所有任務和事件 13.10 SNS· SNS--- Simple notification service · 及時的,基于push的交付(無輪詢) · 簡單的APIs和易于集成的應用程序 · 靈活的消息傳遞,多傳輸協(xié)議 · 便宜,按需付費,不用預付 · 基于web 的AWS 管理console,提供簡單的 point-and-click接口 SNS vs SQS · 都是AWS的消息服務 · SNS-- Push · SQS—Pull Messages in SWF are tasks; messages in SQS are messages; messages in SNS are notifications 13.11 Elastic transcoder· 云上的media 編碼器 · 將media 從其原始格式轉(zhuǎn)換到不同的格式,可以在智能手機、平板電腦、個人電腦等上播放的不同格式 · 提供流行的輸出格式編碼預置,這意味著你不需要的猜測哪些設置在特使設備上工作的最好 · 根據(jù)你轉(zhuǎn)碼的分鐘數(shù)和轉(zhuǎn)碼的分辨率來支付 Figure 62 Elastic transcoder workflow 13.12 Kinesis流式數(shù)據(jù)是由數(shù)千個數(shù)據(jù)源連續(xù)生成的數(shù)據(jù),這些數(shù)據(jù)源通常是同時發(fā)送數(shù)據(jù)記錄,并且是小尺寸的(kb 順序),如: · 網(wǎng)購 · 股票價格 · 游戲數(shù)據(jù) · 社交網(wǎng)絡數(shù)據(jù) · 地理空間數(shù)據(jù)(uber,didi) · IoT傳感器數(shù)據(jù) Kinesis是AWS上一個處理流式數(shù)據(jù)的平臺,使加載和分析流數(shù)據(jù)變得容易,還提供了為業(yè)務需求構建自定義應用程序的能力。3種不同形式的kinesis: · Kinesis stream · Kinesis firehose · Kinesis analytics Kinesis Streams has a maximum retention of 7 days and Kinesis Firehose has a retention of 1 day Figure 63 Kinesis stream Kinesis stream 由shards組成: · 對于讀取,每秒5個事務,最大的總數(shù)據(jù)讀取速率為 每秒2MB · 對于寫,每秒最多1000條記錄,最大的總數(shù)據(jù)寫速率為 每秒1MB,包括分區(qū)鍵 · Stream的數(shù)據(jù)容量是指定流的shards數(shù)量的函數(shù),總容量是shards容量的總和 Figure 64 Kinesis Firehose Kinesis stream數(shù)據(jù)可以持久,而Kinesis firehose 數(shù)據(jù)不能持久。 Figure 65 Kinesis Analytics Figure 66 Kinesis components comparison Kinesis Data Streams Real-time data capture Ingest and store data streams from hundreds of thousands of data sources:
Kinesis Data Firehose Load real-time data Load streaming data into data lakes, data stores, and analytics tools for:
Kinesis Data Analytics Get insights in real time Analyze streaming data and gain actionable insights in real time:
13.13 CloudFrontDelivery · Request-Route53-edge location-Origin server · Supports both static and dynamic content RMTPà Real Time Messaging Protocol(實時消息傳輸協(xié)議) · S3 bucket as the origin · users view media files using the media player that is provided by cloudfront; not the locally installed · Web distribution for media Player and RMTP distribution for media files · private content · OAIà Origin Access Identity · add header in http server, Origin to verify the request has come from CloudFront · feature · signed URLs and signed cookies · for RTMP distribution · restrict access to individual files · access to multiple restricted files Caching Based on Request Headers Geo Restriction Compressed Files · Content-Encoding header on the file must not be gzip · viewer uncompresses the file · multi-upload to S3 SNI Server Name Indication, 同一個IP可用選擇多個hostname, 用自己的SSL證書時選擇,一般是客戶端瀏覽器的選項 Dedicated IP 專屬主機IP,不和其他hostname共用,傳統(tǒng)SSL使用,現(xiàn)在大部分用SNI https with S3, s3不能獨立用https, 但是結合cloudfront, 用 ACMà Amazon Certificate Manager 生成的證書可以通訊 Price · Charge with: data out, request, Invalidation request, SSL certificates · CloudFront is intended to cache and deliver static files from your origin servers to users or clients. Dynamic content is also servable through CloudFront from EC2 or other web servers. as CloudFront is a distribution mechanism, not a storage facility. · Edge locations are used by CloudFront distributions to store cached content, EC2 instances can serve content from processes. · CloudFront is AWS’s distribution network. It’s a content caching system that is ultimately a networking component of your AWS buildout. · CloudFront can front a number of AWS services: AWS Shield, S3, ELBs (including ALBs), and EC2 instances. It also most recently supports Lambda@Edge as an origin. · As CloudFront is typically associated with performance, and not a lot else. However, CloudFront also provides deep integration with many managed AWS services, such as S3, EC2, ELBs, and even Route53 · CloudFront automatically provides AWS Shield (standard) to protect from DDoS, and it also can integrate with AWS WAF and AWS Shield advanced. These combine to secure content at the edge. HTTPS is not required, and there is no KMS involvement with CloudFront. · Edge locations number more than both regions and availability zones · CloudFront is easy to set up and lets you create a global content delivery network without contracts. It’s also a mechanism for distributing content at low latency. Creating websites and the actual file storage are not features of CloudFront but of LightSail (for example) and S3, respectively. · When you create a CloudFront distribution, you register a domain name for your static and dynamic content. This domain should then be used by clients. · CloudFront will always handle requests that it receives. It will either return the requested content if cached or retrieve that content by requesting it from an origin server. It will not redirect the client, nor will it pass the request on directly. · There is no charge associated with data moving from any region to a CloudFront edge location. · CloudFront can store and serve both static (HTML and CSS) and dynamic (PHP,) content. SQL queries cannot be directly returned, nor can an actual Lambda function. You can front the result of a Lambda@Edge function, but not the function itself. · An edge location is a data center that delivers CloudFront content. Edge locations are spread across the world. · A distribution is the setup including your origin servers and how the content from those servers is distributed via CloudFront. It does not specifically refer to cached content at any given point in time. · Edge locations check for updated content every 24 hours by default, but this value can be changed. · Edge locations can be set to have a 0-second expiration period, which effectively means no caching occurs. · RDS instances cannot be origin servers · A collection of edge locations is a distribution. · An RTMP distribution is the Adobe Real-Time Messaging Protocol and is suitable for using S3 buckets as an origin server to serve streaming media · CloudFront supports both web distributions and RTMP distributions. · An Origin Access Identity is a special user that you will set up the CloudFront service to use to access you restricted content · The invalidation API is the fastest way to remove a file or object, although it will typically incur additional cost. · While edge locations are typically read from by clients, they are also writeable. You can store objects on edge locations as well as read from them. · CloudFront will always handle requests that it receives. It will either return the requested content if cached (A) or retrieve that content by requesting it from an origin server (C). It will not redirect the client (D), nor will it pass the request on directly (B). 13.14 CloudWatchCloudWatch provides disk read operations, CPU usage, and inbound network traffic but does not provide memory usage by default. 13.15 WAF & ShieldA PUT request is used for establishing a session with IMDS version 2. In response, IMDS issues a session token that is valid for TTL specified in the PUT call. With IMDS v2, all calls to metadata service must include the token in the X-aws-ec2-metadata-token header. PUT is used as several firewalls, and proxies do not forward PUTs. Besides, IMDS V2 does not issue a token when the PUT request has an X-Forwarded-For header. 13.15.1 WAFà Web Application FirewallAWS WAF Protect your web applications from common web exploits AWS WAF is a web application firewall service that lets you monitor web requests that are forwarded to an Amazon API Gateway API, an Amazon CloudFront distribution, or an Application Load Balancer. You can protect those resources based on conditions that you specify, such as the IP addresses that the requests originate from. With WAF IP Address sets, you have a scalable solution for whitelisting or blacklisting. This solution supports 1000s of IP address blocks. The WAF IP Address sets and Regex Pattern Sets are reusable across different Web ACLs. Security Group has a limit of a few hundred entries, and Network ACL has a limit of a few 10s of entries. 13.15.2 ShieldAWS Shield provides expanded DDoS attack protection for your AWS resources. Get 24/7 support from our DDoS response team and detailed visibility into DDoS events. As an AWS customer, you automatically have basic DDoS protection with the AWS Shield Standard plan, at no additional cost beyond what you already pay for AWS WAF and your other AWS services. For an additional cost, you can get advanced DDoS protection by activating the AWS Shield Advanced plan. AWS Shield standard: § Protect agaist layer3 and 4 attacks § DDos and other infrastructure level attacks § Included for all customers § Free UDP reflection attack (layer 3) SYN Flood (layer 4) 13.16 Manage resources at scaleSystems Manager also provides a browser-based command line and shell interface for managing Windows and Linux instances. A big benefit is administrators can use IAM to grant and revoke access to the system. The allows you to control through IAM which user can access each instance including the option to provide non-root access. The users can connect to the system without SSH or RDP or Bastion host. This approach vastly simplifies your setup as you no longer need to manage SSH keys or passwords for the servers and eliminates the need for bastion hosts. AWS config continuously monitors your infrastructure, checks for compliance, and alerts you of changes. Using the managed rules in Config, you can quickly get started with best practices to keep your infrastructure compliant with your enterprise policies. You can also customize by writing your own rules. CloudTrail maintains an audit trail of all changes to pinpoint who made the changes and when. With Systems Manager, you get visibility and control of your ec2 and on-premises server infrastructure. With AWS Trusted Advisor, you can benchmark your environment against AWS Best Practices. With AWS Inspector, you can quickly find out security exposures and vulnerabilities in your EC2 instance. It can identify the ports that are reachable from outside of VPC, and it will also identify the process that is listening on the port. The inspector will compare the installed OS and software against known vulnerabilities in the CVE list. It evaluates your instance against the center for industry security (CIS) benchmarks for host hardening. The inspector also checks your instance against AWS security best practices. Inspector will prioritize the findings based on the severity Trusted Advisor is an online tool that provides real-time guidance to help you provision your resources following AWS best practices. By following recommendations provided by Trusted Advisor regularly, you can provision your resources optimally AWS Trusted Advisor is an online resource that helps you reduce cost as well as increase performance and improve security. 14 Cloud migrationTools for cost estimation AWS support plan |
|