

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 聯網
<a name="networking-pattern-list"></a>

**Topics**
+ [使用 自動化區域間對等互連的設定 AWS Transit Gateway](automate-the-setup-of-inter-region-peering-with-aws-transit-gateway.md)
+ [使用 AWS Transit Gateway 集中網路連線](centralize-network-connectivity-using-aws-transit-gateway.md)
+ [使用 Application Load Balancer 在 Oracle WebLogic 上設定 Oracle JD Edwards EnterpriseOne 的 HTTPS 加密](configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer.md)
+ [透過私有網路連線至 Application Migration Service 資料和控制平面](connect-to-application-migration-service-data-and-control-planes-over-a-private-network.md)
+ [使用 AWS CloudFormation 自訂資源和 Amazon SNS 建立 Infoblox 物件](create-infoblox-objects-using-aws-cloudformation-custom-resources-and-amazon-sns.md)
+ [AWS 使用 Terraform 在 上建立階層式多區域 IPAM 架構](multi-region-ipam-architecture.md)
+ [自訂 的 Amazon CloudWatch 提醒 AWS Network Firewall](customize-amazon-cloudwatch-alerts-for-aws-network-firewall.md)
+ [使用 Terraform 在 AWS Wavelength 區域中部署資源](deploy-resources-wavelength-zone-using-terraform.md)
+ [將大量 DNS 記錄遷移至 Amazon Route 53 私有託管區域](migrate-dns-records-in-bulk-to-an-amazon-route-53-private-hosted-zone.md)
+ [當您從 F5 遷移到 AWS 上的 Application Load Balancer 時修改 HTTP 標頭](modify-http-headers-when-you-migrate-from-f5-to-an-application-load-balancer-on-aws.md)
+ [為多個 中的傳入網際網路存取建立 Network Access Analyzer 調查結果報告 AWS 帳戶](create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.md)
+ [在多帳戶 AWS 環境中設定混合網路的 DNS 解析](set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment.md)
+ [確認 ELB 負載平衡器需要終止 TLS](verify-that-elb-load-balancers-require-tls-termination.md)
+ [使用 Splunk 檢視 AWS Network Firewall 日誌和指標](view-aws-network-firewall-logs-and-metrics-by-using-splunk.md)
+ [更多模式](networking-more-patterns-pattern-list.md)

# 使用 自動化區域間對等互連的設定 AWS Transit Gateway
<a name="automate-the-setup-of-inter-region-peering-with-aws-transit-gateway"></a>

*Ram Kandaswamy，Amazon Web Services*

## 摘要
<a name="automate-the-setup-of-inter-region-peering-with-aws-transit-gateway-summary"></a>

[AWS Transit Gateway](https://docs.aws.amazon.com/vpc/latest/tgw/what-is-transit-gateway.html) 透過中央中樞連接虛擬私有雲端 (VPCs) 和內部部署網路。Transit Gateway 流量不會周遊公有網際網路，這可減少威脅向量，例如常見的入侵和分散式阻斷服務 (DDoS) 攻擊。

如果您需要在兩個或多個 之間通訊 AWS 區域，您可以使用區域間傳輸閘道對等互連，在不同區域中的傳輸閘道之間建立對等互連。不過，使用 Transit Gateway 手動設定區域間對等可能既複雜又耗時。此模式提供使用基礎設施做為程式碼 (IaC) 來設定對等互連的指引。如果您必須重複設定多個區域，並為 AWS 帳戶 多區域組織設定使用此方法。

此模式會設定[AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html)堆疊，其中包含 Amazon CloudWatch Logs 中的 AWS Step Functions [anworkflow](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-statemachines.html)、 AWS Lambda [functions](https://docs.aws.amazon.com/lambda/latest/dg/concepts-basics.html#gettingstarted-concepts-function)、 AWS Identity and Access Management (IAM) [角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)和[日誌群組](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html)。然後，您可以執行 Step Functions 工作流程，為您的傳輸閘道建立區域間對等互連。

## 先決條件和限制
<a name="automate-the-setup-of-inter-region-peering-with-aws-transit-gateway-prereqs"></a>

**先決條件**
+ 作用中 AWS 帳戶。
+ 具有程式碼產生功能的 IDE，例如 [Kiro](https://kiro.dev/#what-is-kiro)。
+ Amazon Simple Storage Service (Amazon S3) 儲存貯體及其上傳物件的許可。
+ 在請求和接受區域中建立的傳輸閘道。
+ 在請求和接受區域中建立的 VPCs。使用值為 的`addToTransitGateway`金鑰標記 VPCs`true`。
+ 根據您的需求為您的 VPCs設定[的安全群組](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-security-groups.html)。
+ 根據您的需求為您的 VPCs 設定[的網路存取控制清單 (ACLs)](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html)。

**限制**
+ 只有部分 AWS 區域 支援區域間對等互連。如需支援區域間對等互連的區域完整清單，請參閱[AWS Transit Gateway FAQs](https://aws.amazon.com/transit-gateway/faqs/)。

## Architecture
<a name="automate-the-setup-of-inter-region-peering-with-aws-transit-gateway-architecture"></a>

 此模式中描述的代理式 AI 開發方法涉及以下步驟：

1. **定義自動化提示** – Kiro 會收到自然語言提示，詳細說明對等互連需求。

1. **產生自動化指令碼** – Kiro 會根據提供的提示產生 CloudFormation 和 Lambda 指令碼。

1. **部署堆疊** – Kiro 使用 CloudFormation 部署所需的資源。

1. **設定對等 –** Kiro 執行 Step Functions 工作流程，其會呼叫 Lambda 函數來建立對等連線並修改路由表。

下圖顯示 Step Functions 工作流程：

![\[Step Functions 工作流程可呼叫 Lambda 函數來修改傳輸閘道對等的路由表。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/b678bb87-c7b9-4f7b-b26e-eaac650e5d1b/images/2f235f47-5d68-492c-b954-7dc170939cae.png)


 

工作流程包含下列步驟：

1. Step Functions 工作流程會呼叫傳輸閘道對等的 Lambda 函數。 

1. 工作流程會等待一分鐘。

1. 工作流程會擷取對等狀態，並將其傳送至條件區塊。區塊負責循環。 

1. 如果不符合成功條件，工作流程會編碼為進入計時器階段。 

1. 如果符合成功條件，Lambda 函數會修改路由表。

1. Step Functions 工作流程結束。

## 工具
<a name="automate-the-setup-of-inter-region-peering-with-aws-transit-gateway-tools"></a>
+ [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) 可協助您設定 AWS 資源、快速且一致地佈建資源，以及在整個 AWS 帳戶 和 生命週期中管理資源 AWS 區域。 
+ [Amazon CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html) 可協助您集中所有系統、應用程式的日誌， AWS 服務 以便您可以監控日誌並將其安全地存檔。
+ [AWS Identity and Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html)[ (](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html)[IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html)[)](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html) 透過控制已驗證並獲授權使用的人員，協助您安全地管理對 AWS 資源的存取。
+ [Kiro](https://kiro.dev/#what-is-kiro) 是一種代理式 AI 開發工具，可協助您透過規格驅動的開發來建置生產就緒的應用程式。 
+ [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) 是一項運算服務，可協助您執行程式碼，無需佈建或管理伺服器。它只會在需要時執行程式碼並自動擴展，因此您只需按使用的運算時間付費。
+ [AWS Step Functions](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html) 是一種無伺服器協同運作服務，可協助您結合 AWS Lambda 函數和其他 AWS 服務 來建置業務關鍵型應用程式。  

## 史詩
<a name="automate-the-setup-of-inter-region-peering-with-aws-transit-gateway-epics"></a>

### 產生 Lambda 和 Step Functions 程式碼
<a name="generate-lam-and-sfn-code"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 使用特定詳細資訊填入提示預留位置 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/automate-the-setup-of-inter-region-peering-with-aws-transit-gateway.html)或者，您可以將此新增為參考上述變數的內嵌提示，而無需連接 檔案以取得內容。 | 一般 AWS、網路管理員 | 
| 建立可建立對等附件的 Lambda 函數。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/automate-the-setup-of-inter-region-peering-with-aws-transit-gateway.html) | 一般 AWS、網路管理員、提示詞工程 | 
| 建立 Lambda 函數來輪詢對等連接狀態。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/automate-the-setup-of-inter-region-peering-with-aws-transit-gateway.html) | 一般 AWS、網路管理員、提示詞工程 | 
| 建立 Lambda 函數，將靜態路由新增至兩個區域。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/automate-the-setup-of-inter-region-peering-with-aws-transit-gateway.html) | 一般 AWS、網路管理員 | 
| 建立 CloudFormation 範本。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/automate-the-setup-of-inter-region-peering-with-aws-transit-gateway.html) | AWS DevOps、一般 AWS、提示工程 | 

### 部署 AWS 資源
<a name="deploy-the-aws-resources"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 使用提示部署 CloudFormation 堆疊。 | 輸入下列提示：<pre>Using the outputs from Prompts 1-4, package and deploy the full stack. Steps:<br /><br />1. For each of the three Python files from Prompts 1-3, create a zip named after the file (e.g. peer-transit-gateway.zip that contains peer-transit-gateway.py).<br />2. Upload all three zips to S3_BUCKET.<br />3. Deploy the CloudFormation template from Prompt 4 to ACTIVE_REGION with S3BucketName=S3_BUCKET and CAPABILITY_NAMED_IAM.<br />4. Initiate the Step Function from the deployed stack.<br /><br />Zip file names must match the S3Key values in the template exactly.</pre> | AWS DevOps、雲端管理員、一般 AWS、提示詞工程 | 
| 驗證部署。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/automate-the-setup-of-inter-region-peering-with-aws-transit-gateway.html) | 一般 AWS | 

