

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

# 從 AWS Organizations 中的整個組織將 AWS Backup 報告匯出為 CSV 檔案 AWS Organizations
<a name="export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file"></a>

*Aromal Raj Jayarajan 和 Purushotham G K，Amazon Web Services*

## 總結
<a name="export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file-summary"></a>

此模式說明如何將 AWS Backup 任務報告從 AWS Organizations 中的組織匯出為 CSV 檔案。解決方案使用 AWS Lambda 和 Amazon EventBridge，根據其狀態來分類 AWS Backup 任務報告，這有助於設定以狀態為基礎的自動化。

AWS Backup 可協助組織集中管理和自動化跨 AWS 服務、雲端和內部部署的資料保護。不過，對於在 AWS Organizations 中設定的 AWS Backup 任務，合併報告只能在每個組織的管理帳戶的 AWS 管理主控台中使用。 AWS Organizations 將此報告帶出管理帳戶，可以減少稽核所需的工作量，並提高自動化、通知和提醒的範圍。

## 先決條件和限制
<a name="export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file-prereqs"></a>

**先決條件 **
+ 作用中的 AWS 帳戶
+ AWS Organizations 中的作用中[組織](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_tutorials_basic.html)，至少包含管理帳戶和成員帳戶
+ 在 AWS Organizations 中的組織層級AWS Organizations Backup （如需詳細資訊，請參閱 [AWS 部落格上的使用 AWS Backup 跨 AWS 服務大規模自動化集中](https://aws.amazon.com/blogs/storage/automate-centralized-backup-at-scale-across-aws-services-using-aws-backup/)備份）
+ 在本機電腦上安裝和設定的 [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

**限制 **

此模式中提供的解決方案可識別僅針對 AWS Backup 任務設定的 AWS 資源。報告無法識別未設定為透過 AWS Backup 備份的 AWS Backup 資源。

## Architecture
<a name="export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file-architecture"></a>

**目標技術堆疊**
+ AWS Backup
+ AWS CloudFormation
+ Amazon EventBridge
+ AWS Lambda
+ AWS Security Token Service (AWS STS)
+ Amazon Simple Storage Service (Amazon S3)
+ AWS Identity and Access Management (IAM)

**目標架構**

下圖顯示將 AWS Backup 任務報告從 AWS Organizations 中的組織匯出為 CSV 檔案的範例工作流程。

![\[使用 EventBridge、Lambda、AWS STS 和 IAM 以 CSV 格式從整個組織匯出 AWS Backup 任務報告。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/74955aad-cc6d-488b-aa34-ae43f50fec60/images/5c39c79f-e731-4ad0-b404-51ebe0976420.png)


該圖顯示以下工作流程：

1. 排程的 EventBridge 事件規則會在成員 （報告） AWS 帳戶中叫用 Lambda 函數。

1. 然後，Lambda 函數會使用 AWS STS 擔任 IAM 角色，該角色具有連線到管理帳戶所需的許可。

1. Lambda 函數接著會執行下列動作：
   + 從 AWS Backup 服務請求合併的 AWS Backup 任務報告
   + 根據 AWS Backup 任務狀態將結果分類
   + 將回應轉換為 CSV 檔案
   + 在根據建立日期標記的資料夾中，將結果上傳至報告帳戶中的 Amazon S3 儲存貯體

## 工具
<a name="export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file-tools"></a>

**工具**
+ [AWS Backup](https://docs.aws.amazon.com/aws-backup/latest/devguide/whatisbackup.html) 是一項全受管服務，可協助您集中和自動化跨 AWS 服務、雲端和內部部署的資料保護。
+ [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) 可協助您設定 AWS 資源、快速且一致地佈建資源，以及在整個 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 Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) 是一種運算服務，可協助您執行程式碼，而不需要佈建或管理伺服器。它只會在需要時執行程式碼並自動擴展，因此您只需支付使用的運算時間。
+ [Amazon Simple Storage Service (Amazon S3)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) 是一種雲端型物件儲存服務，可協助您儲存、保護和擷取任何數量的資料。

**程式碼 **

此模式的程式碼可在 GitHub [aws-backup-report-generator](https://github.com/aws-samples/aws-backup-report-generator) 儲存庫中使用。

## 最佳實務
<a name="export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file-best-practices"></a>
+ [Amazon S3 的安全最佳實務 ](https://docs.aws.amazon.com/AmazonS3/latest/userguide/security-best-practices.html)(*Amazon S3 使用者指南*)
+ [使用 AWS Lambda 函數的最佳實務 ](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html)(*AWS Lambda 開發人員指南*)
+ [管理帳戶的最佳實務 ](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_best-practices_mgmt-acct.html)(*AWS Organizations 使用者指南*)

## 史詩
<a name="export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file-epics"></a>

### 部署解決方案元件
<a name="deploy-the-solution-components"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 複製 GitHub 儲存庫。 | 在終端機視窗中執行下列命令，複製 GitHub [aws-backup-report-generator](https://github.com/aws-samples/aws-backup-report-generator) 儲存庫：<pre>git clone https://github.com/aws-samples/aws-backup-report-generator.git</pre>如需詳細資訊，請參閱 GitHub 文件中的[複製儲存庫](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)。 | AWS DevOps，DevOps 工程師 | 
| 在成員 （報告） AWS 帳戶中部署解決方案元件。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file.html) | DevOps 工程師，AWS DevOps | 

### 測試解決方案
<a name="test-the-solution"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 確定 EventBridge 規則在測試之前執行。 | 透過等待至少 24 小時，或增加 CloudFormation 範本的 **template-reporting.yml** 檔案中的報告頻率，確保 EventBridge 規則執行。**增加報告頻率**[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file.html) | AWS DevOps，DevOps 工程師 | 
| 檢查 Amazon S3 儲存貯體是否有產生的報告。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file.html) | AWS DevOps，DevOps 工程師 | 

### 清除您的資源
<a name="clean-up-your-resources"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 從成員 （報告） 帳戶刪除解決方案元件。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file.html) | AWS DevOps，DevOps 工程師 | 
| 從管理帳戶刪除解決方案元件。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file.html) | AWS DevOps，DevOps 工程師 | 

## 相關資源
<a name="export-aws-backup-reports-from-across-an-organization-in-aws-organizations-as-a-csv-file-resources"></a>
+ [教學課程：搭配排程事件使用 AWS Lambda ](https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents-tutorial.html)(AWS Lambda 文件）
+ [建立排程事件以執行 AWS Lambda 函數](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/scheduled-events-invoking-lambda-example.html) （適用於 JavaScript 的 AWS 開發套件文件）
+ [IAM 教學課程：使用 IAM 角色在 AWS 帳戶之間委派存取權 ](https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_cross-account-with-roles.html)(IAM 文件）
+ [AWS Organizations 術語和概念](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html) (AWS Organizations 文件）
+ [使用 AWS Backup 主控台建立報告計畫](https://docs.aws.amazon.com/aws-backup/latest/devguide/create-report-plan-console.html) (AWS Backup 文件）
+ [建立稽核報告](https://docs.aws.amazon.com/aws-backup/latest/devguide/create-audit-report.html) (AWS Backup 文件）
+ [建立隨需報告 ](https://docs.aws.amazon.com/aws-backup/latest/devguide/create-on-demand-reports.html)(AWS Backup 文件）
+ [什麼是 AWS Backup？](https://docs.aws.amazon.com/aws-backup/latest/devguide/whatisbackup.html) (AWS Backup文件）
+ [使用 AWS Backup 跨 AWS 服務大規模自動化集中AWS Backup](https://aws.amazon.com/blogs/storage/automate-centralized-backup-at-scale-across-aws-services-using-aws-backup/)(AWS 部落格文章）