## 相關資源
<a name="automate-the-setup-of-inter-region-peering-with-aws-transit-gateway-resources"></a>
+ [在 Step Functions 中啟動狀態機器執行](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-executions.html)
+ [傳輸閘道對等互連附件](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-peering.html)
+ [AWS 區域 使用 跨 互連 VPCs AWS Transit Gateway](https://www.youtube.com/watch?v=cj1rQqLxXU8)（影片）

# 使用 AWS Transit Gateway 集中網路連線
<a name="centralize-network-connectivity-using-aws-transit-gateway"></a>

*Mydhili Palagummi 和 Nikhil Marrapu，Amazon Web Services*

## 總結
<a name="centralize-network-connectivity-using-aws-transit-gateway-summary"></a>

此模式描述最簡單的組態，其中 AWS Transit Gateway 可用來將內部部署網路連線到 AWS 區域內多個 AWS 帳戶中的虛擬私有雲端 (VPCs)。使用此設定，您可以建立混合網路，連接區域中的多個 VPC 網路和內部部署網路。這可透過使用傳輸閘道和虛擬私有網路 (VPN) 連線至內部部署網路來完成。

## 先決條件和限制
<a name="centralize-network-connectivity-using-aws-transit-gateway-prereqs"></a>

**先決條件**
+ 託管網路服務的帳戶，作為 AWS Organizations 中組織的成員帳戶進行管理
+ 多個 AWS 帳戶中VPCs，沒有重疊的無類別網域間路由 (CIDR) 區塊

**限制**

此模式不支援隔離特定 VPCs或內部部署網路之間的流量。連接到傳輸閘道的所有網路將能夠互相連接。若要隔離流量，您需要在傳輸閘道上使用自訂路由表。此模式只會使用單一預設傳輸閘道路由表來連接 VPCs 和內部部署網路，這是最簡單的組態。

## Architecture
<a name="centralize-network-connectivity-using-aws-transit-gateway-architecture"></a>

**目標技術堆疊**
+ AWS Transit Gateway
+ AWS Site-to-Site VPN
+ VPC
+ AWS Resource Access Manager (AWS RAM)

 

**目標架構**

![\[AWS Transit Gateway 會將內部部署網路連接到區域內多個 AWS 帳戶中VPCs。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/e23f5faf-e75e-42a3-80e3-142516a2db4e/images/1ecf7e04-bbf8-4304-88c8-6aceb7271d1e.jpeg)


## 工具
<a name="centralize-network-connectivity-using-aws-transit-gateway-tools"></a>

**AWS 服務**
+ [AWS Resource Access Manager (AWS RAM)](https://docs.aws.amazon.com/ram/latest/userguide/what-is.html) 可協助您在 AWS 帳戶、組織單位或整個組織中安全地共用資源 AWS Organizations 。
+ [AWS Transit Gateway](https://docs.aws.amazon.com/vpc/latest/tgw/what-is-transit-gateway.html) 是中央中樞，可連接虛擬私有雲端 (VPCs) 和內部部署網路。

## 史詩
<a name="centralize-network-connectivity-using-aws-transit-gateway-epics"></a>

### 在網路服務帳戶中建立傳輸閘道
<a name="create-a-transit-gateway-in-the-network-services-account"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立傳輸閘道。 | 在您要託管網路服務的 AWS 帳戶中，在目標 AWS 區域中建立傳輸閘道。如需說明，請參閱[建立傳輸閘道](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-transit-gateways.html#create-tgw)。注意下列事項：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/centralize-network-connectivity-using-aws-transit-gateway.html) | 網路管理員 | 

### 將傳輸閘道連接至您的內部部署網路
<a name="connect-the-transit-gateway-to-your-on-premises-network"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 設定 VPN 連線的客戶閘道裝置。 | 客戶閘道裝置連接到傳輸閘道與內部部署網路之間Site-to-Site連線的內部部署端。如需詳細資訊，請參閱 AWS Site-to-Site VPN 文件中的[您的客戶閘道裝置](https://docs.aws.amazon.com/vpn/latest/s2svpn/your-cgw.html)。識別或啟動支援的現場部署客戶裝置，並記下其公有 IP 地址。VPN 組態稍後在此史詩中完成。 | 網路管理員 | 
| 在網路服務帳戶中，建立傳輸閘道的 VPN 連接。 | 若要設定連線，請為傳輸閘道建立 VPN 連接。如需說明，請參閱[傳輸閘道 VPN 連接](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-vpn-attachments.html)。 | 網路管理員 | 
| 在內部部署網路的客戶閘道裝置上設定 VPN。 | 下載與傳輸閘道相關聯的Site-to-Site連線組態檔案，並在客戶閘道裝置上設定 VPN 設定。如需說明，請參閱[下載組態檔案](https://docs.aws.amazon.com/vpn/latest/s2svpn/SetUpVPNConnections.html#vpn-download-config)。 | 網路管理員 | 

### 將網路服務帳戶中的傳輸閘道分享給其他 AWS 帳戶或您的組織
<a name="share-the-transit-gateway-in-the-network-services-account-to-other-aws-accounts-or-your-organization"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 在 AWS Organizations 管理帳戶中，開啟共用。 | 若要與您的組織或特定組織單位共用傳輸閘道，請在 AWS Organizations 中開啟共用。否則，您需要個別共用每個帳戶的傳輸閘道。如需說明，請參閱在 [ AWS Organizations 中啟用資源共用](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-orgs)。 | AWS 系統管理員 | 
| 在網路服務帳戶中建立傳輸閘道資源共享。 | 若要允許組織中其他 AWS 帳戶中VPCs 連線至傳輸閘道，請在網路服務帳戶中使用 AWS RAM 主控台來共用傳輸閘道資源。如需說明，請參閱[建立資源共享](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-create)。 | AWS 系統管理員 | 

### 將 VPCs連接至傳輸閘道
<a name="connect-vpcs-to-the-transit-gateway"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 在個別帳戶中建立 VPC 連接。 | 在已共用傳輸閘道的帳戶中，建立傳輸閘道 VPC 連接。如需說明，請參閱[建立傳輸閘道連接至 VPC](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-vpc-attachments.html#create-vpc-attachment)。 | 網路管理員 | 
| 接受 VPC 連接請求。 | 在網路服務帳戶中，接受傳輸閘道 VPC 連接請求。如需說明，請參閱[接受共用附件](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-transit-gateways.html#tgw-accept-shared-attachment)。 | 網路管理員 | 

### 設定路由
<a name="configure-routing"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 在個別帳戶 VPCs中設定路由。 | 在每個個別帳戶 VPC 中，使用傳輸閘道做為目標，將路由新增至內部部署網路和其他 VPC 網路。如需說明，請參閱[從路由表新增和移除路由](https://docs.aws.amazon.com/vpc/latest/userguide/WorkWithRouteTables.html#AddRemoveRoutes)。 | 網路管理員 | 
| 在傳輸閘道路由表中設定路由。 | 來自 VPCs和 VPN 連接的路由應傳播，並應顯示在傳輸閘道預設路由表中。如有需要，請在傳輸閘道預設路由表中建立任何靜態路由 （其中一個範例是靜態 VPN 連接的靜態路由）。如需說明，請參閱[建立靜態路由](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-route-tables.html#tgw-create-static-route)。 | 網路管理員 | 
| 新增安全群組和網路存取控制清單 (ACL) 規則。 | 對於 VPC 中的 EC2 執行個體和其他資源，請確保安全群組規則和網路 ACL 規則允許 VPCs 與內部部署網路之間的流量。如需說明，請參閱[使用安全群組控制資源的流量](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html#AddRemoveRules)，以及[從 ACL 新增和刪除規則](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html#Rules)。 | 網路管理員 | 

### 測試連線能力
<a name="test-connectivity"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 測試 VPCs之間的連線。 | 確保網路 ACL 和安全群組允許網際網路控制訊息通訊協定 (ICMP) 流量，然後從 VPC 中的執行個體 ping 到另一個也連接到傳輸閘道的 VPC。 | 網路管理員 | 
| 測試 VPCs與內部部署網路之間的連線。 | 確保網路 ACL 規則、安全群組規則和任何防火牆允許 ICMP 流量，然後 ping 內部部署網路和 VPCs 中的 EC2 執行個體之間。您必須先從內部部署網路啟動網路通訊，才能讓 VPN 連線進入 `UP` 狀態。 | 網路管理員 | 

## 相關資源
<a name="centralize-network-connectivity-using-aws-transit-gateway-resources"></a>
+ [建置可擴展且安全的多 VPC AWS 網路基礎設施](https://d1.awsstatic.com/whitepapers/building-a-scalable-and-secure-multi-vpc-aws-network-infrastructure.pdf) (AWS 白皮書）
+ [使用共用資源](https://docs.aws.amazon.com/ram/latest/userguide/working-with.html) (AWS RAM 文件）
+ [使用傳輸閘道 ](https://docs.aws.amazon.com/vpc/latest/tgw/working-with-transit-gateways.html)(AWS Transit Gateway 文件）

# 使用 Application Load Balancer 在 Oracle WebLogic 上設定 Oracle JD Edwards EnterpriseOne 的 HTTPS 加密
<a name="configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer"></a>

*Thanigaivel Thirumalai，Amazon Web Services*

## 總結
<a name="configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer-summary"></a>

此模式說明如何為 Oracle WebLogic 工作負載上的 Oracle JD Edwards EnterpriseOne 中的 SSL 卸載設定 HTTPS 加密。此方法會加密使用者瀏覽器和負載平衡器之間的流量，以消除 EnterpriseOne 伺服器的加密負擔。

許多使用者使用 AWS Application Load Balancer 水平擴展 EnterpriseOne JAVA 虛擬機器 (JVM) 層。 [ Application Load Balancer ](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html)負載平衡器可做為用戶端的單一聯絡點，並將傳入流量分配到多個 JVMs。或者，負載平衡器可以將流量分散到多個可用區域，並提高 EnterpriseOne 的可用性。

此模式中描述的程序會設定瀏覽器和負載平衡器之間的加密，而不是加密負載平衡器和 EnterpriseOne JVMs之間的流量。此方法稱為 *SSL 卸載*。將 SSL 解密程序從 EnterpriseOne Web 或應用程式伺服器卸載至 Application Load Balancer，可減輕應用程式端的負擔。在負載平衡器終止 SSL 之後，未加密的流量會路由到 AWS 上的應用程式。

[Oracle JD Edwards EnterpriseOne](https://www.oracle.com/applications/jd-edwards-enterpriseone/) 是企業資源規劃 (ERP) 解決方案，適用於生產、建構、分發、服務或管理產品或實體資產的組織。JD Edwards EnterpriseOne 支援各種硬體、作業系統和資料庫平台。

## 先決條件和限制
<a name="configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer-prereqs"></a>

**先決條件**
+ 作用中的 AWS 帳戶
+ AWS Identity and Access Management (IAM) 角色，具有發出 AWS 服務呼叫和管理 AWS 資源的許可
+ SSL 憑證

**產品版本**
+ 此模式已使用 Oracle WebLogic 12c 進行測試，但您也可以使用其他版本。

## Architecture
<a name="configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer-architecture"></a>

執行 SSL 卸載的方法有多種。此模式使用 Application Load Balancer 和 Oracle HTTP Server (OHS)，如下圖所示。

![\[使用負載平衡器和 OHS 卸載 SSL\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/c62b976b-31e4-42ca-b7e8-13f7c9d9a187/images/2ae2d0eb-b9f3-41f8-ad86-9af3aade7072.png)


下圖顯示 JD Edwards EnterpriseOne、Application Load Balancer 和 Java Application Server (JAS) JVM 配置。

![\[EnterpriseOne、負載平衡器和 JAS JVM 配置\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/c62b976b-31e4-42ca-b7e8-13f7c9d9a187/images/72ea35b0-2907-48b3-aeb7-0c5d9a3b831b.png)


## 工具
<a name="configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer-tools"></a>

**AWS 服務**
+ [Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/) 會將傳入的應用程式流量分散到多個可用區域中的多個目標，例如 Amazon Elastic Compute Cloud (Amazon EC2 執行個體）。
+ [AWS Certificate Manager (ACM)](https://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html) 可協助您建立、存放和續約公有和私有 SSL/TLS X.509 憑證和金鑰，以保護 AWS 網站和應用程式。
+ [Amazon Route 53](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html) 是一種可用性高、可擴展性強的 DNS Web 服務。

## 最佳實務
<a name="configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer-best-practices"></a>
+ 如需 ACM 最佳實務，請參閱 [ACM 文件。](https://docs.aws.amazon.com/acm/latest/userguide/acm-bestpractices.html)

## 史詩
<a name="configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer-epics"></a>

### 設定 WebLogic 和 OHS
<a name="set-up-weblogic-and-ohs"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 安裝和設定 Oracle 元件。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer.html) | JDE CNC、WebLogic 管理員 | 
| 在網域層級啟用 WebLogic 外掛程式。 | 負載平衡需要 WebLogic 外掛程式。若要啟用外掛程式：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer.html) | JDE CNC、WebLogic 管理員 | 
| 編輯組態檔案。 | `mod_wl_ohs.conf` 檔案會設定從 OHS 到 WebLogic 的代理請求。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer.html)<pre><VirtualHost *:8000><br /><Location /jde><br />WLSRequest On<br />SetHandler weblogic-handler<br />WebLogicHost localhost<br />WebLogicPort 8000<br />WLProxySSL On<br />WLProxySSLPassThrough On<br /></Location><br /></VirtualHost></pre> | JDE CNC、WebLogic 管理員 | 
| 使用 Enterprise Manager 啟動 OHS。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer.html) | JDE CNC、WebLogic 管理員 | 

### 設定 Application Load Balancer
<a name="configure-the-application-load-balancer"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 設定目標群組。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer.html)如需詳細說明，請參閱 [Elastic Load Balancing 文件](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-target-group.html)。 | AWS 管理員 | 
| 設定負載平衡器。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer.html) | AWS 管理員 | 
| 新增 Route 53 (DNS) 記錄。 | （選用） 您可以為子網域新增 Amazon Route 53 DNS 記錄。此記錄會指向您的 Application Load Balancer。如需說明，請參閱 [Route 53 文件](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-creating.html)。 | AWS 管理員 | 

## 疑難排解
<a name="configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer-troubleshooting"></a>


| 問題 | 解決方案 | 
| --- | --- | 
| HTTP 伺服器不會顯示。 | 如果 **HTTP 伺服器**未出現在 Enterprise Manager 主控台**的目標導覽**清單中，請依照下列步驟執行：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer.html)建立執行個體並啟用變更後，您就可以在**目標導覽**面板中看到 HTTP 伺服器。 | 

## 相關資源
<a name="configure-https-encryption-for-oracle-jd-edwards-enterpriseone-on-oracle-weblogic-by-using-an-application-load-balancer-resources"></a>

**AWS 文件**
+ [Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html)
+ [使用公有託管區域](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/AboutHZWorkingWith.html)
+ [使用私有託管區域](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-private.html)

**Oracle 文件：**
+ [Oracle WebLogic Server Proxy 外掛程式概觀](https://docs.oracle.com/middleware/1221/webtier/develop-plugin/overview.htm#PLGWL391)
+ [使用 Infrastructure Installer 安裝 WebLogic Server](https://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/12c/12_2_1/02-01-004-InstallWLSInfrastructure/installweblogicinfrastructure.html)
+ [安裝和設定 Oracle HTTP 伺服器 ](https://docs.oracle.com/middleware/1221/core/install-ohs/toc.htm)

# 透過私有網路連線至 Application Migration Service 資料和控制平面
<a name="connect-to-application-migration-service-data-and-control-planes-over-a-private-network"></a>

*Dipin Jain 和 Mike Kuznetsov，Amazon Web Services*

## 總結
<a name="connect-to-application-migration-service-data-and-control-planes-over-a-private-network-summary"></a>

此模式說明如何使用介面 VPC 端點，連線到私有安全網路上 AWS Application Migration Service 的資料平面和控制平面。

Application Migration Service 是高度自動化lift-and-shift（重新託管） 解決方案，可簡化、加速和降低將應用程式遷移至 的成本 AWS。它可讓公司重新託管大量實體、虛擬或雲端伺服器，而不會發生相容性問題、效能中斷或長切換時段。Application Migration Service 可從 取得 AWS 管理主控台。這可與其他 無縫整合 AWS 服務，例如 AWS CloudTrail Amazon CloudWatch 和 AWS Identity and Access Management (IAM)。

您可以透過使用 Site-to-Site VPN 服務或 Application Migration Service 中的 VPC 對等互連 AWS Direct Connect，從來源資料中心連線到資料平面，也就是做為目的地 VPC 中資料複寫之暫存區域的子網路。您也可以使用 支援的[介面 VPC 端點](https://docs.aws.amazon.com/vpc/latest/privatelink/vpce-interface.html) AWS PrivateLink ，透過私有網路連線至 Application Migration Service 控制平面。 

## 先決條件和限制
<a name="connect-to-application-migration-service-data-and-control-planes-over-a-private-network-prereqs"></a>

**先決條件**
+ **預備區域子網路** – 在您設定 Application Migration Service 之前，請建立子網路，做為從來源伺服器複寫至 AWS （即資料平面） 之資料的預備區域。首次存取 Application Migration Service 主控台時，您必須在[複寫設定範本](https://docs.aws.amazon.com/mgn/latest/ug/template-vs-server.html)中指定此子網路。您可以在複寫設定範本中覆寫特定來源伺服器的此子網路。雖然您可以在 中使用現有的子網路 AWS 帳戶，但我們建議您為此建立新的專用子網路。
+ **網路需求** – Application Migration Service 在預備區域子網路中啟動的複寫伺服器必須能夠將資料傳送至位於 的 Application Migration Service API 端點`https://mgn.<region>.amazonaws.com/`，其中 `<region>`是 AWS 區域 您要複寫之 的程式碼 （例如 `https://mgn.us-east-1.amazonaws.com`)。下載 Application Migration Service 軟體時，需要 Amazon Simple Storage Service (Amazon S3) 服務 URLs。
  +  AWS 複寫代理程式安裝程式應可存取 AWS 區域 與 Application Migration Service 搭配使用之 的 Amazon Simple Storage Service (Amazon S3) 儲存貯體 URL。
  + 預備區域子網路應可存取 Amazon S3。
  + 安裝 AWS 複寫代理程式的來源伺服器必須能夠將資料傳送至預備區域子網路中的複寫伺服器，以及傳送至位於 的 Application Migration Service API 端點`https://mgn.<region>.amazonaws.com/`。

下表列出所需的連接埠。


| 
| 
| 來源 | 目標 | 站點 | 如需詳細資訊，請參閱 | 
| --- |--- |--- |--- |
| 來源資料中心 | Amazon S3 URLs | 443 (TCP) | [透過 TCP 連接埠 443 的通訊](https://docs.aws.amazon.com/mgn/latest/ug/Network-Requirements.html#TCP-443) | 
| 來源資料中心 | AWS 區域 Application Migration Service 的 特定主控台地址 | 443 (TCP) | [透過 TCP 連接埠 443 的來源伺服器與 Application Migration Service 之間的通訊](https://docs.aws.amazon.com/mgn/latest/ug/Network-Requirements.html#Source-Manager-TCP-443) | 
| 來源資料中心 | 暫存區域子網路 | 1500 (TCP) | [透過 TCP 連接埠 1500 的來源伺服器與預備區域子網路之間的通訊](https://docs.aws.amazon.com/mgn/latest/ug/Network-Requirements.html#Communication-TCP-1500) | 
| 暫存區域子網路 | AWS 區域 Application Migration Service 的 特定主控台地址 | 443 (TCP) | [透過 TCP 連接埠 443 的預備區域子網路與 Application Migration Service 之間的通訊](https://docs.aws.amazon.com/mgn/latest/ug/Network-Requirements.html#Communication-TCP-443-Staging) | 
| 暫存區域子網路 | Amazon S3 URLs | 443 (TCP) | [透過 TCP 連接埠 443 的通訊](https://docs.aws.amazon.com/mgn/latest/ug/Network-Requirements.html#TCP-443) | 
| 暫存區域子網路 | 子網路的 Amazon Elastic Compute Cloud (Amazon EC2) 端點 AWS 區域 | 443 (TCP) | [透過 TCP 連接埠 443 的通訊](https://docs.aws.amazon.com/mgn/latest/ug/Network-Requirements.html#TCP-443) | 

**限制**

Application Migration Service 目前無法在所有 AWS 區域 和 作業系統中使用。
+ [支援的 AWS 區域](https://docs.aws.amazon.com/mgn/latest/ug/supported-regions.html)
+ [支援的作業系統](https://docs.aws.amazon.com/mgn/latest/ug/Supported-Operating-Systems.html)

## Architecture
<a name="connect-to-application-migration-service-data-and-control-planes-over-a-private-network-architecture"></a>

下圖說明典型遷移的網路架構。如需此架構的詳細資訊，請參閱 [Application Migration Service 文件](https://docs.aws.amazon.com/mgn/latest/ug/Network-Settings-Video.html)和 [Application Migration Service 架構和網路架構影片](https://youtu.be/ao8geVzmmRo)。

![\[典型遷移的 Application Migration Service 網路架構\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/21346c0f-0643-4f4f-b21f-fdfe24fc6a8f/images/546598b2-8026-4849-a441-eaa2bc2bf6bb.png)


下列詳細檢視顯示預備區域 VPC 中連接 Amazon S3 和 Application Migration Service 的介面 VPC 端點組態。

![\[Application Migration Service 的典型遷移網路架構 - 詳細檢視\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/21346c0f-0643-4f4f-b21f-fdfe24fc6a8f/images/bd0dfd42-4ab0-466f-b696-804dedcf4513.png)


## 工具
<a name="connect-to-application-migration-service-data-and-control-planes-over-a-private-network-tools"></a>
+ [AWS Application Migration Service](https://docs.aws.amazon.com/mgn/latest/ug/what-is-application-migration-service.html) 簡化、加速並降低重新託管應用程式的成本 AWS。
+ [介面 VPC 端點](https://docs.aws.amazon.com/vpc/latest/privatelink/vpce-interface.html)可讓您連線至由 提供支援的服務， AWS PrivateLink 而不需要網際網路閘道、NAT 裝置、VPN 連線或 AWS Direct Connect 連線。VPC 中的執行個體不需要公有 IP 地址，即可與服務中的資源通訊。VPC 與另一個服務之間的流量都會保持在 Amazon 網路的範圍內。

## 史詩
<a name="connect-to-application-migration-service-data-and-control-planes-over-a-private-network-epics"></a>

### 建立 Application Migration Service、Amazon EC2 和 Amazon S3 的端點
<a name="create-endpoints-for-mgn-ec2-and-s3"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 設定 Application Migration Service 的介面端點。 | 來源資料中心和預備區域 VPC 會透過您在目標預備區域 VPC 中建立的介面端點，私下連線至 Application Migration Service 控制平面。若要建立端點：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/connect-to-application-migration-service-data-and-control-planes-over-a-private-network.html)如需詳細資訊，請參閱[《Amazon VPC 文件》中的 AWS 服務 使用介面 VPC 端點存取](https://docs.aws.amazon.com/vpc/latest/privatelink/vpce-interface.html) 。 | 遷移潛在客戶 | 
| 設定 Amazon EC2 的介面端點。 | 預備區域 VPC 會透過您在目標預備區域 VPC 中建立的介面端點，私下連線至 Amazon EC2 API。若要建立端點，請遵循上一個案例提供的指示。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/connect-to-application-migration-service-data-and-control-planes-over-a-private-network.html) | 遷移潛在客戶 | 
| 設定 Amazon S3 的介面端點。 | 來源資料中心和預備區域 VPC 會透過您在目標預備區域 VPC 中建立的介面端點，私下連線至 Amazon S3 API。若要建立端點，請遵循第一個案例提供的指示。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/connect-to-application-migration-service-data-and-control-planes-over-a-private-network.html)您使用界面端點，因為閘道端點連線無法從 VPC 延伸。（如需詳細資訊，請參閱 [AWS PrivateLink 文件](https://docs.aws.amazon.com/vpc/latest/privatelink/vpce-gateway.html)。) | 遷移潛在客戶 | 
| 設定 Amazon S3 Gateway 端點。 | 在組態階段，複寫伺服器必須連線至 S3 AWS 儲存貯體，才能下載複寫伺服器的軟體更新。不過，Amazon S3 介面端點不支援私有 DNS 名稱*，*而且無法將 Amazon S3 端點 DNS 名稱提供給複寫伺服器。 若要緩解此問題，您可以在預備區域子網路所屬的 VPC 中建立 Amazon S3 閘道端點，並使用相關路由更新預備子網路的路由表。如需詳細資訊，請參閱 AWS PrivateLink 文件中的[建立閘道端點](https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-s3.html#create-gateway-endpoint-s3)。 | 雲端管理員 | 
| 設定內部部署 DNS 以解析端點的私有 DNS 名稱。 | Application Migration Service 和 Amazon EC2 的介面端點具有可在 VPC 中解析的私有 DNS 名稱。不過，您也需要設定內部部署伺服器來解析這些介面端點的私有 DNS 名稱。設定這些伺服器的方法有多種。在此模式中，我們透過將內部部署 DNS 查詢轉送到暫存區域 VPC 中的 Amazon Route 53 Resolver 傳入端點來測試此功能。如需詳細資訊，請參閱 Route 53 文件中的[解決 VPCs 與網路之間的 DNS 查詢](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-overview-DSN-queries-to-vpc.html)。 | 遷移工程師 | 

### 透過私有連結連線至 Application Migration Service 控制平面
<a name="connect-to-the-mgn-control-plane-over-a-private-link"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 使用 AWS 安裝複寫代理程式 AWS PrivateLink。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/connect-to-application-migration-service-data-and-control-planes-over-a-private-network.html)以下是 Linux 的範例：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/connect-to-application-migration-service-data-and-control-planes-over-a-private-network.html)在您與 Application Migration Service AWS 建立連線並安裝複寫代理程式之後，請依照 [Application Migration Service 文件](https://docs.aws.amazon.com/mgn/latest/ug/migration-workflow-gs.html)的指示，將來源伺服器遷移至目標 VPC 和子網路。 | 遷移工程師 | 

## 相關資源
<a name="connect-to-application-migration-service-data-and-control-planes-over-a-private-network-resources"></a>

**Application Migration Service 文件**
+ [概念](https://docs.aws.amazon.com/mgn/latest/ug/CloudEndure-Concepts.html)
+ [遷移工作流程](https://docs.aws.amazon.com/mgn/latest/ug/migration-workflow-gs.html)
+ [快速入門指南](https://docs.aws.amazon.com/mgn/latest/ug/quick-start-guide-gs.html)
+ [常見問答集](https://docs.aws.amazon.com/mgn/latest/ug/FAQ.html)
+ [疑難排解](https://docs.aws.amazon.com/mgn/latest/ug/troubleshooting.html)

**其他資源**
+ [AWS 使用 VPC 介面端點在 上的多帳戶架構中重新託管您的應用程式](https://docs.aws.amazon.com/prescriptive-guidance/latest/rehost-multi-account-architecture-interface-endpoints/) (AWS 方案指引指南）
+ [AWS Application Migration Service – 技術簡介](https://www.aws.training/Details/eLearning?id=71732) (AWS 培訓和認證演練）
+ [AWS Application Migration Service 架構和網路架構](https://youtu.be/ao8geVzmmRo) （影片）

## 其他資訊
<a name="connect-to-application-migration-service-data-and-control-planes-over-a-private-network-additional"></a>

針對 **Linux 伺服器上的複寫代理程式安裝****進行故障診斷 ***AWS *

如果您在 Amazon Linux 伺服器上收到 **gcc** 錯誤，請設定套件儲存庫，並使用下列命令：

```
## sudo yum groupinstall "Development Tools"
```

# 使用 AWS CloudFormation 自訂資源和 Amazon SNS 建立 Infoblox 物件
<a name="create-infoblox-objects-using-aws-cloudformation-custom-resources-and-amazon-sns"></a>

*Tim Sutton，Amazon Web Services*

## 總結
<a name="create-infoblox-objects-using-aws-cloudformation-custom-resources-and-amazon-sns-summary"></a>

**注意**： AWS Cloud9 不再提供給新客戶。的現有客戶 AWS Cloud9 可以繼續正常使用服務。[進一步了解](https://aws.amazon.com/blogs/devops/how-to-migrate-from-aws-cloud9-to-aws-ide-toolkits-or-aws-cloudshell/)

Infoblox 網域名稱系統 (DNS)、動態主機組態通訊協定 (DHCP) 和 IP 地址管理 ([Infoblox DDI](https://www.infoblox.com/products/ddi/)) 可讓您集中並有效控制複雜的混合環境。使用 Infoblox DDI，除了使用相同的設備管理內部部署和 Amazon Web Services (AWS) 雲端上的 DNS 之外，您還可以在一個授權 IP 地址管理 (IPAM) 資料庫中探索和記錄所有網路資產。

此模式說明如何透過呼叫 Infoblox WAPI API，使用 AWS CloudFormation 自訂資源來建立 Infoblox 物件 （例如 DNS 記錄或 IPAM 物件）。如需 Infoblox WAPI 的詳細資訊，請參閱 Infoblox [文件中的 WAPI](https://www.infoblox.com/wp-content/uploads/infoblox-deployment-infoblox-rest-api.pdf) 文件。

透過使用此模式的方法，除了移除建立記錄和佈建網路的手動程序之外，您還可以取得 AWS 和內部部署環境的 DNS 記錄和 IPAM 組態的統一檢視。您可以針對下列使用案例使用此模式的方法：
+ 在建立 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體之後新增 A 記錄 
+ 在建立 Application Load Balancer 之後新增 CNAME 記錄
+ 在建立虛擬私有雲端 (VPC) 之後新增網路物件
+ 提供下一個網路範圍，並使用該範圍來建立子網路

您也可以擴展此模式並使用其他 Infoblox 裝置功能，例如新增不同的 DNS 記錄類型或設定 Infoblox vDiscovery。 

模式使用中hub-and-spoke設計，其中中樞需要連線至 AWS 雲端或內部部署上的 Infoblox 設備，並使用 AWS Lambda 呼叫 Infoblox API。輪輻位於 AWS Organizations 中相同組織的相同或不同帳戶中，並使用 AWS CloudFormation 自訂資源呼叫 Lambda 函數。

## 先決條件和限制
<a name="create-infoblox-objects-using-aws-cloudformation-custom-resources-and-amazon-sns-prereqs"></a>

**先決條件**
+ 安裝在 AWS 雲端、內部部署或兩者上的現有 Infoblox 設備或網格，並使用可管理 IPAM 和 DNS 動作的管理員使用者進行設定。如需詳細資訊，請參閱 Infoblox 文件中的[關於管理員帳戶](https://docs.infoblox.com/display/nios86/About+Admin+Accounts)。 
+ 您要在 Infoblox 設備上新增記錄的現有 DNS 授權區域。如需詳細資訊，請參閱 Infoblox 文件中的[設定授權區域](https://docs.infoblox.com/display/nios86/Configuring+Authoritative+Zones)。 
+ AWS Organizations 中的兩個作用中 AWS 帳戶。一個帳戶是中樞帳戶，另一個帳戶是輻條帳戶。
+ 中樞和輻條帳戶必須位於相同的 AWS 區域。 
+ 中樞帳戶的 VPC 必須連線至 Infoblox 設備；例如，使用 AWS Transit Gateway 或 VPC 對等互連。
+ [AWS Serverless Application Model (AWS SAM)](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html)，使用 AWS Cloud9 或 AWS CloudShell 在本機安裝和設定。
+ `Infoblox-Hub.zip` 和 `ClientTest.yaml` 檔案 （已連接），下載至包含 AWS SAM 的本機環境。

**限制**
+ AWS CloudFormation 自訂資源的服務權杖必須來自建立堆疊的相同區域。我們建議您在每個區域中使用中樞帳戶，而不是在一個區域中建立 Amazon Simple Notification Service (Amazon SNS) 主題，並在另一個區域中呼叫 Lambda 函數。

**產品版本**
+ Infoblox WAPI 2.7 版

## Architecture
<a name="create-infoblox-objects-using-aws-cloudformation-custom-resources-and-amazon-sns-architecture"></a>

下圖顯示此模式的工作流程。 

![\[使用 AWS CloudFormation 自訂資源和 Amazon SNS 建立 Infoblox 物件。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/8d609d3f-6f5e-4084-849f-ca191db8055e/images/3594a064-e103-4211-84b7-da67c41ebb15.png)


下圖顯示此模式解決方案的下列元件：

1. AWS CloudFormation 自訂資源可讓您在AWS CloudFormation、更新或刪除堆疊時執行的範本中撰寫自訂佈建邏輯。當您建立堆疊時，AWS CloudFormation 會將`create`請求傳送至由 EC2 執行個體上執行之應用程式監控的 SNS 主題。

1. 來自 AWS CloudFormation 自訂資源的 Amazon SNS 通知會透過特定 AWS Key Management Service (AWS KMS) 金鑰加密，且存取權僅限於 Organizations 中組織中的帳戶。SNS 主題會啟動呼叫 Infoblox WAPI API 的 Lambda 資源。

1. Amazon SNS 會叫用下列 Lambda 函數，以使用 Infoblox WAPI URL、使用者名稱和密碼 AWS Secrets Manager Amazon Resource Name (ARNs) 做為環境變數： 
   + `dnsapi.lambda_handler` – 從 AWS CloudFormation `DNSName`自訂資源接收 `DNSType`、 和 `DNSValue`值，並使用它們來建立 DNS A 記錄和 CNAMES。
   + `ipaddr.lambda_handler` – 從 AWS CloudFormation 自訂資源接收 `VPCCIDR`、`SubnetPrefix`、 `Type`和 `Network Name`值，並使用這些資料將網路資料新增至 Infoblox IPAM 資料庫，或為自訂資源提供可用於建立新子網路的下一個可用網路。
   + `describeprefixes.lambda_handler` – 使用`"com.amazonaws."+Region+".s3"`篩選條件來擷取所需的 ，以呼叫 `describe_managed_prefix_lists` AWS API`prefix ID`。
**重要**  
這些 Lambda 函數是以 Python 撰寫，彼此類似，但呼叫不同的 APIs。

1. 您可以將 Infoblox 網格部署為實體、虛擬或雲端型網路設備。 它可以使用一系列 Hypervisor 部署在內部部署或做為虛擬設備，包括 VMware ESXi、Microsoft Hyper-V、Linux KVM 和 Xen。您也可以使用 Amazon Machine Image (AMI) 在 AWS 雲端上部署 Infoblox 網格。

1. 此圖顯示 Infoblox 網格的混合解決方案，它將 DNS 和 IPAM 提供給 AWS 雲端和內部部署上的資源。

**技術堆疊**
+ AWS CloudFormation
+ IAM
+ AWS KMS
+ AWS Lambda
+ AWS SAM
+ AWS Secrets Manager
+ Amazon SNS
+ Amazon VPC 

## 工具
<a name="create-infoblox-objects-using-aws-cloudformation-custom-resources-and-amazon-sns-tools"></a>
+ [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) 可協助您設定 AWS 資源、快速且一致地佈建資源，以及在整個 AWS 帳戶和區域的生命週期中管理這些資源。
+ [AWS Identity and Access Management (IAM)](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html) 可透過控制已驗證並獲授權使用的人員，協助您安全地管理對 AWS 資源的存取。
+ [AWS Key Management Service (AWS KMS)](https://docs.aws.amazon.com/kms/latest/developerguide/overview.html) 可協助您建立和控制密碼編譯金鑰，以協助保護您的資料。
+ [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) 是一種運算服務，可協助您執行程式碼，而無需佈建或管理伺服器。它只會在需要時執行程式碼並自動擴展，因此您只需按使用的運算時間付費。
+ [AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html) 是一種帳戶管理服務，可協助您將多個 AWS 帳戶合併到您建立並集中管理的組織。
+ [AWS Secrets Manager](https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html) 可協助您以 API 呼叫 Secrets Manager，以程式設計方式擷取秘密，取代程式碼中的硬式編碼登入資料，包括密碼。
+ [AWS Serverless Application Model (AWS SAM)](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) 是一種開放原始碼架構，可協助您在 AWS 雲端中建置無伺服器應用程式。
+ [Amazon Simple Notification Service (Amazon SNS)](https://docs.aws.amazon.com/sns/latest/dg/welcome.html) 可協助您協調和管理發佈者和用戶端之間的訊息交換，包括 Web 伺服器和電子郵件地址。
+ [Amazon Virtual Private Cloud (Amazon VPC)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html) 可協助您在已定義的虛擬網路中啟動 AWS 資源。這個虛擬網路類似於您在自己的資料中心內操作的傳統網路，具有使用可擴展的 AWS 基礎設施的優勢。

**Code**

您可以使用`ClientTest.yaml`範例 AWS CloudFormation 範本 （已連接） 來測試 Infoblox 中樞。您可以自訂 AWS CloudFormation 範本，以包含下表中的自訂資源。


|  | 
| --- |
| 使用 Infoblox 輻條自訂資源建立 A 記錄 | 傳回值： `infobloxref ` – Infoblox 參考資源範例：

```
ARECORDCustomResource:

  Type: "Custom::InfobloxAPI"

  Properties:

    ServiceToken: !Sub  arn:aws:sns:${AWS::Region}:${HubAccountID}:RunInfobloxDNSFunction

    DNSName: 'arecordtest.company.com'

    DNSType: 'ARecord' 

    DNSValue: '10.0.0.1'
``` | 
| --- |--- |
| 使用 Infoblox 語音自訂資源建立 CNAME 記錄 | **傳回值**： `infobloxref ` – Infoblox 參考**資源範例**：<pre>CNAMECustomResource:<br /><br />  Type: "Custom::InfobloxAPI"<br /><br />  Properties:<br /><br />    ServiceToken: !Sub arn:aws:sns:${AWS::Region}:${HubAccountID}:RunInfoblox    <br /><br />    DNSFunction<br /><br />    DNSName: 'cnametest.company.com'<br /><br />    DNSType: 'cname' <br /><br />    DNSValue: 'aws.amazon.com'</pre> | 
| 使用 Infoblox 輻條自訂資源建立網路物件 | **傳回值：**`infobloxref ` – Infoblox 參考`network` – 網路範圍 （與 相同`VPCCIDR`)**資源範例：**<pre>VPCCustomResource:<br /><br />  Type: 'Custom::InfobloxAPI'<br /><br />  Properties:<br /><br />    ServiceToken: !Sub  arn:aws:sns:${AWS::Region}:${HubAccountID}:RunInfobloxNextSubnetFunction<br /><br />    VPCCIDR: !Ref VpcCIDR<br /><br />    Type: VPC<br /><br />    NetworkName: My-VPC</pre> | 
| 使用 Infoblox 輻條自訂資源擷取下一個可用的子網路 | **傳回值：**`infobloxref` – Infoblox 參考`network ` – 子網路的網路範圍**資源範例：**<pre>Subnet1CustomResource:<br /><br />  Type: 'Custom::InfobloxAPI'<br /><br />  DependsOn: VPCCustomResource<br /><br />  Properties:<br /><br />    ServiceToken: !Sub  arn:aws:sns:${AWS::Region}:${HubAccountID}:RunInfobloxNextSubnetFunction<br /><br />    VPCCIDR: !Ref VpcCIDR<br /><br />    Type: Subnet<br /><br />    SubnetPrefix: !Ref SubnetPrefix<br /><br />NetworkName: My-Subnet</pre> | 

## 史詩
<a name="create-infoblox-objects-using-aws-cloudformation-custom-resources-and-amazon-sns-epics"></a>

### 建立和設定中樞帳戶的 VPC
<a name="create-and-configure-the-hub-accountrsquor-s-vpc"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立與 Infoblox 設備連線的 VPC。 | 登入您中樞帳戶的 AWS 管理主控台，並依照 AWS Quick [Starts 中 AWS Cloud Quick Start 參考部署上的 Amazon VPC](https://aws-quickstart.github.io/quickstart-aws-vpc/) 中的步驟建立 VPC。VPC 必須具有與 Infoblox 設備的 HTTPS 連線，建議您為此連線使用私有子網路。 | 網路管理員、系統管理員 | 
| （選用） 建立私有子網路的 VPC 端點。 | VPC 端點為您的私有子網路提供公有服務的連線。需要下列端點：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-infoblox-objects-using-aws-cloudformation-custom-resources-and-amazon-sns.html)如需為私有子網路建立端點的詳細資訊，請參閱 Amazon [VPC 文件中的 VPC 端點](https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints.html)。 | 網路管理員、系統管理員 | 

### 部署 Infoblox 中樞
<a name="deploy-the-infoblox-hub"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建置 AWS SAM 範本。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-infoblox-objects-using-aws-cloudformation-custom-resources-and-amazon-sns.html) | 開發人員、系統管理員 | 
| 部署 AWS SAM 範本。 | `sam deploy` 命令會取得必要的參數並將其儲存至 `samconfig.toml` 檔案、將 AWS CloudFormation 範本和 Lambda 函數存放在 S3 儲存貯體，然後將 AWS CloudFormation 範本部署到您的中樞帳戶。 下列範例程式碼示範如何部署 AWS SAM 範本：<pre>$ sam deploy --guided<br /><br />Configuring SAM deploy<br />======================<br />        Looking for config file [samconfig.toml] :  Found<br />        Reading default arguments  :  Success<br />        Setting default arguments for 'sam deploy'<br />        =========================================<br />        Stack Name [Infoblox-Hub]:<br />        AWS Region [eu-west-1]:<br />        Parameter InfobloxUsername:<br />        Parameter InfobloxPassword:<br />        Parameter InfobloxIPAddress [xxx.xxx.xx.xxx]:<br />        Parameter AWSOrganisationID [o-xxxxxxxxx]:<br />        Parameter VPCID [vpc-xxxxxxxxx]:<br />        Parameter VPCCIDR [xxx.xxx.xxx.xxx/16]:<br />        Parameter VPCSubnetID1 [subnet-xxx]:<br />        Parameter VPCSubnetID2 [subnet-xxx]:<br />        Parameter VPCSubnetID3 [subnet-xxx]:<br />        Parameter VPCSubnetID4 []: <br />        #Shows you resources changes to be deployed and require a 'Y' to initiate deploy<br />        Confirm changes before deploy [Y/n]: y<br />        #SAM needs permission to be able to create roles to connect to the resources in your template<br />Allow SAM CLI IAM role creation [Y/n]: n<br />Capabilities [['CAPABILITY_NAMED_IAM']]:<br />        Save arguments to configuration file [Y/n]: y<br />        SAM configuration file [samconfig.toml]:<br />        SAM configuration environment [default]: </pre>您每次都必須使用 `--guided`選項，因為 Infoblox 登入憑證不會存放在 `samconfig.toml` 檔案中。 | 開發人員、系統管理員 | 

## 相關資源
<a name="create-infoblox-objects-using-aws-cloudformation-custom-resources-and-amazon-sns-resources"></a>
+ [使用 Postman 開始使用 WAPIs ](https://blogs.infoblox.com/community/getting-started-with-wapis-using-postman/) (Infoblox 部落格）
+ [使用 BYOL 模型佈建 AWS 的 vNIOS ](https://docs.infoblox.com/display/NAIG/Provisioning+vNIOS+for+AWS+Using+the+BYOL+Model)(Infoblox 文件）
+ [quickstart-aws-vpc](https://github.com/aws-quickstart/quickstart-aws-vpc) (GitHub 儲存庫）
+ [describe\$1managed\$1prefix\$1lists](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_managed_prefix_lists) （適用於 Python 的 AWS 開發套件文件）

## 附件
<a name="attachments-8d609d3f-6f5e-4084-849f-ca191db8055e"></a>

若要存取與本文件相關聯的其他內容，請解壓縮下列檔案： [attachment.zip](samples/p-attach/8d609d3f-6f5e-4084-849f-ca191db8055e/attachments/attachment.zip)

# AWS 使用 Terraform 在 上建立階層式多區域 IPAM 架構
<a name="multi-region-ipam-architecture"></a>

*Donny Schreiber，Amazon Web Services*

## 總結
<a name="multi-region-ipam-architecture-summary"></a>

*IP 地址管理 (IPAM)* 是網路管理的關鍵元件，隨著組織擴展其雲端基礎設施而變得越來越複雜。如果沒有適當的 IPAM，組織會面臨 IP 地址衝突、地址空間浪費，以及可能導致中斷和應用程式停機的複雜故障診斷的風險。此模式示範如何使用 HashiCorp Terraform 為 AWS 企業環境實作全面的 IPAM 解決方案。它可協助組織建立階層式多區域 IPAM 架構，以促進組織中所有 AWS 帳戶 的集中式 IP 地址管理[AWS](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html#organization-structure)。

此模式可協助您使用複雜的四層集區階層實作 [Amazon VPC IP Address Manager](https://docs.aws.amazon.com/vpc/latest/ipam/what-it-is-ipam.html)：頂層集區、區域集區、業務單位集區和環境特定集區。此結構支援適當的 IP 地址控管，同時啟用將 IP 管理委派給組織內適當的團隊。解決方案使用 AWS Resource Access Manager (AWS RAM) 在整個組織中無縫共用 IP Address Manager 集區。 AWS RAM 集中和標準化 IPAM 規格，團隊可以在所有受管帳戶中建置這些規格。

此模式可協助您達成下列目標：
+ 自動化跨 AWS 區域、業務單位和環境的 IP 地址配置。
+ 透過程式設計驗證強制執行組織網路政策。
+ 隨著業務需求的演進，有效率地擴展網路基礎設施。
+ 透過集中管理 IP 地址空間來降低營運開銷。
+ 使用自助式 CIDR 範圍配置加速雲端原生工作負載部署。
+ 透過以政策為基礎的控制和驗證來防止解決衝突。

## 先決條件和限制
<a name="multi-region-ipam-architecture-prereqs"></a>

**先決條件**
+ 一或多個 AWS 帳戶，以組織身分管理 AWS Organizations。
+ 做為 IP Address Manager 委派管理員的網路中樞或網路管理帳戶。
+ AWS Command Line Interface (AWS CLI)，[已安裝](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)並[設定](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)。
+ [已安裝](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) Terraform 1.5.0 版或更新版本。
+ AWS Terraform 的提供者，[已設定](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)。
+ 管理 [IP Address Manager](https://docs.aws.amazon.com/vpc/latest/ipam/iam-ipam.html)、 [AWS RAM](https://docs.aws.amazon.com/ram/latest/userguide/security-iam.html)和[虛擬私有雲端 (VPCs](https://docs.aws.amazon.com/vpc/latest/userguide/security-iam.html)許可，已在 AWS Identity and Access Management (IAM) 中設定。

**限制**
+ IP Address Manager [受限於服務配額](https://docs.aws.amazon.com/vpc/latest/ipam/quotas-ipam.html)。集區的預設服務配額為每個範圍 50 個。為 6 個區域、2 個業務單位和 4 個環境執行此部署會建立 67 個集區。因此，可能需要增加配額。
+ 在配置資源之後修改或刪除 IP Address Manager 集區可能會導致相依性問題。您必須先[釋出配置](https://docs.aws.amazon.com/vpc/latest/ipam/release-alloc-ipam.html)，才能刪除集區。
+ 在 IP Address Manager 中，[資源監控](https://docs.aws.amazon.com/vpc/latest/ipam/monitor-cidr-compliance-ipam.html)可能會在反映資源變更時發生些微延遲。此延遲可能約為 20 分鐘。
+ IP Address Manager 無法自動強制執行不同範圍的 IP 地址唯一性。
+ 自訂標籤必須遵循[AWS 標記最佳實務](https://docs.aws.amazon.com/whitepapers/latest/tagging-best-practices/tagging-best-practices.html)。例如，每個金鑰都必須是唯一的，且不能以 開頭`aws:`。
+ 將 IP Address Manager 與組織外部的帳戶整合時，有一些[考量和限制](https://docs.aws.amazon.com/vpc/latest/ipam/enable-integ-ipam-outside-org-considerations.html)。

## Architecture
<a name="multi-region-ipam-architecture-architecture"></a>

**目標架構**

*IP Address Manager 組態和集區階層*

下圖顯示目標架構的邏輯建構。*範圍*是 IP Address Manager 中的最高層級容器。每個範圍代表單一網路的 IP 地址空間。*集區*是範圍內連續 IP 地址範圍 （或 CIDR 範圍） 的集合。集區可協助您根據您的路由和安全需求組織 IP 地址。此圖表顯示四個層級的集區：頂層集區、區域集區、業務單位集區和環境集區。

![\[網路帳戶中單一 AWS 區域中的私有範圍和四個層級的集區。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/780e344e-37f7-4b70-8d7c-94ec67a29305/images/1e23b2a7-a274-4a19-9097-61d8a31dfbf8.png)


此解決方案會建立清晰的 IP Address Manager 集區階層：

1. 最上層集區包含整個組織 IP 地址空間，例如 `10.176.0.0/12`。

1. 區域集區適用於區域特定的配置，例如 `10.176.0.0/15` `us-east-1`。

1. 業務單位集區是每個集區中的特定網域配置 AWS 區域。例如， `us-east-1`區域中的財務業務單位可能會有 `10.176.0.0/16`。

1. 環境集區是不同環境的特定用途配置。例如， `us-east-1`區域中的財務業務單位可能具有生產環境`10.176.0.0/18`的 。

此部署拓撲會在地理上分配 IP Address Manager 資源，同時維持集中式控制。以下是其功能：
+ IP Address Manager 部署在單一主要節點中 AWS 區域。
+ 其他區域會註冊為[操作區域](https://docs.aws.amazon.com/vpc/latest/ipam/mod-ipam-region.html)，其中 IP Address Manager 可以管理資源。
+ 每個操作區域都會從最上層集區接收專用地址集區。
+ 所有操作區域中的資源都會透過主要區域中的 IP Address Manager 集中管理。
+ 每個區域集區都有與其區域繫結的區域設定屬性，協助您正確配置資源。

*進階 CIDR 範圍驗證*

此解決方案旨在防止部署無效的組態。當您透過 Terraform 部署集區時，會在 Terraform 計劃階段驗證下列項目：
+ 驗證所有環境 CIDR 範圍都包含在其父業務單位 CIDR 範圍內
+ 確認所有業務單位 CIDR 範圍都包含在其父區域 CIDR 範圍內
+ 驗證所有區域 CIDR 範圍是否包含在最上層 CIDR 範圍內
+ 檢查相同階層層級內是否有重疊的 CIDR 範圍
+ 驗證環境與其個別業務單位的適當映射

*CIDR 範圍配置*

下圖顯示開發人員或管理員如何建立新的 VPCs 並從集區層級配置 IP 地址的範例。

![\[網路帳戶中單一 AWS 區域中的私有範圍和四個層級的集區。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/780e344e-37f7-4b70-8d7c-94ec67a29305/images/7c3de2e3-e71b-4fc0-abcd-7e88cfab5c87.png)


該圖顯示以下工作流程：

1. 透過 AWS 管理主控台、 或透過基礎設施即程式碼 (IaC) AWS CLI，開發人員或管理員會請求`AY3`環境集區中下一個可用的 CIDR 範圍。

1. IP Address Manager 會將該集區中的下一個可用 CIDR 範圍配置給 `AY3-4` VPC。無法再使用此 CIDR 範圍。

**自動化和擴展**

此解決方案專為可擴展性而設計，如下所示：
+ **區域擴展** – 透過使用其他區域集區項目擴展 Terraform 組態來新增區域。
+ **業務單位成長** – 透過將新業務單位新增至 BU 組態映射來支援新業務單位。
+ **環境彈性** – 根據組織需求設定不同的環境類型，例如開發或生產。
+ **多帳戶支援** – 透過 將集區分享到組織中的所有帳戶 AWS RAM。
+ **自動化 VPC 佈建** – 與 VPC 佈建工作流程整合，以自動化 CIDR 範圍配置。

階層結構也允許不同規模的委派和控制，如下所示：
+ 網路管理員可能會管理最上層和區域集區。
+ 業務單位 IT 團隊可能已委派控制各自的集區。
+ 應用程式團隊可能會使用其指定環境集區的 IP 地址。

**注意**  
您也可以將此解決方案與 [AWS Control Tower Account Factory for Terraform (AFT)](https://docs.aws.amazon.com/controltower/latest/userguide/aft-overview.html) 整合。如需詳細資訊，請參閱此模式[額外資訊](#multi-region-ipam-architecture-additional)區段中的*與 AFT 整合*。

## 工具
<a name="multi-region-ipam-architecture-tools"></a>

**AWS 服務**
+ [Amazon CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html) 可協助您 AWS 即時監控 AWS 資源的指標，以及您在 上執行的應用程式。
+ [AWS Command Line Interface (AWS CLI)](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) 是一種開放原始碼工具，可協助您 AWS 服務 透過命令列 shell 中的命令與 互動。
+ [AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html) 是一種帳戶管理服務，可協助您將多個 合併 AWS 帳戶 到您建立並集中管理的組織。
+ [AWS Resource Access Manager (AWS RAM)](https://docs.aws.amazon.com/ram/latest/userguide/what-is.html) 可協助您安全地跨 共用資源 AWS 帳戶 ，以減少營運開銷並提供可見性和可稽核性。
+ [Amazon Virtual Private Cloud (Amazon VPC)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html) 可協助您在已定義的虛擬網路中啟動 AWS 資源。此虛擬網路與您在自己的資料中心中操作的傳統網路相似，且具備使用 AWS可擴展基礎設施的優勢。[IP Address Manager](https://docs.aws.amazon.com/vpc/latest/ipam/what-it-is-ipam.html) 是 Amazon VPC 的一項功能。它可協助您規劃、追蹤和監控 AWS 工作負載的 IP 地址。

**其他工具**
+ [HashiCorp Terraform](https://www.terraform.io/docs) 是一種基礎設施即程式碼 (IaC) 工具，可協助您使用程式碼來佈建和管理雲端基礎設施和資源。

**程式碼儲存庫**

此模式的程式碼可在 GitHub 上儲存庫[的階層式 IPAM 實作範例 AWS](https://github.com/aws-samples/sample-amazon-vpc-ipam-terraform)** **中取得。儲存庫結構包括：
+ **根模組** – 部署協同運作和輸入變數。
+ **IPAM 模組** – 此模式中所述架構的核心實作。
+ **標籤模組** – 所有資源的標準化標記。

## 最佳實務
<a name="multi-region-ipam-architecture-best-practices"></a>

請考慮下列網路規劃的最佳實務：
+ **先規劃** – 在部署之前徹底規劃 IP 地址空間。如需詳細資訊，請參閱[規劃 IP 地址佈建](https://docs.aws.amazon.com/vpc/latest/ipam/planning-ipam.html)。
+ **避免重疊的 CIDR 範圍** – 確保每個層級的 CIDR 範圍不會重疊。
+ **預留緩衝空間** – 一律配置比立即所需更大的 CIDR 範圍，以適應成長。
+ **文件 IP 地址配置** – 維護 IP 地址配置策略的文件。

請考慮下列部署最佳實務：
+ **從非生產開始** – 首先在非生產環境中部署。
+ **使用 Terraform 狀態管理** – 實作遠端狀態儲存和鎖定。如需詳細資訊，請參閱 Terraform 文件中的[狀態儲存和鎖定](https://developer.hashicorp.com/terraform/language/state/backends)。
+ **實作版本控制** – 版本控制所有 Terraform 程式碼。
+ **實作 CI/CD 整合** – 使用持續整合和持續交付 (CI/CD) 管道進行可重複的部署。

請考慮下列操作最佳實務：
+ **啟用自動匯入** – 設定 IP Address Manager 集區以自動探索和匯入現有資源。依照[編輯 IPAM 集區](https://docs.aws.amazon.com/vpc/latest/ipam/mod-pool-ipam.html)中的指示開啟自動匯入。
+ **監控 IP 地址使用率** – 設定 IP 地址使用率閾值的警示。如需詳細資訊，請參閱[使用 Amazon CloudWatch 監控 IPAM](https://docs.aws.amazon.com/vpc/latest/ipam/cloudwatch-ipam.html)。
+ **定期稽核** – 定期稽核 IP 地址使用情況和合規性。如需詳細資訊，請參閱[追蹤 IPAM 中的 IP 地址用量](https://docs.aws.amazon.com/vpc/latest/ipam/tracking-ip-addresses-ipam.html)。
+ **清除未使用的配置** – 解除委任資源時釋出 IP 地址配置。如需詳細資訊，請參閱[從集區取消佈建 CIDRs](https://docs.aws.amazon.com/vpc/latest/ipam/depro-pool-cidr-ipam.html)。

請考慮下列安全最佳實務：
+ **實作最低權限** – 使用具有最低必要許可的 IAM 角色。如需詳細資訊，請參閱 [IAM 中的安全最佳實務](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)和 [IPAM 中的身分和存取管理](https://docs.aws.amazon.com/vpc/latest/ipam/iam-ipam.html)。
+ **使用服務控制政策** – 實作服務控制政策 SCPs)，以在組織中強制執行 IP Address Manager 用量。如需詳細資訊，請參閱[使用 SCPs 強制使用 IPAM 建立 VPC](https://docs.aws.amazon.com/vpc/latest/ipam/scp-ipam.html)。
+ **控制資源共用** – 仔細管理其中 IP Address Manager 資源共用的範圍 AWS RAM。如需詳細資訊，請參閱[使用 共用 IPAM 集區 AWS RAM](https://docs.aws.amazon.com/vpc/latest/ipam/share-pool-ipam.html)。
+ **強制標記** – 對與 IP Address Manager 相關的所有資源實作強制標記。如需詳細資訊，請參閱[其他資訊](#multi-region-ipam-architecture-additional)區段中的*標記策略*。

## 史詩
<a name="multi-region-ipam-architecture-epics"></a>

### 設定 IP Address Manager 的委派管理員帳戶
<a name="set-up-a-delegated-administrator-account-for-ip-address-manager"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 啟用 AWS Organizations 功能。 | 確定 AWS Organizations 已啟用所有功能。如需說明，請參閱 AWS Organizations 文件中的[為使用 的組織啟用所有功能 AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html)。 | AWS 管理員 | 
| 在 中啟用資源共用 AWS RAM。 | 使用 AWS CLI，輸入下列命令為您的組織啟用 AWS RAM 資源共用：<pre>aws ram enable-sharing-with-aws-organization</pre>如需詳細資訊，請參閱 AWS RAM 文件中的在 [中啟用資源共用 AWS Organizations](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-orgs)。 | AWS 管理員 | 
| 指定 IP Address Manager 的管理員。 | 從組織的管理帳戶中，使用 AWS CLI輸入下列命令，其中 `123456789012`是將管理 IP Address Manager 的帳戶 ID：<pre>aws ec2 enable-ipam-organization-admin-account \<br />    --delegated-admin-account-id 123456789012</pre>一般而言，網路或網路中樞帳戶會用作 IP Address Manager 的委派管理員。如需詳細資訊，請參閱 [IP Address Manager 文件中的將 IPAM 與 AWS Organization 中的帳戶整合](https://docs.aws.amazon.com/vpc/latest/ipam/enable-integ-ipam.html)。 | AWS 管理員 | 

### 部署基礎設施
<a name="deploy-the-infrastructure"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 定義網路架構。 | 定義並記錄您的網路架構，包括區域、業務單位和環境的 CIDR 範圍。如需詳細資訊，請參閱 [IP Address Manager 文件中的規劃 IP 地址佈建](https://docs.aws.amazon.com/vpc/latest/ipam/planning-ipam.html)。 | 網路工程師 | 
| 複製儲存庫。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/multi-region-ipam-architecture.html) | DevOps 工程師 | 
| 設定變數。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/multi-region-ipam-architecture.html) | Terraform 網路工程師 | 
| 部署 IP Address Manager 資源。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/multi-region-ipam-architecture.html) | Terraform | 
| 驗證部署。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/multi-region-ipam-architecture.html) | General AWS，網路工程師 | 

### 建立 VPCs並設定監控
<a name="create-vpcs-and-set-up-monitoring"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立 VPC。 | 請遵循 Amazon [VPC 文件中建立](https://docs.aws.amazon.com/vpc/latest/userguide/create-vpc.html) VPC 中的步驟。當您達到為 VPC 選擇 CIDR 範圍的步驟時，請從您的區域、業務單位和環境集區配置下一個可用的範圍。 | 一般 AWS、網路管理員、網路工程師 | 
| 驗證 CIDR 範圍配置。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/multi-region-ipam-architecture.html) | 一般 AWS、網路管理員、網路工程師 | 
| 監控 IP Address Manager。 | 設定與 IP Address Manager 資源配置相關的監控和警示。如需詳細資訊和指示，請參閱 [IP Address Manager 文件中的使用 Amazon CloudWatch 監控 IPAM](https://docs.aws.amazon.com/vpc/latest/ipam/cloudwatch-ipam.html) 和[依資源監控 CIDR 用量](https://docs.aws.amazon.com/vpc/latest/ipam/monitor-cidr-compliance-ipam.html)。 | 一般 AWS | 
| 強制使用 IP Address Manager。 | 在 中建立服務控制政策 (SCP) AWS Organizations ，要求組織中的成員在建立 VPC 時使用 IP Address Manager。如需說明，請參閱 [IP Address Manager 文件中的強制使用 IPAM 搭配 SCPs 建立 VPC](https://docs.aws.amazon.com/vpc/latest/ipam/scp-ipam.html)。 | General AWS、AWS 管理員 | 

## 疑難排解
<a name="multi-region-ipam-architecture-troubleshooting"></a>


| 問題 | 解決方案 | 
| --- | --- | 
| 找不到 IP Address Manager 資源時 Terraform 失敗 | 請確定 IP Address Manager 管理員帳戶已正確委派，且您的 AWS 提供者已向該帳戶進行身分驗證。 | 
| CIDR 範圍配置失敗 | 檢查請求的 CIDR 範圍是否在 IP Address Manager 集區的可用範圍內，且未與現有的配置重疊。 | 
| AWS RAM 共用問題 | 確認您的 AWS Organization 已啟用資源共用。確認 AWS RAM 共享中使用了正確的主體，即組織 Amazon Resource Name (ARN)。 | 
| 集區階層驗證錯誤 | 請確定子集區 CIDR 範圍已正確包含在其父集區 CIDR 範圍內，且不會與同級集區重疊。 | 
| 超過 IP Address Manager 配額限制 | 請求提高 IP Address Manager 集區的配額。如需詳細資訊，請參閱「Service Quotas 使用者指南」**中的[請求提高配額](https://docs.aws.amazon.com/servicequotas/latest/userguide/request-quota-increase.html)。 | 

## 相關資源
<a name="multi-region-ipam-architecture-resources"></a>

**AWS 服務 文件**
+ [Amazon VPC IP Address Manager 文件](https://docs.aws.amazon.com/vpc/latest/ipam/what-it-is-ipam.html)
+ [AWS Resource Access Manager 文件](https://docs.aws.amazon.com/ram/latest/userguide/what-is.html)
+ [AWS Organizations 文件](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html)

**AWS 部落格文章**
+ [使用 Amazon VPCs IP Address Manager 管理跨 VPC 和區域的 IP 集區](https://aws.amazon.com/blogs/networking-and-content-delivery/managing-ip-pools-across-vpcs-and-regions-using-amazon-vpc-ip-address-manager/)
+ [使用 Amazon VPC IP Address Manager 進行大規模的網路地址管理和稽核](https://aws.amazon.com/blogs/aws/network-address-management-and-auditing-at-scale-with-amazon-vpc-ip-address-manager/)

**影片和教學課程**
+ [AWS re：Invent 2022：Amazon VPC 設計和 IPAM (NET310) 的最佳實務](https://www.youtube.com/watch?v=XrEHsy_8RYs)
+ [AWS re：Invent 2022：進階 VPC 設計和新功能 (NET401)](https://www.youtube.com/watch?v=tbXTVpwx87o)

## 其他資訊
<a name="multi-region-ipam-architecture-additional"></a>

**與 AFT 整合**

您可以將此解決方案與 AWS Control Tower Account Factory for Terraform (AFT) 整合，以確保新佈建的帳戶自動接收適當的網路組態。透過在網路中樞帳戶中部署此 IPAM 解決方案，透過 AFT 建立的新帳戶可以在建立 VPCs 時參考共用 IP Address Manager 集區。

下列程式碼範例示範使用 AWS Systems Manager 參數存放區在帳戶自訂中的 AFT 整合：

```
# Get the IP Address Manager pool ID from Parameter Store
data "aws_ssm_parameter" "dev_ipam_pool_id" {
  name = "/org/network/ipam/finance/dev/pool-id"
}

# Create a VPC using the IP Address Manager pool
resource "aws_vpc" "this" {
  ipv4_ipam_pool_id   = data.aws_ssm_parameter.dev_ipam_pool_id.value
  ipv4_netmask_length = 24
  
  tags = {
    Name = "aft-account-vpc"
  }
}
```

**標記策略**

解決方案實作全方位的標記策略，以促進資源管理。下列程式碼範例示範如何使用：

```
# Example tag configuration
module "tags" {
  source = "./modules/tags"
  
  # Required tags
  product_name  = "enterprise-network"
  feature_name  = "ipam"
  org_id        = "finance"
  business_unit = "network-operations"
  owner         = "network-team"
  environment   = "prod"
  repo          = "https://github.com/myorg/ipam-terraform"
  branch        = "main"
  cost_center   = "123456"
  dr_tier       = "tier1"
  
  # Optional tags
  optional_tags = {
    "project"    = "network-modernization"
    "stack_role" = "infrastructure"
  }
}
```

這些標籤會自動套用至所有 IP Address Manager 資源。這有助於一致的控管、成本分配和資源管理。

# 自訂 的 Amazon CloudWatch 提醒 AWS Network Firewall
<a name="customize-amazon-cloudwatch-alerts-for-aws-network-firewall"></a>

*Jason Owens，Amazon Web Services*

## 總結
<a name="customize-amazon-cloudwatch-alerts-for-aws-network-firewall-summary"></a>

模式可協助您自訂由 產生的 Amazon CloudWatch 警示 AWS Network Firewall。您可以使用預先定義的規則，或建立自訂規則來判斷提醒的訊息、中繼資料和嚴重性。然後，您可以對這些提醒採取行動，或自動回應其他 Amazon 服務，例如 Amazon EventBridge。

在此模式中，您會產生 Suricata 相容防火牆規則。[Suricata](https://suricata.io/) 是一種開放原始碼威脅偵測引擎。您首先建立簡單的規則，然後測試它們以確認產生並記錄 CloudWatch 提醒。成功測試規則後，您可以修改規則以定義自訂訊息、中繼資料和嚴重性，然後再次測試以確認更新。

## 先決條件和限制
<a name="customize-amazon-cloudwatch-alerts-for-aws-network-firewall-prereqs"></a>

**先決條件**
+ 作用中 AWS 帳戶。
+ AWS Command Line Interface (AWS CLI) 在 Linux、macOS 或 Windows 工作站上安裝和設定。如需詳細資訊，請參閱[安裝或更新最新版本的 AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)。
+ AWS Network Firewall 已安裝並設定為使用 CloudWatch Logs。如需詳細資訊，請參閱[從 記錄網路流量 AWS Network Firewall](https://docs.aws.amazon.com/network-firewall/latest/developerguide/firewall-logging.html)。
+ 受 Network Firewall 保護之虛擬私有雲端 (VPC) 私有子網路中的 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體。

**產品版本**
+ 對於 第 1 版 AWS CLI，請使用 1.18.180 或更新版本。對於 第 2 版 AWS CLI，請使用 2.1.2 或更新版本。
+ 來自 Suricata 5.0.2 版的 classification.config 檔案。如需此組態檔案的副本，請參閱[其他資訊](#customize-amazon-cloudwatch-alerts-for-aws-network-firewall-additional)一節。

## Architecture
<a name="customize-amazon-cloudwatch-alerts-for-aws-network-firewall-architecture"></a>

![\[EC2 執行個體請求會在 Network Firewall 中產生警示，將警示轉送至 CloudWatch\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/da6087a9-e942-4cfe-85e3-3b08de6f3ba5/images/778d85cd-bc87-4ed0-a161-d35eb5daa694.png)


架構圖顯示下列工作流程：

1. 私有子網路中的 Amazon EC2 執行個體會使用 [curl](https://curl.se/) 或 [Wget](https://www.gnu.org/software/wget/) 提出請求。

1. Network Firewall 會處理流量並產生提醒。

1. Network Firewall 會將記錄的警示傳送至 CloudWatch Logs。

## 工具
<a name="customize-amazon-cloudwatch-alerts-for-aws-network-firewall-tools"></a>

**AWS 服務**
+ [Amazon CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html) 可協助您 AWS 即時監控 AWS 資源的指標，以及您在 上執行的應用程式。
+ [Amazon CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html) 可協助您集中所有系統、應用程式的日誌， AWS 服務 以便您可以監控日誌並將其安全地存檔。
+ [AWS Command Line Interface (AWS CLI)](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) 是一種開放原始碼工具，可協助您 AWS 服務 透過命令列 shell 中的命令與 互動。
+ [AWS Network Firewall](https://docs.aws.amazon.com/network-firewall/latest/developerguide/what-is-aws-network-firewall.html) 是 AWS 雲端中的虛擬私有雲端 (VPC) 的有狀態、受管網路防火牆以及入侵偵測和預防服務。 

**其他工具**
+ [curl](https://curl.se/) 是開放原始碼命令列工具和程式庫。
+ [GNU Wget](https://www.gnu.org/software/wget/) 是免費命令列工具。

## 史詩
<a name="customize-amazon-cloudwatch-alerts-for-aws-network-firewall-epics"></a>

### 建立防火牆規則和規則群組
<a name="create-the-firewall-rules-and-rule-group"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立規則。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/customize-amazon-cloudwatch-alerts-for-aws-network-firewall.html) | AWS 系統管理員、網路管理員 | 
| 建立規則群組。 | 在 中 AWS CLI，輸入下列命令。這會建立規則群組。<pre>❯ aws network-firewall create-rule-group \<br />        --rule-group-name custom --type STATEFUL \<br />        --capacity 10 --rules file://custom.rules \<br />        --tags Key=environment,Value=development</pre>以下為範例輸出。請記下`RuleGroupArn`您在後續步驟中需要的 。<pre>{<br />    "UpdateToken": "4f998d72-973c-490a-bed2-fc3460547e23",<br />    "RuleGroupResponse": {<br />        "RuleGroupArn": "arn:aws:network-firewall:us-east-2:1234567890:stateful-rulegroup/custom",<br />        "RuleGroupName": "custom",<br />        "RuleGroupId": "238a8259-9eaf-48bb-90af-5e690cf8c48b",<br />        "Type": "STATEFUL",<br />        "Capacity": 10,<br />        "RuleGroupStatus": "ACTIVE",<br />        "Tags": [<br />            {<br />                "Key": "environment",<br />                "Value": "development"<br />            }<br />        ]<br />    }</pre> | AWS 系統管理員 | 

### 更新防火牆政策
<a name="update-the-firewall-policy"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 取得防火牆政策的 ARN。 | 在 中 AWS CLI，輸入下列命令。這會傳回防火牆政策的 Amazon Resource Name (ARN)。記錄 ARN 以供稍後在此模式中使用。<pre>❯ aws network-firewall describe-firewall \<br />    --firewall-name aws-network-firewall-anfw \<br />    --query 'Firewall.FirewallPolicyArn'</pre>以下是此命令傳回的範例 ARN。<pre>"arn:aws:network-firewall:us-east-2:1234567890:firewall-policy/firewall-policy-anfw"</pre> | AWS 系統管理員 | 
| 更新防火牆政策。 | 在文字編輯器中，複製貼上下列程式碼。`<RuleGroupArn>` 將 取代為您在上一個 epic 中記錄的值。儲存檔案為 `firewall-policy-anfw.json`。<pre>{<br />    "StatelessDefaultActions": [<br />        "aws:forward_to_sfe"<br />    ],<br />    "StatelessFragmentDefaultActions": [<br />        "aws:forward_to_sfe"<br />    ],<br />    "StatefulRuleGroupReferences": [<br />        {<br />            "ResourceArn": "<RuleGroupArn>"<br />        }<br />    ]<br />}</pre>在 中輸入下列命令 AWS CLI。此命令需要[更新字符](https://docs.aws.amazon.com/cli/latest/reference/network-firewall/update-firewall-policy.html)才能新增新規則。字符用於確認自您上次擷取以來，政策尚未變更。<pre>UPDATETOKEN=(`aws network-firewall describe-firewall-policy \<br />              --firewall-policy-name firewall-policy-anfw \<br />              --output text --query UpdateToken`)<br /> <br /> aws network-firewall update-firewall-policy \<br /> --update-token $UPDATETOKEN \<br /> --firewall-policy-name firewall-policy-anfw \<br /> --firewall-policy file://firewall-policy-anfw.json</pre> | AWS 系統管理員 | 
| 確認政策更新。 | （選用） 如果您想要確認已新增規則並檢視政策格式，請在 中輸入下列命令 AWS CLI。<pre>❯ aws network-firewall describe-firewall-policy \<br />  --firewall-policy-name firewall-policy-anfw \<br />  --query FirewallPolicy</pre>以下為範例輸出。<pre>{<br />    "StatelessDefaultActions": [<br />        "aws:forward_to_sfe"<br />    ],<br />    "StatelessFragmentDefaultActions": [<br />        "aws:forward_to_sfe"<br />    ],<br />    "StatefulRuleGroupReferences": [<br />        {<br />            "ResourceArn": "arn:aws:network-firewall:us-east-2:1234567890:stateful-rulegroup/custom"<br />        }<br />    ]<br />}</pre> | AWS 系統管理員 | 

### 測試提醒功能
<a name="test-alert-functionality"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 產生測試提醒。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/customize-amazon-cloudwatch-alerts-for-aws-network-firewall.html) | AWS 系統管理員 | 
| 驗證是否已記錄提醒。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/customize-amazon-cloudwatch-alerts-for-aws-network-firewall.html) | AWS 系統管理員 | 

### 更新防火牆規則和規則群組
<a name="update-the-firewall-rules-and-rule-group"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 更新防火牆規則。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/customize-amazon-cloudwatch-alerts-for-aws-network-firewall.html) | AWS 系統管理員 | 
| 更新規則群組。 | 在 中 AWS CLI，執行下列命令。使用防火牆政策的 ARN。這些命令會取得更新字符，並使用規則變更來更新規則群組。<pre>❯ UPDATETOKEN=(`aws network-firewall \<br />                describe-rule-group \<br />--rule-group-arn arn:aws:network-firewall:us-east-2:123457890:stateful-rulegroup/custom \<br />--output text --query UpdateToken`)</pre><pre> ❯ aws network-firewall update-rule-group \<br />  --rule-group-arn arn:aws:network-firewall:us-east-2:1234567890:stateful-rulegroup/custom \<br />--rules file://custom.rules \<br />--update-token $UPDATETOKEN</pre>以下為範例輸出。<pre>{<br />    "UpdateToken": "7536939f-6a1d-414c-96d1-bb28110996ed",<br />    "RuleGroupResponse": {<br />        "RuleGroupArn": "arn:aws:network-firewall:us-east-2:1234567890:stateful-rulegroup/custom",<br />        "RuleGroupName": "custom",<br />        "RuleGroupId": "238a8259-9eaf-48bb-90af-5e690cf8c48b",<br />        "Type": "STATEFUL",<br />        "Capacity": 10,<br />        "RuleGroupStatus": "ACTIVE",<br />        "Tags": [<br />            {<br />                "Key": "environment",<br />                "Value": "development"<br />            }<br />        ]<br />    }<br />}</pre> | AWS 系統管理員 | 

### 測試更新的提醒功能
<a name="test-the-updated-alert-functionality"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 產生測試提醒。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/customize-amazon-cloudwatch-alerts-for-aws-network-firewall.html) | AWS 系統管理員 | 
| 驗證已變更的提醒。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/customize-amazon-cloudwatch-alerts-for-aws-network-firewall.html) | AWS 系統管理員 | 

## 相關資源
<a name="customize-amazon-cloudwatch-alerts-for-aws-network-firewall-resources"></a>

**參考**
+ [從 傳送提醒 AWS Network Firewall 到 Slack 頻道](https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/send-alerts-from-aws-network-firewall-to-a-slack-channel.html) (AWS 方案指引）
+ [AWS 使用 Suricata 在 上擴展威脅預防 ](https://aws.amazon.com/blogs/opensource/scaling-threat-prevention-on-aws-with-suricata/)(AWS 部落格文章）
+ [的部署模型 AWS Network Firewall](https://aws.amazon.com/blogs/networking-and-content-delivery/deployment-models-for-aws-network-firewall/) (AWS 部落格文章）
+ [Suricata 中繼金鑰 ](https://suricata.readthedocs.io/en/suricata-6.0.1/rules/meta.html)(Suricata 文件）

**教學課程和影片**
+ [AWS Network Firewall 研討會](https://networkfirewall.workshop.aws/)

## 其他資訊
<a name="customize-amazon-cloudwatch-alerts-for-aws-network-firewall-additional"></a>

以下是來自 Suricata 5.0.2 的分類組態檔案。建立防火牆規則時會使用這些分類。

```
# config classification:shortname,short description,priority
 
config classification: not-suspicious,Not Suspicious Traffic,3
config classification: unknown,Unknown Traffic,3
config classification: bad-unknown,Potentially Bad Traffic, 2
config classification: attempted-recon,Attempted Information Leak,2
config classification: successful-recon-limited,Information Leak,2
config classification: successful-recon-largescale,Large Scale Information Leak,2
config classification: attempted-dos,Attempted Denial of Service,2
config classification: successful-dos,Denial of Service,2
config classification: attempted-user,Attempted User Privilege Gain,1
config classification: unsuccessful-user,Unsuccessful User Privilege Gain,1
config classification: successful-user,Successful User Privilege Gain,1
config classification: attempted-admin,Attempted Administrator Privilege Gain,1
config classification: successful-admin,Successful Administrator Privilege Gain,1
 
# NEW CLASSIFICATIONS
config classification: rpc-portmap-decode,Decode of an RPC Query,2
config classification: shellcode-detect,Executable code was detected,1
config classification: string-detect,A suspicious string was detected,3
config classification: suspicious-filename-detect,A suspicious filename was detected,2
config classification: suspicious-login,An attempted login using a suspicious username was detected,2
config classification: system-call-detect,A system call was detected,2
config classification: tcp-connection,A TCP connection was detected,4
config classification: trojan-activity,A Network Trojan was detected, 1
config classification: unusual-client-port-connection,A client was using an unusual port,2
config classification: network-scan,Detection of a Network Scan,3
config classification: denial-of-service,Detection of a Denial of Service Attack,2
config classification: non-standard-protocol,Detection of a non-standard protocol or event,2
config classification: protocol-command-decode,Generic Protocol Command Decode,3
config classification: web-application-activity,access to a potentially vulnerable web application,2
config classification: web-application-attack,Web Application Attack,1
config classification: misc-activity,Misc activity,3
config classification: misc-attack,Misc Attack,2
config classification: icmp-event,Generic ICMP event,3
config classification: inappropriate-content,Inappropriate Content was Detected,1
config classification: policy-violation,Potential Corporate Privacy Violation,1
config classification: default-login-attempt,Attempt to login by a default username and password,2
 
# Update
config classification: targeted-activity,Targeted Malicious Activity was Detected,1
config classification: exploit-kit,Exploit Kit Activity Detected,1
config classification: external-ip-check,Device Retrieving External IP Address Detected,2
config classification: domain-c2,Domain Observed Used for C2 Detected,1
config classification: pup-activity,Possibly Unwanted Program Detected,2
config classification: credential-theft,Successful Credential Theft Detected,1
config classification: social-engineering,Possible Social Engineering Attempted,2
config classification: coin-mining,Crypto Currency Mining Activity Detected,2
config classification: command-and-control,Malware Command and Control Activity Detected,1
```

# 使用 Terraform 在 AWS Wavelength 區域中部署資源
<a name="deploy-resources-wavelength-zone-using-terraform"></a>

*Zahoor Chaudhrey 和 Luca Iannario，Amazon Web Services*

## 總結
<a name="deploy-resources-wavelength-zone-using-terraform-summary"></a>

[AWS Wavelength](https://docs.aws.amazon.com/wavelength/latest/developerguide/what-is-wavelength.html) 可協助您建置針對多存取邊緣運算 (MEC) 應用程式最佳化的基礎設施。*Wavelength 區域*是 AWS 基礎設施部署，可將 AWS 運算和儲存服務嵌入通訊服務供應商 (CSP) 5G 網路。來自 5G 裝置的應用程式流量會到達在 Wavelength 區域中執行的應用程式伺服器，而不會離開電信網路。以下內容有助於透過 Wavelength 進行網路連線：
+ **虛擬私有雲端 (VPCs)** – 中的 VPCs AWS 帳戶 可以延伸到多個可用區域，包括 Wavelength 區域。Amazon Elastic Compute Cloud (Amazon EC2) 執行個體和相關服務會顯示為區域 VPC 的一部分。VPCs是在 [Amazon Virtual Private Cloud (Amazon VPC)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html) 中建立和管理。
+ **電信業者閘道** – 電信業者閘道可透過 CSP 的網路，從 Wavelength 區域中的子網路連線至 CSP 網路、網際網路或 AWS 區域 。電信業者閘道有兩個用途。它允許來自特定位置 CSP 網路的傳入流量，並允許傳出流量到電信網路和網際網路。

此模式及其相關聯的 Terraform 程式碼可協助您在 Wavelength 區域中啟動資源，例如 Amazon EC2 執行個體、Amazon Elastic Block Store (Amazon EBS) 磁碟區、VPCs、子網路和電信業者閘道。

## 先決條件和限制
<a name="deploy-resources-wavelength-zone-using-terraform-prereqs"></a>

**先決條件**
+ 作用中 AWS 帳戶
+ 整合式開發環境 (IDE)
+ [選擇加入](https://docs.aws.amazon.com/wavelength/latest/developerguide/get-started-wavelength.html#enable-zone-group)目標 Wavelength 區域
+ AWS Command Line Interface (AWS CLI)，[已安裝](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)並[設定](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)
+ Terraform 1.8.4 版或更新版本，[已安裝](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) (Terraform 文件）
+ Terraform AWS Provider 5.32.1 版或更新版本，[已設定](https://hashicorp.github.io/terraform-provider-aws/) (Terraform 文件）
+ Git，[已安裝](https://github.com/git-guides/install-git) (GitHub)
+ 建立 Amazon VPC、Wavelength 和 Amazon EC2 資源[的許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html) 

**限制**

並非所有 都 AWS 區域 支援 Wavelength 區域。如需詳細資訊，請參閱 [Wavelength 文件中的可用 Wavelength 區域](https://docs.aws.amazon.com/wavelength/latest/developerguide/available-wavelength-zones.html)。

## Architecture
<a name="deploy-resources-wavelength-zone-using-terraform-architecture"></a>

下圖顯示如何在 Wavelength 區域中建立子網路 AWS 和資源。在 Wavelength 區域中包含子網路的 VPCs 可以連接到電信業者閘道。電信業者閘道可讓您連線至下列資源：
+ 電信業者網路上的 4G/LTE 和 5G 裝置。
+ 已修正特定 Wavelength Zone 合作夥伴的無線存取。如需詳細資訊，請參閱[多重存取 AWS Wavelength](https://docs.aws.amazon.com/wavelength/latest/developerguide/multi-access.html)。
+ 將流量傳出至公有網際網路資源。

![\[電信業者閘道會將 Wavelength 區域中的 AWS 資源連線至 CSP 網路。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/8c507de1-208c-4563-bb58-52388ab2fa6d/images/a4cc0699-0cbc-4f15-ab14-3ae569ced7f4.png)


## 工具
<a name="deploy-resources-wavelength-zone-using-terraform-tools"></a>

**AWS 服務**
+ [Amazon Virtual Private Cloud (Amazon VPC)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html) 可協助您在已定義的虛擬網路中啟動 AWS 資源。此虛擬網路與您在自己的資料中心中操作的傳統網路相似，且具備使用 AWS可擴展基礎設施的優勢。
+ [AWS Wavelength](https://docs.aws.amazon.com/wavelength/latest/developerguide/what-is-wavelength.html) 將 AWS 雲端 基礎設施擴展到電信供應商的 5G 網路。這可協助您建置應用程式，為行動裝置和最終使用者提供極低延遲。

**其他工具**
+ [Terraform](https://www.terraform.io/) 是 HashiCorp 的基礎設施即程式碼 (IaC) 工具，可協助您建立和管理雲端和內部部署資源。

**程式碼儲存庫**

此模式的程式碼可在 GitHub [使用 Terraform 建立 AWS Wavelength 基礎設施](https://github.com/aws-samples/terraform-wavelength-infrastructure)儲存庫中取得。Terraform 程式碼會部署下列基礎設施和資源：
+ VPC
+ Wavelength 區域
+ Wavelength 區域中的 pubic 子網路
+ Wavelength 區域中的電信業者閘道
+ Wavelength 區域中的 Amazon EC2 執行個體

## 最佳實務
<a name="deploy-resources-wavelength-zone-using-terraform-best-practices"></a>
+ 部署之前，請確認您使用的是最新版本的 Terraform 和 AWS CLI。
+ 使用持續整合和持續交付 (CI/CD) 管道來部署 IaC。如需詳細資訊，請參閱 AWS 部落格上 [AWS CI/CD 管道中管理 Terraform 狀態檔案的最佳實務](https://aws.amazon.com/blogs/devops/best-practices-for-managing-terraform-state-files-in-aws-ci-cd-pipeline/)。

## 史詩
<a name="deploy-resources-wavelength-zone-using-terraform-epics"></a>

### 佈建 基礎設施
<a name="provision-the-infrastructure"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 複製儲存庫。 | 輸入下列命令，將[使用 Terraform 儲存庫建立 AWS Wavelength 基礎設施](https://github.com/aws-samples/terraform-wavelength-infrastructure)複製到您的環境。`git clone git@github.com:aws-samples/terraform-wavelength-infrastructure.git` | DevOps 工程師 | 
| 更新變數。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/deploy-resources-wavelength-zone-using-terraform.html) | DevOps 工程師，Terraform | 
| 初始化組態。 | 輸入下列命令來初始化工作目錄。<pre>terraform init</pre> | DevOps 工程師，Terraform | 
| 預覽 Terraform 計劃。 | 輸入下列命令，將目標狀態與您 AWS 環境的目前狀態進行比較。此命令會產生將設定的資源預覽。<pre>terraform plan</pre> | DevOps 工程師，Terraform | 
| 驗證和部署。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/deploy-resources-wavelength-zone-using-terraform.html) | DevOps 工程師，Terraform | 

### 驗證和清除
<a name="validate-and-clean-up"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 驗證基礎設施部署。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/deploy-resources-wavelength-zone-using-terraform.html) | AWS DevOps，DevOps 工程師 | 
| （選用） 清除基礎設施。 | 如果您需要刪除 Terraform 佈建的所有資源，請執行下列動作：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/deploy-resources-wavelength-zone-using-terraform.html) | DevOps 工程師，Terraform | 

## 疑難排解
<a name="deploy-resources-wavelength-zone-using-terraform-troubleshooting"></a>


| 問題 | 解決方案 | 
| --- | --- | 
| 連線至 中的 Amazon EC2 執行個體 AWS 區域。 | 請參閱[連線 Linux 執行個體的故障診斷](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html)或[連線 Windows 執行個體的故障診斷](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/troubleshooting-windows-instances.html)。 | 
| 連線至 Wavelength 區域中的 Amazon EC2 執行個體。 | 請參閱[疑難排解在 Wavelength 區域中啟動之 EC2 執行個體的 SSH 或 RDP 連線](https://repost.aws/knowledge-center/ec2-wavelength-zone-connection-errors)。 | 
| Wavelength 區域中的容量。 | 請參閱 [Wavelength 區域的配額和考量](https://docs.aws.amazon.com/wavelength/latest/developerguide/wavelength-quotas.html)。 | 
| 從電信業者網路到 的行動或電信業者連線 AWS 區域。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/deploy-resources-wavelength-zone-using-terraform.html) | 

## 相關資源
<a name="deploy-resources-wavelength-zone-using-terraform-resources"></a>
+ [什麼是 AWS Wavelength？](https://docs.aws.amazon.com/wavelength/latest/developerguide/what-is-wavelength.html)
+ [AWS Wavelength 運作方式](https://docs.aws.amazon.com/wavelength/latest/developerguide/how-wavelengths-work.html)
+ [中的彈性 AWS Wavelength](https://docs.aws.amazon.com/wavelength/latest/developerguide/disaster-recovery-resiliency.html)

# 將大量 DNS 記錄遷移至 Amazon Route 53 私有託管區域
<a name="migrate-dns-records-in-bulk-to-an-amazon-route-53-private-hosted-zone"></a>

*Ram Kandaswamy，Amazon Web Services*

## 總結
<a name="migrate-dns-records-in-bulk-to-an-amazon-route-53-private-hosted-zone-summary"></a>

網路工程師和雲端管理員需要有效率且簡單的方法，將網域名稱系統 (DNS) 記錄新增至 Amazon Route 53 中的私有託管區域。使用手動方法將項目從 Microsoft Excel 工作表複製到 Route 53 主控台中的適當位置很繁瑣且容易出錯。此模式描述自動化方法，可減少新增多個記錄所需的時間和精力。它也為多個託管區域建立提供一組可重複的步驟。

此模式使用 Amazon Simple Storage Service (Amazon S3) 來存放記錄。為了有效率地使用資料，模式使用 JSON 格式，因為它簡單且能夠支援 Python 字典 (`dict` 資料類型）。

**注意**  
如果您可以從系統產生區域檔案，請考慮改用 [Route 53 匯入功能](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-creating-import.html)。

## 先決條件和限制
<a name="migrate-dns-records-in-bulk-to-an-amazon-route-53-private-hosted-zone-prereqs"></a>

**先決條件**
+ 包含私有託管區域記錄的 Excel 工作表
+ 熟悉不同類型的 DNS 記錄，例如 A 記錄、Name Authority Pointer (NAPTR) 記錄和 SRV 記錄 （請參閱[支援的 DNS 記錄類型](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/ResourceRecordTypes.html))
+ 熟悉 Python 語言及其程式庫

**限制**
+ 模式不會為所有使用案例案例提供廣泛的涵蓋範圍。例如，[Change\$1resource\$1record\$1sets](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/route53.html#Route53.Client.change_resource_record_sets) 呼叫不會使用 API 的所有可用屬性。
+ 在 Excel 工作表中，假設每一列中的值是唯一的。每個完整網域名稱 (FQDN) 的多個值預期會出現在相同的資料列中。如果不正確，您應該修改此模式中提供的程式碼，以執行必要的串連。
+ 模式使用適用於 Python 的 AWS 開發套件 (Boto3) 直接呼叫 Route 53 服務。您可以增強程式碼以使用 `create_stack`和 `update_stack`命令的 AWS CloudFormation 包裝函式，並使用 JSON 值填入範本資源。

## Architecture
<a name="migrate-dns-records-in-bulk-to-an-amazon-route-53-private-hosted-zone-architecture"></a>

**技術堆疊**
+ 用於路由流量的 Route 53 私有託管區域
+ 用於儲存輸出 JSON 檔案的 Amazon S3 

![\[將大量 DNS 記錄遷移至 Route 53 私有託管區域的工作流程。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/a81c29ea-f0c5-4d4a-ba87-93111a0f1ee9/images/2ada844b-4147-4f9f-8883-d22605aa42d8.png)


工作流程包含這些步驟，如上圖所示，並在 *Epics* 章節中討論：

1. 將具有記錄集資訊的 Excel 工作表上傳至 S3 儲存貯體。

1. 建立並執行 Python 指令碼，將 Excel 資料轉換為 JSON 格式。

1. 從 S3 儲存貯體讀取記錄並清除資料。

1. 在私有託管區域中建立記錄集。

## 工具
<a name="migrate-dns-records-in-bulk-to-an-amazon-route-53-private-hosted-zone-tools"></a>
+ [Route 53](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html) –Amazon Route 53 是高度可用且可擴展的 DNS Web 服務，可處理網域註冊、DNS 路由和運作狀態檢查。
+ [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) – Amazon Simple Storage Service (Amazon S3) 是一種物件儲存服務。您可以使用 Amazon S3 隨時從 Web 任何地方存放和擷取任意資料量。

## 史詩
<a name="migrate-dns-records-in-bulk-to-an-amazon-route-53-private-hosted-zone-epics"></a>

### 準備資料以進行自動化
<a name="prepare-data-for-automation"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 為您的記錄建立 Excel 檔案。 | 使用您從目前系統匯出的記錄來建立 Excel 工作表，其中包含記錄的必要資料欄，例如完整網域名稱 (FQDN)、記錄類型、存留時間 (TTL) 和值。對於 NAPTR 和 SRV 記錄，值是多個屬性的組合，因此請使用 Excel 的 `concat`方法來合併這些屬性。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/migrate-dns-records-in-bulk-to-an-amazon-route-53-private-hosted-zone.html) | 資料工程師、Excel 技能 | 
| 驗證工作環境。 | 在您的 IDE 中，建立 Python 檔案，將 Excel 輸入工作表轉換為 JSON 格式。（您也可以使用 Amazon SageMaker 筆記本來使用 Python 程式碼，而不是 IDE。)確認您使用的 Python 版本是 3.7 版或更新版本。<pre> python3 --version</pre>安裝 **pandas** 套件。<pre> pip3 install pandas --user</pre> | 一般 AWS | 
| 將 Excel 工作表資料轉換為 JSON。 | 建立 Python 檔案，其中包含要從 Excel 轉換為 JSON 的下列程式碼。<pre>import pandas as pd<br />data=pd.read_excel('./Book1.xls')<br />data.to_json(path_or_buf='my.json',orient='records')</pre>其中 `Book1`是 Excel 工作表的名稱，而 `my.json`是輸出 JSON 檔案的名稱。 | 資料工程師、Python 技能 | 
| 將 JSON 檔案上傳至 S3 儲存貯體。 | 上傳 `my.json` 至 S3 儲存貯體。如需詳細資訊，請參閱 Amazon S3 文件中的[建立儲存貯](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)體。 | 應用程式開發人員 | 
| FqdnName | RecordType | Value | TTL | 
| something.example.org | A | 1.1.1.1 | 900 | 

### 插入記錄
<a name="insert-records"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立私有託管區域。 | 使用 [create\$1hosted\$1zone](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/route53.html#Route53.Client.create_hosted_zone) API 和下列 Python 範例程式碼來建立私有託管區域。將參數 `hostedZoneName`、 `vpcRegion`和 取代`vpcId`為您自己的值。<pre>import boto3<br />import random<br />hostedZoneName ="xxx"<br />vpcRegion = "us-east-1"<br />vpcId="vpc-xxxx"<br />route53_client = boto3.client('route53')<br />response = route53_client.create_hosted_zone(<br />        Name= hostedZoneName,<br />        VPC={<br />            'VPCRegion: vpcRegion,<br />            'VPCId': vpcId<br />        },<br />        CallerReference=str(random.random()*100000),<br />        HostedZoneConfig={<br />            'Comment': "private hosted zone created by automation",<br />            'PrivateZone': True<br />        }<br />    )<br /> print(response)</pre>您也可以使用基礎設施即程式碼 (IaC) 工具，例如 AWS CloudFormation，將這些步驟取代為使用適當資源和屬性建立堆疊的範本。 | 雲端架構師、網路管理員、Python 技能 | 
| 從 Amazon S3 擷取做為字典的詳細資訊。 | 使用下列程式碼從 S3 儲存貯體讀取，並以 Python 字典的形式取得 JSON 值。 <pre>fileobj = s3_client.get_object(<br />        Bucket=bucket_name,<br />        Key='my.json'<br />        )<br />    filedata = fileobj['Body'].read()<br />    contents = filedata.decode('utf-8')<br />    json_content=json.loads(contents)<br />    print(json_content)</pre>其中 `json_content`包含 Python 字典。 | 應用程式開發人員、Python 技能 | 
| 清除空格和 Unicode 字元的資料值。 | 為了確保資料正確性的安全措施，請使用下列程式碼對 中的值執行條紋操作`json_content`。此程式碼會移除每個字串前面和結尾的空格字元。它也會使用 `replace`方法來移除硬 （不中斷） 空格 (`\xa0`字元）。<pre>for item in json_content:<br />    fqn_name = unicodedata.normalize("NFKD",item["FqdnName"].replace("u'", "'").replace('\xa0', '').strip())<br />    rec_type = item["RecordType"].replace('\xa0', '').strip()<br />    res_rec = {<br />                 'Value': item["Value"].replace('\xa0', '').strip()<br />                }</pre> | 應用程式開發人員、Python 技能 | 
| 插入記錄。 | 使用以下程式碼做為上一個`for`迴圈的一部分。<pre>change_response = route53_client.change_resource_record_sets(<br />            HostedZoneId="xxxxxxxx",<br />            ChangeBatch={<br />                'Comment': 'Created by automation',<br />                'Changes': [<br />                    {<br />                        'Action': 'UPSERT',<br />                        'ResourceRecordSet': {<br />                            'Name': fqn_name,<br />                            'Type': rec_type,<br />                            'TTL': item["TTL"],<br />                            'ResourceRecords': res_rec<br />                        }<br />                    }<br />                ]<br />            }<br />    )</pre>其中 `xxxxxxx`是此史詩中第一個步驟的託管區域 ID。 | 應用程式開發人員、Python 技能 | 

## 相關資源
<a name="migrate-dns-records-in-bulk-to-an-amazon-route-53-private-hosted-zone-resources"></a>

**參考**
+ [透過匯入區域檔案建立記錄 ](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-creating-import.html)(Amazon Route 53 文件）
+ [create\$1hosted\$1zone 方法](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/route53.html#Route53.Client.create_hosted_zone) (Boto3 文件）
+ [change\$1resource\$1record\$1sets 方法](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/route53.html#Route53.Client.change_resource_record_sets) (Boto3 文件）

**教學課程和影片**
+ [Python 教學課程](https://docs.python.org/3/tutorial/) (Python 文件）
+ [使用 Amazon Route 53 的 DNS 設計](https://www.youtube.com/watch?v=2y_RBjDkRgY) (YouTube 影片、*AWS Online Tech Talks*)

# 當您從 F5 遷移到 AWS 上的 Application Load Balancer 時修改 HTTP 標頭
<a name="modify-http-headers-when-you-migrate-from-f5-to-an-application-load-balancer-on-aws"></a>

*Sachin Trivedi，Amazon Web Services*

## 總結
<a name="modify-http-headers-when-you-migrate-from-f5-to-an-application-load-balancer-on-aws-summary"></a>

當您將使用 F5 Load Balancer 的應用程式遷移至 Amazon Web Services (AWS)，並想要在 AWS 上使用 Application Load Balancer 時，遷移 F5 規則以進行標頭修改是常見的問題。Application Load Balancer 不支援標頭修改，但您可以使用 Amazon CloudFront 做為內容交付網路 (CDN) 和 Lambda@Edge 來修改標頭。

此模式說明必要的整合，並透過使用 AWS CloudFront 和 Lambda@Edge 提供標頭修改的範例程式碼。

## 先決條件和限制
<a name="modify-http-headers-when-you-migrate-from-f5-to-an-application-load-balancer-on-aws-prereqs"></a>

**先決條件**
+ 內部部署應用程式，使用 F5 負載平衡器搭配使用 取代 HTTP 標頭值的組態`if, else`。如需此組態的詳細資訊，請參閱 F5 產品文件中的 [HTTP：：header](https://clouddocs.f5.com/api/irules/HTTP__header.html)。 

**限制**
+ 此模式適用於 F5 負載平衡器標頭自訂。對於其他第三方負載平衡器，請檢查負載平衡器文件以取得支援資訊。
+ 您用於 Lambda@Edge 的 Lambda 函數必須位於美國東部 （維吉尼亞北部） 區域。

## Architecture
<a name="modify-http-headers-when-you-migrate-from-f5-to-an-application-load-balancer-on-aws-architecture"></a>

下圖顯示 AWS 上的架構，包括 CDN 和其他 AWS 元件之間的整合流程。

![\[使用 Amazon CloudFront 和 Lambda@Edge 修改標頭的架構\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/00abbe3c-2453-4291-9b24-b488dced4868/images/4ee9a19e-6da2-4c5a-a8bc-19d3918a166e.png)


## 工具
<a name="modify-http-headers-when-you-migrate-from-f5-to-an-application-load-balancer-on-aws-tools"></a>

**AWS 服務**
+ [Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html) - Application Load Balancer 是一種 AWS 全受管負載平衡服務，可在開放系統互連 (OSI) 模型的第七層運作。它平衡多個目標的流量，並支援基於 HTTP 標頭和方法、查詢字串以及主機型或路徑型路由的進階路由請求。
+ [Amazon CloudFront](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html) – Amazon CloudFront 是一種 Web 服務，可加速將靜態和動態 Web 內容，例如 .html、.css、.js 和映像檔案分發給使用者。CloudFront 透過稱為節點的全球資料中心網路提供內容，以降低延遲並改善效能。
+ [Lambda@Edge](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-the-edge.html) ─ Lambda@Edge 是 AWS Lambda 的延伸，可讓您執行函數來自訂 CloudFront 提供的內容。您可以在美國東部 （維吉尼亞北部） 區域中編寫函數，然後將函數與 CloudFront 分佈建立關聯，以在全球各地自動複寫程式碼，而無需佈建或管理伺服器。這可減少延遲並改善使用者體驗。

**Code**

下列範例程式碼提供修改 CloudFront 回應標頭的藍圖。遵循 *Epics* 區段中的指示來部署程式碼。

```
exports.handler = async (event, context) => {
    const response = event.Records[0].cf.response;
    const headers = response.headers;


    const headerNameSrc = 'content-security-policy';
    const headerNameValue = '*.xyz.com';


    if (headers[headerNameSrc.toLowerCase()]) {
        headers[headerNameSrc.toLowerCase()] = [{
            key: headerNameSrc,
            value: headerNameValue,
        }];
        console.log(`Response header "${headerNameSrc}" was set to ` +
                    `"${headers[headerNameSrc.toLowerCase()][0].value}"`);
    }
    else {
            headers[headerNameSrc.toLowerCase()] = [{
            key: headerNameSrc,
            value: headerNameValue,
            }];
    }
    return response;
};
```

## 史詩
<a name="modify-http-headers-when-you-migrate-from-f5-to-an-application-load-balancer-on-aws-epics"></a>

### 建立 CDN 分佈
<a name="create-a-cdn-distribution"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立 CloudFront Web 分佈。 | 在此步驟中，您會建立 CloudFront 分佈，以告知 CloudFront 您要從何處交付內容，以及如何追蹤和管理內容交付的詳細資訊。若要使用主控台建立分佈，請登入 AWS 管理主控台，開啟 [CloudFront 主控台](https://console.aws.amazon.com/cloudfront/v3/home)，然後遵循 [CloudFront 文件](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-creating-console.html)中的步驟。 | 雲端管理員 | 

### 建立和部署 Lambda@Edge 函數
<a name="create-and-deploy-the-lambda-edge-function"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立和部署 Lambda@Edge 函數。 | 您可以使用修改 CloudFront 回應標頭的藍圖來建立 Lambda@Edge 函數。（其他 bluePrints 適用於不同的使用案例；如需詳細資訊，請參閱 CloudFront 文件中的 [Lambda@Edge 範例函數](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-examples.html)。) 若要建立 Lambda@Edge 函數：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/modify-http-headers-when-you-migrate-from-f5-to-an-application-load-balancer-on-aws.html) | AWS 管理員 | 
| 部署 Lambda@Edge 函數。 | 遵循教學課程[的步驟 4](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-how-it-works-tutorial.html#lambda-edge-how-it-works-tutorial-add-trigger)：在 Amazon CloudFront 文件中建立簡單的 Lambda@Edge 函數，以設定 CloudFront 觸發並部署函數。 ** | AWS 管理員 | 

## 相關資源
<a name="modify-http-headers-when-you-migrate-from-f5-to-an-application-load-balancer-on-aws-resources"></a>

**CloudFront 文件**
+ [自訂原始伺服器的請求和回應行為](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html) 
+ [使用分佈](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-working-with.html) 
+ [Lambda@Edge 範例函數](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-examples.html) 
+ [使用 Lambda@Edge 在邊緣自訂](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-the-edge.html)
+ [教學課程：建立簡單的 Lambda@Edge 函數](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-how-it-works-tutorial.html)

# 為多個 中的傳入網際網路存取建立 Network Access Analyzer 調查結果報告 AWS 帳戶
<a name="create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts"></a>

*Mike Virgilio，Amazon Web Services*

## 總結
<a name="create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts-summary"></a>

意外的傳入網際網路存取 AWS 資源可能會對組織的資料周邊造成風險。[Network Access Analyzer](https://docs.aws.amazon.com/vpc/latest/network-access-analyzer/what-is-network-access-analyzer.html) 是一種 Amazon Virtual Private Cloud (Amazon VPC) 功能，可協助您識別對 Amazon Web Services () 上資源的意外網路存取AWS。您可以使用 Network Access Analyzer 來指定網路存取需求，並識別不符合指定需求的潛在網路路徑。您可以使用 Network Access Analyzer 執行下列動作：

1. 識別可透過網際網路閘道存取網際網路 AWS 的資源。

1. 驗證您的虛擬私有雲端 (VPCs) 是否已適當分割，例如隔離生產和開發環境，以及分隔交易工作負載。

Network Access Analyzer 會分析end-to-end網路連線能力條件，而不只是單一元件。為了判斷資源是否可存取網際網路，Network Access Analyzer 會評估網際網路閘道、VPC 路由表、網路存取控制清單 (ACLs)、彈性網路介面上的公有 IP 地址，以及安全群組。如果任何這些元件阻止網際網路存取，Network Access Analyzer 不會產生問題清單。例如，如果 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體有一個開放的安全群組，允許來自 的流量，`0/0`但執行個體位於無法從任何網際網路閘道路由的私有子網路中，則 Network Access Analyzer 不會產生問題清單。這可提供高逼真度的結果，讓您可以識別可從網際網路真正存取的資源。

當您執行 Network Access Analyzer 時，您可以使用 [Network Access Scopes](https://docs.aws.amazon.com/vpc/latest/network-access-analyzer/what-is-network-access-analyzer.html#concepts) 來指定您的網路存取需求。此解決方案可識別網際網路閘道和彈性網路界面之間的網路路徑。在此模式中，您會在 AWS 帳戶 組織中的集中式 中部署解決方案，並由 管理， AWS Organizations並分析 AWS 區域組織中任何帳戶中的所有 帳戶。

此解決方案的設計考量如下：
+  AWS CloudFormation 範本可減少在此模式中部署 AWS 資源所需的工作量。
+ 您可以在部署時調整 CloudFormation 範本和 **naa-script.sh** 指令碼中的參數，為您的環境自訂參數。
+ Bash 指令碼會自動平行佈建和分析多個帳戶的網路存取範圍。
+ Python 指令碼會處理問題清單、擷取資料，然後合併結果。您可以選擇檢閱 CSV 格式或 中的 Network Access Analyzer 調查結果合併報告 AWS Security Hub CSPM。CSV 報告的範例可在此模式的其他資訊[其他資訊](#create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts-additional)區段中取得。
+ 您可以修復問題清單，也可以將問題清單新增至 **naa-exclusions.csv** 檔案，將其排除在未來的分析之外。

## 先決條件和限制
<a name="create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts-prereqs"></a>

**先決條件**
+  AWS 帳戶 用於託管安全服務和工具的 ，以組織的成員帳戶的形式進行管理 AWS Organizations。在此模式中，此帳戶稱為安全帳戶。
+ 在安全帳戶中，您必須擁有具有傳出網際網路存取權的私有子網路。如需說明，請參閱 Amazon VPC 文件中的[建立子網路](https://docs.aws.amazon.com/vpc/latest/userguide/create-subnets.html)。您可以使用 [NAT 閘道](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html)或[界面 VPC 端點](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html)來建立網際網路存取。
+ 存取 AWS Organizations 管理帳戶或具有 CloudFormation 委派管理員許可的帳戶。如需說明，請參閱 CloudFormation 文件中的[註冊委派管理員](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-delegated-admin.html)。
+ 啟用 AWS Organizations 和 CloudFormation 之間的受信任存取。如需說明，請參閱 CloudFormation 文件中的[使用 啟用受信任存取 AWS Organizations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-enable-trusted-access.html)。
+ 如果您要將調查結果上傳至 Security Hub CSPM，則必須在帳戶和佈建 Amazon EC2 執行個體 AWS 區域 的帳戶中啟用 Security Hub CSPM。如需詳細資訊，請參閱[設定 AWS Security Hub CSPM](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-settingup.html)。

**限制**
+ 由於 Network Access Analyzer 功能的限制，目前不會分析跨帳戶網路路徑。
+ 目標 AWS 帳戶 必須以組織身分管理 AWS Organizations。如果您未使用 AWS Organizations，您可以更新您環境的 **naa-execrole.yaml** CloudFormation 範本和 **naa-script.sh** 指令碼。反之，您可以提供您要執行指令碼 AWS 帳戶 IDs 和區域的清單。
+ CloudFormation 範本旨在將 Amazon EC2 執行個體部署在具有傳出網際網路存取的私有子網路中。 AWS Systems Manager 代理程式 (SSM 代理程式） 需要傳出存取權才能到達 Systems Manager 服務端點，而您需要傳出存取權才能複製程式碼儲存庫並安裝相依性。如果您想要使用公有子網路，您必須修改 **naa-resources.yaml** 範本，將[彈性 IP 地址](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html)與 Amazon EC2 執行個體建立關聯。

## Architecture
<a name="create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts-architecture"></a>

**目標架構**

*選項 1：存取 Amazon S3 儲存貯體中的調查結果*

![\[存取 Amazon S3 儲存貯體中 Network Access Analyzer 調查結果報告的架構圖\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/eda6abba-632a-4e3d-92b9-31848fa6dead/images/d0b08437-e5b0-47a1-abdd-040c67b5da8f.png)


圖表顯示下列程序：

1. 如果您手動執行解決方案，使用者會使用 Session Manager 驗證 Amazon EC2 執行個體，然後執行 **naa-script.sh** 指令碼。此 shell 指令碼會執行步驟 2–7。

   如果您自動執行解決方案，**naa-script.sh** 指令碼會根據您在 cron 表達式中定義的排程自動啟動。此 shell 指令碼會執行步驟 2–7。如需詳細資訊，請參閱本節結尾的*自動化和擴展*。

1. Amazon EC2 執行個體會從 Amazon S3 儲存貯體下載最新的 **naa-exception.csv** 檔案。此檔案稍後會在 Python 指令碼處理排除的程序中使用。

1. Amazon EC2 執行個體會擔任 `NAAEC2Role` AWS Identity and Access Management (IAM) 角色，授予存取 Amazon S3 儲存貯體的許可，並擔任組織中其他帳戶中的 `NAAExecRole` IAM 角色。

1. Amazon EC2 執行個體會在組織的管理帳戶中擔任 `NAAExecRole` IAM 角色，並在組織中產生帳戶清單。

1. Amazon EC2 執行個體會擔任組織成員帳戶中的 `NAAExecRole` IAM 角色 （在架構圖中稱為*工作負載帳戶*)，並在每個帳戶中執行安全評估。調查結果會以 JSON 檔案形式存放在 Amazon EC2 執行個體上。

1. Amazon EC2 執行個體使用 Python 指令碼來處理 JSON 檔案、擷取資料欄位，以及建立 CSV 報告。

1. Amazon EC2 執行個體會將 CSV 檔案上傳至 Amazon S3 儲存貯體。

1. Amazon EventBridge 規則會偵測檔案上傳，並使用 Amazon SNS 主題來傳送電子郵件，通知使用者報告已完成。

1. 使用者從 Amazon S3 儲存貯體下載 CSV 檔案。使用者將結果匯入 Excel 範本並檢閱結果。

*選項 2：存取 中的問題清單 AWS Security Hub CSPM*

![\[透過 AWS Security Hub 存取 Network Access Analyzer 調查結果的架構圖\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/eda6abba-632a-4e3d-92b9-31848fa6dead/images/9cb4f059-dfb6-4a33-9f8d-159fe5df0d64.png)


圖表顯示下列程序：

1. 如果您手動執行解決方案，使用者會使用 Session Manager 驗證 Amazon EC2 執行個體，然後執行 **naa-script.sh** 指令碼。此 shell 指令碼會執行步驟 2–7。

   如果您自動執行解決方案，**naa-script.sh** 指令碼會根據您在 cron 表達式中定義的排程自動啟動。此 shell 指令碼會執行步驟 2–7。如需詳細資訊，請參閱本節結尾的*自動化和擴展*。

1. Amazon EC2 執行個體會從 Amazon S3 儲存貯體下載最新的 **naa-exception.csv** 檔案。此檔案稍後會在 Python 指令碼處理排除的程序中使用。

1. Amazon EC2 執行個體會擔任 `NAAEC2Role` IAM 角色，授予存取 Amazon S3 儲存貯體和在組織中其他帳戶中擔任 `NAAExecRole` IAM 角色的許可。

1. Amazon EC2 執行個體會在組織的管理帳戶中擔任 `NAAExecRole` IAM 角色，並在組織中產生帳戶清單。

1. Amazon EC2 執行個體會擔任組織成員帳戶中的 `NAAExecRole` IAM 角色 （在架構圖中稱為*工作負載帳戶*)，並在每個帳戶中執行安全評估。調查結果會以 JSON 檔案形式存放在 Amazon EC2 執行個體上。

1. Amazon EC2 執行個體使用 Python 指令碼來處理 JSON 檔案，並擷取資料欄位以匯入 Security Hub CSPM。

1. Amazon EC2 執行個體會將 Network Access Analyzer 調查結果匯入 Security Hub CSPM。

1. Amazon EventBridge 規則會偵測匯入，並使用 Amazon SNS 主題來傳送電子郵件，通知使用者程序已完成。

1. 使用者會在 Security Hub CSPM 中檢視問題清單。

**自動化和擴展**

您可以排程此解決方案，以自訂排程自動執行 **naa-script.sh** 指令碼。若要設定自訂排程，請在 **naa-resources.yaml** CloudFormation 範本中修改 `CronScheduleExpression` 參數。例如， 的預設值會在每週日午夜`0 0 * * 0`執行解決方案。的值`0 0 * 1-12 0`會在每月第一個星期日的午夜執行解決方案。如需使用 Cron 表達式的詳細資訊，請參閱 Systems Manager 文件中的 [Cron 和 Rate 表達](https://docs.aws.amazon.com/systems-manager/latest/userguide/reference-cron-and-rate-expressions.html)式。

如果您想要在部署`NAA-Resources`堆疊之後調整排程，您可以在 中手動編輯 Cron 排程`/etc/cron.d/naa-schedule`。

## 工具
<a name="create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts-tools"></a>

**AWS 服務**
+ [Amazon Elastic Compute Cloud (Amazon EC2)](https://docs.aws.amazon.com/ec2/) 在 AWS 雲端中提供可擴展的運算容量。您可以視需要啟動任意數量的虛擬伺服器，，並快速進行擴展或縮減。
+ [Amazon EventBridge](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is.html) 是一種無伺服器事件匯流排服務，可協助您將應用程式與來自各種來源的即時資料連線。例如， AWS Lambda 函數、使用 API 目的地的 HTTP 調用端點，或其他事件匯流排 AWS 帳戶。
+ [AWS Identity and Access Management (IAM)](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html) 透過控制已驗證並獲授權使用的人員，協助您安全地管理對 AWS 資源的存取。
+ [AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html) 是一種帳戶管理服務，可協助您將多個 合併 AWS 帳戶 到您建立並集中管理的組織。
+ [AWS Security Hub CSPM](https://docs.aws.amazon.com/securityhub/latest/userguide/what-is-securityhub.html) 提供 中安全狀態的完整檢視 AWS。它還可協助您根據安全產業標準和最佳實務來檢查 AWS 環境。
+ [Amazon Simple Notification Service (Amazon SNS)](https://docs.aws.amazon.com/sns/latest/dg/welcome.html) 可協助您協調和管理發佈者和用戶端之間的訊息交換，包括 Web 伺服器和電子郵件地址。
+ [Amazon Simple Storage Service (Amazon S3)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) 是一種雲端型物件儲存服務，可協助您儲存、保護和擷取任何數量的資料。
+ [AWS Systems Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/what-is-systems-manager.html) 可協助您管理在 中執行的應用程式和基礎設施 AWS 雲端。它可簡化應用程式和資源管理、縮短偵測和解決操作問題的時間，並協助您大規模安全地管理 AWS 資源。此模式使用 Systems Manager 的功能 Session Manager。

**程式碼儲存庫**

此模式的程式碼可在 GitHub [Network Access Analyzer 多帳戶分析](https://github.com/aws-samples/network-access-analyzer-multi-account-analysis)儲存庫中使用。程式碼儲存庫包含下列檔案：
+ **naa-script.sh** – 此 bash 指令碼用於 AWS 帳戶平行啟動多個 Network Access Analyzer 分析。如 **naa-resources.yaml** CloudFormation 範本中所定義，此指令碼會自動部署到 Amazon EC2 執行個體上的 `/usr/local/naa` 資料夾。
+ **naa-resources.yaml** – 您可以使用此 CloudFormation 範本在組織的安全帳戶中建立堆疊。此範本會部署此帳戶所有必要的資源，以支援解決方案。此堆疊必須部署在 **naa-execrole.yaml** 範本之前。
**注意**  
如果刪除並重新部署此堆疊，您必須重建`NAAExecRole`堆疊集，才能在 IAM 角色之間重建跨帳戶相依性。
+ **naa-execrole.yaml** – 您可以使用此 CloudFormation 範本建立堆疊集，在組織中的所有帳戶中部署 `NAAExecRole` IAM 角色，包括 管理帳戶。
+ **naa-processfindings.py** – **naa-script.sh **指令碼會自動呼叫此 Python 指令碼來處理 Network Access Analyzer JSON 輸出、排除 **naa-exclusions.csv** 檔案中任何已知良好的資源，然後產生合併結果的 CSV 檔案，或將結果匯入 Security Hub CSPM。

## 史詩
<a name="create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts-epics"></a>

### 準備部署
<a name="prepare-for-deployment"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 複製程式碼儲存庫。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 
| 檢閱範本。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 

### 建立 CloudFormation 堆疊
<a name="create-the-cfnshort-stacks"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 佈建安全帳戶中的資源。 | 使用 **naa-resources.yaml** 範本，您可以建立 CloudFormation 堆疊，以部署安全帳戶中所有必要的資源。如需說明，請參閱 CloudFormation 文件中的[建立堆疊](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-create-stack.html)。部署此範本時，請注意下列事項：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html)[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 
| 在成員帳戶中佈建 IAM 角色。 | 在 AWS Organizations 管理帳戶或具有 CloudFormation 委派管理員許可的帳戶中，使用 **naa-execrole.yaml** 範本建立 CloudFormation 堆疊集。堆疊集會在組織中的所有成員帳戶中部署 `NAAExecRole` IAM 角色。如需說明，請參閱 CloudFormation 文件中的[建立具有服務受管許可的堆疊集](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-getting-started-create.html#stacksets-orgs-associate-stackset-with-org)。部署此範本時，請注意下列事項：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 
| 在管理帳戶中佈建 IAM 角色。 | 使用 **naa-execrole.yaml** 範本，您可以建立 CloudFormation 堆疊，在組織的管理帳戶中部署 `NAAExecRole` IAM 角色。您先前建立的堆疊集不會在管理帳戶中部署 IAM 角色。如需說明，請參閱 CloudFormation 文件中的[建立堆疊](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-create-stack.html)。部署此範本時，請注意下列事項：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 

### 執行分析
<a name="perform-the-analysis"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 自訂 shell 指令碼。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 
| 分析目標帳戶。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 
| 選項 1 – 從 Amazon S3 儲存貯體擷取結果。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 
| 選項 2 – 在 Security Hub CSPM 中檢閱結果。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 

### 修復和排除問題清單
<a name="remediate-and-exclude-findings"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 修復問題清單。 | 修復您要解決的任何問題清單。如需如何在 AWS 身分、資源和網路周圍建立周邊的詳細資訊和最佳實務，請參閱[在 上建立資料周邊 AWS](https://docs.aws.amazon.com/whitepapers/latest/building-a-data-perimeter-on-aws/building-a-data-perimeter-on-aws.html) (AWS 白皮書）。 | AWS DevOps | 
| 排除具有已知良好網路路徑的資源。 | 如果 Network Access Analyzer 產生應可從網際網路存取的資源調查結果，則您可以將這些資源新增至排除清單。下次 Network Access Analyzer 執行時，不會產生該資源的問題清單。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 

### （選用） 更新 naa-script.sh 指令碼
<a name="optional-update-the-naa-script-sh-script"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 更新 naa-script.sh 指令碼。 | 如果您想要將 **naa-script.sh** 指令碼更新至儲存庫中的最新版本，請執行下列動作：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 

### (選用) 清除
<a name="optional-clean-up"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 刪除所有部署的資源。 | 您可以在帳戶中保留部署的資源。如果您想要取消佈建所有資源，請執行下列動作：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | AWS DevOps | 

## 疑難排解
<a name="create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts-troubleshooting"></a>


| 問題 | 解決方案 | 
| --- | --- | 
| 無法使用 Session Manager 連線至 Amazon EC2 執行個體。 | SSM Agent 必須能夠與 Systems Manager 端點通訊。請執行下列操作：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts.html) | 
| 部署堆疊集時，CloudFormation 主控台會提示您使用 `Enable trusted access with AWS Organizations to use service-managed permissions`。 | 這表示 AWS Organizations 和 CloudFormation 之間尚未啟用受信任的存取。部署服務受管堆疊集需要信任的存取權。選擇按鈕以啟用受信任的存取。如需詳細資訊，請參閱 CloudFormation 文件中的[啟用受信任存取](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-enable-trusted-access.html)。 | 

## 相關資源
<a name="create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts-resources"></a>
+ [新增 – Amazon VPC Network Access Analyzer](https://aws.amazon.com/blogs/aws/new-amazon-vpc-network-access-analyzer/) (AWS 部落格文章）
+ [AWS re：Inforce 2022 - 驗證 AWS (NIS202) （影片） 上的有效網路存取控制](https://youtu.be/aN2P2zeQek0) 
+ [示範 - 使用 Network Access Analyzer 進行全組織的網際網路傳入資料路徑分析](https://youtu.be/1IFNZWy4iy0) （影片）

## 其他資訊
<a name="create-a-report-of-network-access-analyzer-findings-for-inbound-internet-access-in-multiple-aws-accounts-additional"></a>

**範例主控台輸出**

以下範例顯示產生目標帳戶清單和分析目標帳戶的輸出。

```
[root@ip-10-10-43-82 naa]# ./naa-script.sh
download: s3://naa-<account ID>-us-east-1/naa-exclusions.csv to ./naa-exclusions.csv

AWS Management Account: <Management account ID>

AWS Accounts being processed...
<Account ID 1> <Account ID 2> <Account ID 3>

Assessing AWS Account: <Account ID 1>, using Role: NAAExecRole
Assessing AWS Account: <Account ID 2>, using Role: NAAExecRole
Assessing AWS Account: <Account ID 3>, using Role: NAAExecRole
Processing account: <Account ID 1> / Region: us-east-1
Account: <Account ID 1> / Region: us-east-1 – Detecting Network Analyzer scope...
Processing account: <Account ID 2> / Region: us-east-1
Account: <Account ID 2> / Region: us-east-1 – Detecting Network Analyzer scope...
Processing account: <Account ID 3> / Region: us-east-1
Account: <Account ID 3> / Region: us-east-1 – Detecting Network Analyzer scope...
Account: <Account ID 1> / Region: us-east-1 – Network Access Analyzer scope detected.
Account: <Account ID 1> / Region: us-east-1 – Continuing analyses with Scope ID. Accounts with many resources may take up to one hour
Account: <Account ID 2> / Region: us-east-1 – Network Access Analyzer scope detected.
Account: <Account ID 2> / Region: us-east-1 – Continuing analyses with Scope ID. Accounts with many resources may take up to one hour
Account: <Account ID 3> / Region: us-east-1 – Network Access Analyzer scope detected.
Account: <Account ID 3> / Region: us-east-1 – Continuing analyses with Scope ID. Accounts with many resources may take up to one hour
```

**CSV 報告範例**

下圖是 CSV 輸出的範例。

![\[此解決方案產生的 CSV 報告範例 1。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/eda6abba-632a-4e3d-92b9-31848fa6dead/images/55e02e61-054e-4da6-aaae-c9a8b6f4f272.png)


![\[此解決方案產生的 CSV 報告範例 2。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/eda6abba-632a-4e3d-92b9-31848fa6dead/images/95f980ad-92c1-4392-92d4-9c742755aab2.png)


# 在多帳戶 AWS 環境中設定混合網路的 DNS 解析
<a name="set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment"></a>

*Anvesh Koganti，Amazon Web Services*

## 總結
<a name="set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-summary"></a>

此模式提供全方位解決方案，可在包含多個 Amazon Web Services (AWS) 帳戶的混合網路環境中設定 DNS 解析。它可透過 Amazon Route 53 Resolver 端點在內部部署網路和 AWS 環境之間啟用雙向 DNS 解析。模式提供兩種解決方案，可在[多帳戶集中式架構](https://docs.aws.amazon.com/whitepapers/latest/hybrid-cloud-dns-options-for-vpc/scaling-dns-management-across-multiple-accounts-and-vpcs.html#multi-account-centralized)中啟用 DNS 解析：
+ *基本設定*不使用 Route 53 Profiles。它有助於最佳化低複雜度的中小型部署的成本。
+ *增強型設定*使用 Route 53 Profiles 來簡化操作。它最適合大型或更複雜的 DNS 部署。

**注意**  
在實作之前，請檢閱*限制*一節，了解服務限制和配額。當您做出決策時，請考慮管理開銷、成本、營運複雜性和團隊專業知識等因素。

## 先決條件和限制
<a name="set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-prereqs"></a>

**先決條件**
+ 跨共用服務和工作負載帳戶部署 Amazon Virtual Private Cloud (Amazon VPC) 的 AWS 多帳戶環境 （最好遵循帳戶結構的[AWS 最佳實務，透過 AWS Control Tower](https://docs.aws.amazon.com/controltower/latest/userguide/aws-multi-account-landing-zone.html) 設定）。
+ 現場部署網路與 AWS 環境之間的現有混合連線 (AWS Direct Connect 或 AWS Site-to-Site VPN)。
+ Amazon VPC 對等 AWS Transit Gateway互連，或適用於 VPCs AWS 雲端 WAN。（應用程式流量需要此連線。 DNS 解析不需要它。 DNS 解析的運作與 VPCs.)
+ 在內部部署環境中執行的 DNS 伺服器。

**限制**
+ Route 53 Resolver 端點、規則和設定檔是區域性建構， AWS 區域 可能需要針對全球組織複寫多個 。
+ 如需 Route 53 Resolver、私有託管區域和設定檔的服務配額完整清單，請參閱 Route 53 文件中的[配額](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DNSLimitations.html)。

## Architecture
<a name="set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-architecture"></a>

**目標技術堆疊**
+ Route 53 傳出和傳入端點
+ 條件式轉送的 Route 53 Resolver 規則
+ AWS Resource Access Manager (AWS RAM)
+ Route 53 私有託管區域

**目標架構**

**傳出和傳入端點**

下圖顯示從 AWS 到內部部署的 DNS 解析流程。這是網域託管在內部部署的傳出解析度的連線設定。以下是設定此設定所涉及程序的高階概觀。如需詳細資訊，請參閱 [Epics](#set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-epics) 區段。

1. 在共用服務 VPC 中部署傳出 Route 53 Resolver 端點。

1. 在共用服務帳戶中為內部部署託管的網域建立 Route 53 Resolver 規則 （轉送規則）。

1. 在需要解析內部部署託管網域的其他 帳戶中，共用規則並將其與 VPCs 建立關聯。這可以根據您的使用案例以不同的方式完成，如本節稍後所述。

![\[AWS 中的傳入和傳出端點到內部部署 DNS 解析流程。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/01e700cd-be8c-4a5d-bc89-b901a260d045/images/d69d4cad-5e2c-4481-9370-2708e8a4f8c1.png)


設定連線後，傳出解析中涉及的步驟如下：

1. Amazon Elastic Compute Cloud (Amazon EC2) 執行個體會將 的 DNS 解析請求`db.onprem.example.com`傳送至 VPC\$12 地址的 VPC Route 53 Resolver。

1. Route 53 Resolver 會檢查 Resolver 規則，並使用傳出端點將請求轉送至內部部署 DNS 伺服器 IPs。

1. 傳出端點會將請求轉送至內部部署 DNS IPs。流量會經過共用服務 VPC 與內部部署資料中心之間已建立的混合網路連線。

1. 內部部署 DNS 伺服器會回應傳出端點，然後將回應轉送回 VPC 的 Route 53 Resolver。Resolver 會將回應傳回 EC2 執行個體。

下圖顯示從內部部署環境到 的 DNS 解析流程 AWS。這是網域託管所在之傳入解析度的連線設定 AWS。以下是設定此設定所涉及程序的高階概觀。如需詳細資訊，請參閱 [Epics](#set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-epics) 區段。

1. 在共用服務 VPC 中部署傳入解析程式端點。

1. 在共用服務帳戶中建立私有託管區域 （集中式方法）。

1. 將私有託管區域與共用服務 VPC 建立關聯。共用這些區域並將其與跨帳戶 VPCs建立關聯，以進行 VPC-to-VPC DNS 解析。這可以根據您的使用案例以不同的方式完成，如本節稍後所述。

![\[內部部署中傳入和傳出端點到 AWS DNS 解析流程。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/01e700cd-be8c-4a5d-bc89-b901a260d045/images/a6f5348c-2041-453e-8939-2b4ee0b7ebd8.png)


設定連線後，傳入解析中涉及的步驟如下：

1. 內部部署資源會將 的 DNS 解析請求`ec2.prod.aws.example.com`傳送至內部部署 DNS 伺服器。

1. 內部部署 DNS 伺服器會透過混合網路連線，將請求轉送至共用服務 VPC 中的傳入解析程式端點。

1. 在 VPC Route 53 Resolver 的協助下，傳入解析程式端點會在相關聯的私有託管區域中查詢請求，並取得適當的 IP 地址。

1. 這些 IP 地址會傳回現場部署 DNS 伺服器，將回應傳回現場部署資源。

此組態可讓內部部署資源透過傳入端點將查詢路由到適當的 AWS 私有託管區域，來解析私有網域名稱。在此架構中，私有託管區域集中在共用服務 VPC 中，允許單一團隊進行中央 DNS 管理。這些區域可以與許多 VPCs相關聯，以解決 VPC-to-VPC解析使用案例。或者，您可能想要將 DNS 網域擁有權和管理委派給每個網域 AWS 帳戶。在這種情況下，每個帳戶都會管理自己的私有託管區域，並將每個區域與中央共用服務 VPC 建立關聯，以便與內部部署環境統一解析。此分散式方法超出此模式的範圍。如需詳細資訊，請參閱 Amazon [ VPCs 混合雲端 DNS 選項白皮書中的跨多個帳戶和 VPC 擴展](https://docs.aws.amazon.com/whitepapers/latest/hybrid-cloud-dns-options-for-vpc/scaling-dns-management-across-multiple-accounts-and-vpcs.html) DNS 管理。 **

當您使用解析程式端點建立基本 DNS 解析流程時，您需要判斷如何管理解析程式規則和跨 私有託管區域的共用和關聯 AWS 帳戶。您可以透過兩種方式處理此問題：透過使用 AWS RAM 共用解析程式規則和直接私有託管區域關聯的自我管理共用，如*基本設定*章節所述，或透過 Route 53 設定檔，如*增強型設定*章節所述。選擇取決於組織的 DNS 管理偏好設定和操作需求。下列架構圖說明擴展的環境，其中包含跨不同帳戶的多個 VPCs，代表典型的企業部署。

**基本設定**

在基本設定中，多帳戶 AWS 環境中混合 DNS 解析的實作會使用 AWS RAM 來共用解析程式轉送規則和私有託管區域關聯，以管理內部部署 AWS 和資源之間的 DNS 查詢。此方法使用共用服務 VPC 中連線至內部部署網路的集中式 Route 53 Resolver 端點，以有效率地處理傳入和傳出 DNS 解析。
+ 對於傳出解決方案，解析程式轉送規則會在共用服務帳戶中建立，然後使用 AWS 帳戶 與其他 共用 AWS RAM。此共用僅限於相同區域內的帳戶。然後，目標帳戶可以將這些規則與其 VPCs建立關聯，並讓這些 VPCs中的資源解析內部部署網域名稱。
+ 對於傳入解析度，私有託管區域會在共用服務帳戶中建立，並與共用服務 VPC 相關聯。這些區域接著可以使用 Route 53 API、 AWS SDKs 或 AWS Command Line Interface () 與其他VPCs 建立關聯AWS CLI。然後，相關聯 VPCs 中的資源可以解析私有託管區域中定義的 DNS 記錄，這會在整個 AWS 環境中建立統一的 DNS 檢視。

下圖顯示此基本設定中的 DNS 解析流程。

![\[在多帳戶 AWS 環境中使用混合 DNS 解析的基本設定。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/01e700cd-be8c-4a5d-bc89-b901a260d045/images/258e4bcd-e9c6-43b5-bab8-856ca22206b9.png)


當您在有限的規模上使用 DNS 基礎設施時，此設定可正常運作。不過，隨著環境的成長，管理 可能會變得具有挑戰性。管理私有託管區域和解析程式規則的共用和關聯方式的操作開銷會隨著規模VPCs而個別大幅增加。此外，每個私有託管區域的 300 個 VPC 關聯限制等服務配額，可能會成為大規模部署的限制因素。增強型設定可解決這些挑戰。

**增強型設定**

Route 53 Profiles 提供簡化的解決方案，可跨多個混合網路管理 DNS 解析 AWS 帳戶。除了個別管理私有託管區域和解析程式規則之外，您可以將 DNS 組態分組為單一容器，以便在區域中VPCs 和帳戶之間輕鬆共用和套用。此設定會在共用服務 VPC 中維護集中式 Resolver 端點架構，同時大幅簡化 DNS 組態的管理。

下圖顯示增強型設定中的 DNS 解析流程。

![\[在多帳戶 AWS 環境中使用 Route 53 Profiles 進行混合 DNS 解析的進階設定。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/01e700cd-be8c-4a5d-bc89-b901a260d045/images/55b9681d-ddb4-4a55-b4ec-fc9afa9870fa.png)


Route 53 Profiles 可讓您將私有託管區域關聯、解析程式轉送規則和 DNS 防火牆規則封裝為單一可共用的單位。您可以在共用服務帳戶中建立設定檔，並使用 與成員帳戶共用 AWS RAM。當設定檔共用並套用至目標 VPCs時，服務會自動處理所有必要的關聯和組態。這可大幅降低 DNS 管理的操作負荷，並為不斷成長的環境提供絕佳的可擴展性。

**自動化和擴展**

使用基礎設施做為程式碼 (IaC) 工具，例如 CloudFormation 或 Terraform，以自動佈建和管理 Route 53 Resolver 端點、規則、私有託管區域和設定檔。將 DNS 組態與持續整合和持續交付 (CI/CD) 管道整合，以實現一致性、可重複性和快速更新。

## 工具
<a name="set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-tools"></a>

**AWS 服務**
+ [AWS Resource Access Manager (AWS RAM)](https://docs.aws.amazon.com/ram/latest/userguide/what-is.html) 可協助您安全地跨 共用資源 AWS 帳戶 ，以減少營運開銷並提供可見性和可稽核性。
+ [Amazon Route 53 Resolver](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver.html) 會以遞迴方式回應來自 AWS 資源的 DNS 查詢，且預設可在所有 VPCs 中使用。您可以建立解析程式端點和條件式轉送規則，以解析內部部署資料中心和 VPCs 之間的 DNS 命名空間。
+ [Amazon Route 53 私有託管區域](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-private.html)是容器，其中包含您希望 Route 53 如何回應網域及其子網域的 DNS 查詢的相關資訊。
+ [Amazon Route 53 Profiles](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/profiles.html) 可讓您以 AWS 帳戶 簡化的方式跨多個 VPCs 套用和管理 DNS 相關的 Route 53 組態。

## 最佳實務
<a name="set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-best-practices"></a>

本節提供最佳化 Route 53 Resolver 的一些最佳實務。這些代表 Route 53 最佳實務的子集。如需完整清單，請參閱 [Amazon Route 53 的最佳實務](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/best-practices.html)。

**使用解析程式端點避免迴圈組態**
+ 仔細規劃 VPC 關聯，設計您的 DNS 架構以防止遞迴路由。當 VPC 託管傳入端點時，請避免將其與可建立循環參考的解析程式規則建立關聯。
+ 當您跨帳戶共用 DNS 資源時， AWS RAM 請策略性地使用 ，以維持乾淨的路由路徑。

如需詳細資訊，請參閱 Route 53 文件中的使用[解析程式端點避免迴圈組態](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/best-practices-resolver-endpoints.html)。

**擴展解析程式端點**
+ 對於需要每秒大量查詢 (QPS) 的環境，請注意端點中的每個 ENI 限制為 10，000 個 QPS。您可以將更多 ENIs新增至端點，以擴展 DNS QPS。
+ Amazon CloudWatch 提供 `InboundQueryVolume`和 `OutboundQueryVolume`指標 （請參閱 [CloudWatch 文件](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/monitoring-resolver-with-cloudwatch.html))。建議您設定監控規則，以便在閾值超過特定值 （例如 10，000 QPS 的 80%) 時提醒您。
+ 設定 Resolver 端點的狀態安全群組規則，以防止連線追蹤限制在大量流量期間造成 DNS 查詢限流。若要進一步了解連線追蹤如何在安全群組中運作，請參閱 [Amazon EC2 文件中的 Amazon EC2 安全群組連線追蹤](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-connection-tracking.html)。 Amazon EC2 

如需詳細資訊，請參閱 Route 53 文件中的[解析程式端點擴展](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/best-practices-resolver-endpoint-scaling.html)。

**為解析程式端點提供高可用性**
+ 在至少兩個可用區域中建立 IP 地址的傳入端點以進行備援。
+ 佈建其他網路介面，以確保在維護或流量激增期間可用性。

如需詳細資訊，請參閱 Route 53 文件中的[解析程式端點高可用性](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/best-practices-resolver-endpoint-high-availability.html)。

## 史詩
<a name="set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-epics"></a>

### 部署 Route 53 Resolver 端點
<a name="deploy-r53r-endpoints"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 部署傳入端點。 | Route 53 Resolver 使用傳入端點從內部部署 DNS 解析程式接收 DNS 查詢。如需說明，請參閱 Route 53 文件中的[轉送傳入 DNS 查詢到您的 VPCs](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-forwarding-inbound-queries.html)。記下傳入端點 IP 地址。 | AWS 管理員、雲端管理員 | 
| 部署傳出端點。 | Route 53 Resolver 使用傳出端點將 DNS 查詢傳送至內部部署 DNS 解析程式。如需說明，請參閱 Route 53 文件中的[轉送傳出 DNS 查詢到您的網路](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-forwarding-outbound-queries.html)。記下輸出端點 ID。 | AWS 管理員、雲端管理員 | 

### 設定和共用 Route 53 私有託管區域
<a name="configure-and-share-r53-private-hosted-zones"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 為託管的網域建立私有託管區域 AWS。 | 此區域會保留 AWS託管網域 （例如 `prod.aws.example.com`) 中資源的 DNS 記錄，這些記錄應從內部部署環境解析。如需說明，請參閱 Route 53 文件中的[建立私有託管區域](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zone-private-creating.html)。建立私有託管區域時，您必須將 VPC 與相同帳戶擁有的託管區域建立關聯。為此選取共用服務 VPC。 | AWS 管理員、雲端管理員 | 
| 基本設定：將私有託管區域與其他帳戶中VPCs 建立關聯。 | 如果您使用的是基本設定 （請參閱[架構](#set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-architecture)一節）：若要啟用成員帳戶 VPCs來解析此私有託管區域中的 DNS 記錄，您必須將 VPCs與託管區域建立關聯。您必須授權關聯，然後以程式設計方式建立關聯。如需說明，請參閱 Route 53 文件中的[關聯 Amazon VPC 和您使用不同 建立的私有託管區域 AWS 帳戶](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zone-private-associate-vpcs-different-accounts.html)。 | AWS 管理員、雲端管理員 | 
| 增強型設定：設定和共用 Route 53 設定檔。 | 如果您使用的是增強型設定 （請參閱[架構](#set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-architecture)一節）：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment.html)視組織的結構和 DNS 需求而定，您可能需要為不同的帳戶或工作負載建立和管理多個設定檔。 | AWS 管理員、雲端管理員 | 

### 設定和共用 Route 53 Resolver 轉送規則
<a name="configure-and-share-r53r-forwarding-rules"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 為內部部署託管的網域建立轉送規則。 | 此規則會指示 Route 53 Resolver 將內部部署網域 （例如 `onprem.example.com`) 的任何 DNS 查詢轉送至內部部署 DNS 解析程式。若要建立此規則，您需要內部部署 DNS 解析程式的 IP 地址和傳出端點 ID。如需說明，請參閱 Route 53 文件中的[建立轉送規則](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-rules-managing-creating-rules.html)。 | AWS 管理員、雲端管理員 | 
| 基本設定：與其他帳戶中VPCs 共用和建立轉送規則的關聯。 | 如果您使用的是基本設定：若要讓轉送規則生效，您必須與其他帳戶中VPCs 共用並建立規則的關聯。Route 53 Resolver 接著會在解析網域時考慮規則。如需說明，請參閱 Route 53 文件中的[與其他 共用解析程式規則 AWS 帳戶 和使用共用規則](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-rules-managing-sharing.html)，以及[將轉送規則與 VPC 建立關聯](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-rules-managing-associating-rules.html)。 | AWS 管理員、雲端管理員 | 
| 增強型設定：設定和共用 Route 53 設定檔。 | 如果您使用的是增強型設定：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment.html)視組織的結構和 DNS 需求而定，您可能需要為不同的帳戶或工作負載建立和管理多個設定檔。 | AWS 管理員、雲端管理員 | 

### 設定內部部署 DNS 解析程式以進行 AWS 整合
<a name="configure-on-premises-dns-resolvers-for-aws-integration"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
|  在內部部署 DNS 解析程式中設定條件式轉送。 | 若要 AWS 從內部部署環境傳送至 以進行解析的 DNS 查詢，您必須在內部部署 DNS 解析程式中設定條件式轉送，以指向傳入端點 IP 地址。這會指示 DNS 解析程式將所有 AWS託管網域的 DNS 查詢 （例如，針對 `prod.aws.example.com`) 轉送至傳入端點 IP 地址，以供 Route 53 Resolver 解析。 | 網路管理員 | 

### 在混合環境中驗證end-to-end解析
<a name="verify-end-to-end-dns-resolution-in-a-hybrid-environment"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 測試從 AWS 到內部部署環境的 DNS 解析。 | 從 VPC 中具有與其相關聯之轉送規則的執行個體，執行內部部署託管網域的 DNS 查詢 （例如，針對 `db.onprem.example.com`)。 | 網路管理員 | 
| 從現場部署環境測試 DNS 解析 AWS。 | 從內部部署伺服器，執行託管網域 AWS的 DNS 解析 （例如，針對 `ec2.prod.aws.example.com`)。 | 網路管理員 | 

## 相關資源
<a name="set-up-dns-resolution-for-hybrid-networks-in-a-multi-account-aws-environment-resources"></a>
+ [Amazon VPC 的混合雲端 DNS 選項](https://docs.aws.amazon.com/whitepapers/latest/hybrid-cloud-dns-options-for-vpc/hybrid-cloud-dns-options-for-vpc.html) (AWS 白皮書）
+ [使用私有託管區域](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-private.html) (Route 53 文件）
+ [Route 53 Resolver 入門](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-getting-started.html)(Route 53 文件）
+ [使用 Route 53 Resolver（部落格文章） 簡化多帳戶環境中的 DNS 管理](https://aws.amazon.com/blogs/security/simplify-dns-management-in-a-multiaccount-environment-with-route-53-resolver/)AWS 
+ [使用具有多個 VPCs和 （部落格文章） 的 Amazon Route 53 設定檔統一 DNS 管理 AWS 帳戶](https://aws.amazon.com/blogs/aws/unify-dns-management-using-amazon-route-53-profiles-with-multiple-vpcs-and-aws-accounts/)AWS 
+ [將多帳戶 DNS 環境遷移至 Amazon Route 53 Profiles](https://aws.amazon.com/blogs/networking-and-content-delivery/migrating-your-multi-account-dns-environment-to-amazon-route-53-profiles/) (AWS 部落格文章）
+ [將 Amazon Route 53 Profiles 用於可擴展的多帳戶 AWS 環境](https://aws.amazon.com/blogs/networking-and-content-delivery/using-amazon-route-53-profiles-for-scalable-multi-account-aws-environments/) (AWS 部落格文章）

 

# 確認 ELB 負載平衡器需要終止 TLS
<a name="verify-that-elb-load-balancers-require-tls-termination"></a>

*Priyanka Chaudhary，Amazon Web Services*

## 總結
<a name="verify-that-elb-load-balancers-require-tls-termination-summary"></a>

在 Amazon Web Services (AWS) 雲端上，Elastic Load Balancing (ELB) 會自動將傳入的應用程式流量分散到多個目標，例如 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體、容器、IP 地址和 AWS Lambda 函數。負載平衡器使用接聽程式來定義負載平衡器用來接受來自使用者的流量的連接埠和通訊協定。Application Load Balancer 在應用程式層進行路由決策，並使用 HTTP/HTTPS 通訊協定。Classic Load Balancer 會在傳輸層、使用 TCP 或 Secure Sockets Layer (SSL) 通訊協定，或使用 HTTP/HTTPS 在應用程式層進行路由決策。

此模式提供安全性控制，可檢查 Application Load Balancer 和 Classic Load Balancer 的多種事件類型。叫用函數時，AWS Lambda 會檢查事件，並確保負載平衡器合規。

函數會在下列 API 呼叫上啟動 Amazon CloudWatch Events 事件：[CreateLoadBalancer](https://docs.aws.amazon.com/elasticloadbalancing/2012-06-01/APIReference/API_CreateLoadBalancer.html)、[CreateLoadBalancerListeners](https://docs.aws.amazon.com/elasticloadbalancing/2012-06-01/APIReference/API_CreateLoadBalancerListeners.html)、[DeleteLoadBalancerListeners](https://docs.aws.amazon.com/elasticloadbalancing/2012-06-01/APIReference/API_DeleteLoadBalancerListeners.html)、[CreateLoadBalancerPolicy](https://docs.aws.amazon.com/elasticloadbalancing/2012-06-01/APIReference/API_CreateLoadBalancerPolicy.html)、[SetLoadBalancerPoliciesOfListener](https://docs.aws.amazon.com/elasticloadbalancing/2012-06-01/APIReference/API_SetLoadBalancerPoliciesOfListener.html)、[CreateListener](https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_CreateListener.html)、[DeleteListener](https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_DeleteListener.html) 和 [ModifyListener](https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_ModifyListener.html)。當事件偵測到其中一個 APIs時，它會呼叫執行 Python 指令碼的 AWS Lambda。Python 指令碼會評估 以查看接聽程式是否包含 SSL 憑證，以及套用的政策是否使用 Transport Layer Security (TLS)。如果 SSL 政策確定為 TLS 以外的任何項目，則函數會傳送 Amazon Simple Notification Service (Amazon SNS) 通知給使用者，其中包含相關資訊。 

## 先決條件和限制
<a name="verify-that-elb-load-balancers-require-tls-termination-prereqs"></a>

**先決條件**
+ 作用中的 AWS 帳戶

**限制**
+ 除非更新負載平衡器接聽程式，否則此安全控制不會檢查現有的負載平衡器。
+ 此安全控制是區域性的。您必須將其部署到您要監控的每個 AWS 區域。

## Architecture
<a name="verify-that-elb-load-balancers-require-tls-termination-architecture"></a>

**目標架構**

![\[確保負載平衡器需要終止 TLS。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/da99cda2-ac34-4791-a2bd-d37264d8d3d9/images/af92b3c8-32bb-45eb-a2a8-d8276fb3e824.png)


**自動化和擴展**
+ 如果您使用的是 [AWS Organizations](https://aws.amazon.com/organizations/)，則可以使用 [AWS Cloudformation StackSets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/what-is-cfnstacksets.html)，將此範本部署到您要監控的多個帳戶中。

## 工具
<a name="verify-that-elb-load-balancers-require-tls-termination-tools"></a>

**AWS 服務**
+ [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) – AWS CloudFormation 可協助您建立模型和設定 AWS 資源、快速一致地佈建資源，以及在整個生命週期中管理資源。您可以使用範本來描述資源及其相依性，並將它們一起啟動和設定為堆疊，而不是個別管理資源。
+ [Amazon CloudWatch Events](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/WhatIsCloudWatchEvents.html) – Amazon CloudWatch Events 提供近乎即時的系統事件串流，說明 AWS 資源的變更。
+ [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) – AWS Lambda 是一種運算服務，支援執行程式碼，無需佈建或管理伺服器。
+ [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/dev/Welcome.html) – Amazon Simple Storage Service (Amazon S3) 是一種高度可擴展的物件儲存服務，可用於各種儲存解決方案，包括網站、行動應用程式、備份和資料湖。
+ [Amazon SNS](https://docs.aws.amazon.com/sns/latest/dg/welcome.html) – Amazon Simple Notification Service (Amazon SNS) 會協調和管理發佈者和用戶端之間的訊息傳遞或傳送，包括 Web 伺服器和電子郵件地址。訂閱者會收到發佈到所訂閱主題的所有訊息，且某一主題的所有訂閱者均會收到相同訊息。

**Code**

此模式包含下列附件：
+ `ELBRequirestlstermination.zip` – 用於安全控制的 Lambda 程式碼。
+ `ELBRequirestlstermination.yml` – 設定事件和 Lambda 函數的 CloudFormation 範本。

## 史詩
<a name="verify-that-elb-load-balancers-require-tls-termination-epics"></a>

### 設定 S3 儲存貯體
<a name="set-up-the-s3-bucket"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 定義 S3 儲存貯體。 | 在 [Amazon S3 主控台](https://console.aws.amazon.com/s3/)上，選擇或建立 S3 儲存貯體以託管 Lambda 程式碼 .zip 檔案。此 S3 儲存貯體必須與您要評估的負載平衡器位於相同的 AWS 區域。S3 儲存貯體名稱全域唯一，且命名空間由所有 AWS 帳戶共用。S3 儲存貯體名稱不能包含正斜線。 | 雲端架構師 | 
| 上傳 Lambda 程式碼。 | 將*附件*區段中提供的 Lambda 程式碼 (`ELBRequirestlstermination.zip` 檔案） 上傳至 S3 儲存貯體。 | 雲端架構師 | 

### 部署 CloudFormation 範本
<a name="deploy-the-cloudformation-template"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 啟動 AWS CloudFormation 範本。 | 在與 S3 儲存貯體相同的 AWS 區域中開啟 [AWS CloudFormation 主控台](https://console.aws.amazon.com/cloudformation/)，並部署連接的範本 `ELBRequirestlstermination.yml`。如需部署 AWS CloudFormation 範本的詳細資訊，請參閱 CloudFormation 文件中的[在 AWS CloudFormation 主控台上建立堆疊](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-create-stack.html)。 CloudFormation  | 雲端架構師 | 
| 完成範本中的參數。 | 當您啟動範本時，系統會提示您輸入下列資訊：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/verify-that-elb-load-balancers-require-tls-termination.html) | 雲端架構師 | 

### 確認訂閱
<a name="confirm-the-subscription"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 確認訂閱。 | 當 CloudFormation 範本成功部署時，它會傳送訂閱電子郵件到您提供的電子郵件地址。您必須確認此電子郵件訂閱，才能開始接收違規通知。 | 雲端架構師 | 

## 相關資源
<a name="verify-that-elb-load-balancers-require-tls-termination-resources"></a>
+ [在 AWS CloudFormation 主控台上建立堆疊](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-create-stack.html) (AWS CloudFormation 文件）
+ [什麼是 AWS Lambda？](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) (AWS Lambda 文件）
+ [什麼是 Classic Load Balancer？](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/introduction.html) (ELB 文件）
+ [什麼是 Application Load Balancer？](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html) (ELB 文件）

## 附件
<a name="attachments-da99cda2-ac34-4791-a2bd-d37264d8d3d9"></a>

若要存取與本文件相關聯的其他內容，請解壓縮下列檔案： [attachment.zip](samples/p-attach/da99cda2-ac34-4791-a2bd-d37264d8d3d9/attachments/attachment.zip)

# 使用 Splunk 檢視 AWS Network Firewall 日誌和指標
<a name="view-aws-network-firewall-logs-and-metrics-by-using-splunk"></a>

*Ivo Pinto，Amazon Web Services*

## 摘要
<a name="view-aws-network-firewall-logs-and-metrics-by-using-splunk-summary"></a>

許多組織使用 [Splunk Enterprise](https://www.splunk.com/en_us/products/splunk-enterprise.html) 做為來自不同來源的日誌和指標的集中彙整和視覺化工具。 此模式可協助您設定 Splunk 使用 Splunk Add-On for [AWS 從 Amazon CloudWatch Logs 擷取 AWS Network Firewall](https://docs.aws.amazon.com/network-firewall/latest/developerguide/what-is-aws-network-firewall.html) 日誌和指標。 [Amazon CloudWatch ](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html)  

若要達成此目的，您可以建立唯讀 AWS Identity and Access Management (IAM) 角色。Splunk Add-On for AWS 使用此角色存取 CloudWatch。您可以設定 Splunk Add-On for AWS 以從 CloudWatch 擷取指標和日誌。最後，您可以從擷取的日誌資料和指標，在 Splunk 中建立視覺化效果。

## 先決條件和限制
<a name="view-aws-network-firewall-logs-and-metrics-by-using-splunk-prereqs"></a>

**先決條件**
+ [Splunk](https://www.splunk.com/) 帳戶
+ Splunk Enterprise 執行個體，8.2.2 版或更新版本 
+ 作用中的 AWS 帳戶
+ Network Firewall，[設定](https://docs.aws.amazon.com/network-firewall/latest/developerguide/getting-started.html)並[設定](https://docs.aws.amazon.com/network-firewall/latest/developerguide/logging-cw-logs.html) 將日誌傳送至 CloudWatch Logs

**限制**
+ Splunk Enterprise 必須部署為 AWS 雲端中的 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體叢集。
+ AWS 中國區域不支援使用自動探索的 Amazon EC2 IAM 角色收集資料。

## Architecture
<a name="view-aws-network-firewall-logs-and-metrics-by-using-splunk-architecture"></a>

![\[AWS Network Firewall 和 Splunk 記錄架構\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/c6ce254a-841f-4bed-8f9f-b35e99f22e56/images/3dd420e9-70af-4a42-b24d-c54872c55e0b.png)


此圖展示了以下要點：

1. Network Firewall 會將日誌發佈至 CloudWatch Logs。

1. Splunk Enterprise 從 CloudWatch 擷取指標和日誌。

若要在此架構中填入範例指標和日誌，工作負載會產生通過 Network Firewall 端點的流量，以前往網際網路。這是透過使用[路由表](https://docs.aws.amazon.com/network-firewall/latest/developerguide/vpc-config.html#vpc-config-route-tables)來實現的。 雖然此模式使用單一 Amazon EC2 執行個體做為工作負載，但只要 Network Firewall 設定為將日誌傳送至 CloudWatch Logs，此模式就可以套用至任何架構。

此架構也會在另一個虛擬私有雲端 (VPC) 中使用 Splunk Enterprise 執行個體。不過，Splunk 執行個體可以位於另一個位置，例如與工作負載相同的 VPC，只要它可以到達 CloudWatch APIs。

## 工具
<a name="view-aws-network-firewall-logs-and-metrics-by-using-splunk-tools"></a>

**AWS 服務**
+ [Amazon CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html) 可協助您集中所有系統、應用程式和 AWS 服務的日誌，以便您可以監控日誌並將其安全地存檔。
+ [Amazon Elastic Compute Cloud (Amazon EC2)](https://docs.aws.amazon.com/ec2/) 在 AWS 雲端中提供可擴展的運算容量。您可以視需要啟動任意數量的虛擬伺服器，，並快速進行擴展或縮減。
+ [AWS Network Firewall](https://docs.aws.amazon.com/network-firewall/latest/developerguide/what-is-aws-network-firewall.html) 是 AWS 雲端中 VPCs 具狀態、受管的網路防火牆和入侵偵測和預防服務。

**其他工具**
+ [Splunk](https://www.splunk.com/) 可協助您監控、視覺化和分析日誌資料。

## 史詩
<a name="view-aws-network-firewall-logs-and-metrics-by-using-splunk-epics"></a>

### 建立 IAM 角色
<a name="create-an-iam-role"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立 IAM 政策。 | 遵循[使用 JSON 編輯器建立政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html#access_policies_create-json-editor)中的指示，建立授予 CloudWatch Logs 資料和 CloudWatch 指標唯讀存取權的 IAM 政策。將以下 政策貼到 JSON 編輯器。<pre>{<br />    "Statement": [<br />        {<br />            "Action": [<br />                "cloudwatch:List*",<br />                "cloudwatch:Get*",<br />                "network-firewall:List*",<br />                "logs:Describe*",<br />                "logs:Get*",<br />                "logs:List*",<br />                "logs:StartQuery",<br />                "logs:StopQuery",<br />                "logs:TestMetricFilter",<br />                "logs:FilterLogEvents",<br />                "network-firewall:Describe*"<br />            ],<br />            "Effect": "Allow",<br />            "Resource": "*"<br />        }<br />    ],<br />    "Version": "2012-10-17"<br />}</pre> | AWS 管理員 | 
| 建立新的 IAM 角色。 | 遵循[建立角色以委派許可給 AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html)中的指示，以建立 Splunk Add-On for AWS 用來存取 CloudWatch 的 IAM 角色。針對**許可政策**，選擇您先前建立的政策。 | AWS 管理員 | 
| 將 IAM 角色指派給 Splunk 叢集中的 EC2 執行個體。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/view-aws-network-firewall-logs-and-metrics-by-using-splunk.html) | AWS 管理員 | 

### 安裝適用於 AWS 的 Splunk 附加元件
<a name="install-the-splunk-add-on-for-aws"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 安裝 附加元件。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/view-aws-network-firewall-logs-and-metrics-by-using-splunk.html) | Splunk 管理員 | 
| 設定 AWS 登入資料。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/view-aws-network-firewall-logs-and-metrics-by-using-splunk.html)如需詳細資訊，請參閱 Splunk 文件中的[在 Splunk 平台執行個體中尋找 IAM 角色](https://splunk.github.io/splunk-add-on-for-amazon-web-services/#Find_an_IAM_role_within_your_Splunk_platform_instance)。 | Splunk 管理員 | 

### 設定 Splunk 對 CloudWatch 的存取
<a name="configure-splunk-access-to-cloudwatch"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 設定從 CloudWatch Logs 擷取 Network Firewall 日誌。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/view-aws-network-firewall-logs-and-metrics-by-using-splunk.html)根據預設，Splunk 每 10 分鐘擷取一次日誌資料。這是**進階設定**下的可設定參數。如需詳細資訊，請參閱 Splunk 文件中的[使用 Splunk Web 設定 CloudWatch Logs 輸入](https://splunk.github.io/splunk-add-on-for-amazon-web-services/#Configure_a_CloudWatch_Logs_input_using_Splunk_Web)。 | Splunk 管理員 | 
| 設定從 CloudWatch 擷取 Network Firewall 指標。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/view-aws-network-firewall-logs-and-metrics-by-using-splunk.html)根據預設，Splunk 每 5 分鐘擷取一次指標資料。這是**進階設定**下的可設定參數。如需詳細資訊，請參閱 Splunk 文件中的[使用 Splunk Web 設定 CloudWatch 輸入](https://splunk.github.io/splunk-add-on-for-amazon-web-services/#Configure_a_CloudWatch_input_using_Splunk_Web)。 | Splunk 管理員 | 

### 使用查詢建立 Splunk 視覺化
<a name="create-splunk-visualizations-by-using-queries"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 檢視最高來源 IP 地址。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/view-aws-network-firewall-logs-and-metrics-by-using-splunk.html) | Splunk 管理員 | 
| 檢視封包統計資料。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/view-aws-network-firewall-logs-and-metrics-by-using-splunk.html) | Splunk 管理員 | 
| 檢視最常用的來源連接埠。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/view-aws-network-firewall-logs-and-metrics-by-using-splunk.html) | Splunk 管理員 | 

## 相關資源
<a name="view-aws-network-firewall-logs-and-metrics-by-using-splunk-resources"></a>

**AWS 文件**
+ [建立角色以委派許可給 AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html) (IAM 文件）
+ [建立 IAM 政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html#access_policies_create-start) (IAM 文件）
+ 在 [AWS Network Firewall 中記錄和監控](https://docs.aws.amazon.com/network-firewall/latest/developerguide/logging-monitoring.html) (Network Firewall 文件）
+ [AWS Network Firewall 的路由表組態](https://docs.aws.amazon.com/network-firewall/latest/developerguide/route-tables.html) (Network Firewall 文件）

**AWS 部落格文章**
+ [AWS Network Firewall 部署模型](https://aws.amazon.com/pt/blogs/networking-and-content-delivery/deployment-models-for-aws-network-firewall/)

**AWS Marketplace**
+ [Splunk Enterprise Amazon Machine Image (AMI)](https://aws.amazon.com/marketplace/pp/prodview-l6oos72bsyaks)

# 更多模式
<a name="networking-more-patterns-pattern-list"></a>

**Topics**
+ [使用 Session Manager 和 Amazon EC2 Instance Connect 存取堡壘主機](access-a-bastion-host-by-using-session-manager-and-amazon-ec2-instance-connect.md)
+ [使用 AWS Fargate、AWS PrivateLink 和 Network Load Balancer，在 Amazon ECS 上私下存取容器應用程式](access-container-applications-privately-on-amazon-ecs-by-using-aws-fargate-aws-privatelink-and-a-network-load-balancer.md)
+ [使用 AWS PrivateLink 和 Network Load Balancer 在 Amazon ECS 上私下存取容器應用程式](access-container-applications-privately-on-amazon-ecs-by-using-aws-privatelink-and-a-network-load-balancer.md)
+ [使用 AWS Managed Microsoft AD 和內部部署 Microsoft Active Directory 集中 DNS 解析](centralize-dns-resolution-by-using-aws-managed-microsoft-ad-and-on-premises-microsoft-active-directory.md)
+ [使用、 AWS Amplify Angular 和 Module Federation 建立微型前端的入口網站](create-amplify-micro-frontend-portal.md)
+ [使用私有端點和 Application Load Balancer 在內部網站上部署 Amazon API Gateway API](deploy-an-amazon-api-gateway-api-on-an-internal-website-using-private-endpoints-and-an-application-load-balancer.md)
+ [使用 部署公有子網路的偵測屬性型存取控制 AWS Config](deploy-detective-attribute-based-access-controls-for-public-subnets-by-using-aws-config.md)
+ [部署公有子網路的預防性屬性型存取控制](deploy-preventative-attribute-based-access-controls-for-public-subnets.md)
+ [在 Amazon RDS 中啟用 PostgreSQL 資料庫執行個體的加密連線](enable-encrypted-connections-for-postgresql-db-instances-in-amazon-rds.md)
+ [使用 AWS Transit Gateway Connect 將 VRFs 擴展至 AWS AWS Transit Gateway](extend-vrfs-to-aws-by-using-aws-transit-gateway-connect.md)
+ [在 上將 F5 BIG-IP 工作負載遷移至 F5 BIG-IP VE AWS 雲端](migrate-an-f5-big-ip-workload-to-f5-big-ip-ve-on-the-aws-cloud.md)
+ [啟用 Amazon EKS Auto 模式時遷移 NGINX 傳入控制器](migrate-nginx-ingress-controller-eks-auto-mode.md)
+ [在非工作負載子網路的多帳戶 VPC 設計中保留可路由 IP 空間](preserve-routable-ip-space-in-multi-account-vpc-designs-for-non-workload-subnets.md)
+ [使用服務控制政策，防止帳戶層級的網際網路存取](prevent-internet-access-at-the-account-level-by-using-a-service-control-policy.md)
+ [從 AWS Network Firewall 傳送提醒到 Slack 頻道](send-alerts-from-aws-network-firewall-to-a-slack-channel.md)
+ [使用 Amazon CloudFront 在 Amazon S3 儲存貯體中透過 VPC 提供靜態內容](serve-static-content-in-an-amazon-s3-bucket-through-a-vpc-by-using-amazon-cloudfront.md)
+ [使用 AWS Elastic Disaster Recovery 為 Oracle JD Edwards EnterpriseOne 設定災難復原](set-up-disaster-recovery-for-oracle-jd-edwards-enterpriseone-with-aws-elastic-disaster-recovery.md)
+ [使用 BMC Discovery 查詢來擷取遷移資料以進行遷移規劃](use-bmc-discovery-queries-to-extract-migration-data-for-migration-planning.md)
+ [使用 Network Firewall 從傳出流量的伺服器名稱指示擷取 DNS 網域名稱](use-network-firewall-to-capture-the-dns-domain-names-from-the-server-name-indication-sni-for-outbound-traffic.md)