

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

# 產生 EC2 政策的帳戶狀態報告
<a name="orgs_manage_policies_ec2_status-report"></a>

*帳戶狀態報告*可讓您檢閱範圍內帳戶 EC2 政策支援的所有屬性的目前狀態。您可以選擇要包含在報告範圍中的帳戶和組織單位 (OUs)，或選取根來選擇整個組織。

此報告透過提供區域明細，以及屬性的目前狀態*跨帳戶 （透過 ) 是否一致*或*不一致* （透過 )，來協助您評估整備程度`numberOfUnmatchedAccounts`。 `numberOfMatchedAccounts`您也可以查看*最常見的值*，這是 屬性最常觀察到的組態值。

是否連接 EC2 政策以強制執行基準組態取決於您的特定使用案例。

如需詳細資訊和說明範例，請參閱 [EC2 政策的帳戶狀態報告](orgs_manage_policies_ec2.md#orgs_manage_policies_ec2-account-status-report)。

## 先決條件
<a name="orgs_manage_policies_ec2_accessing-status-report-prerequisites"></a>

在產生帳戶狀態報告之前，請先完成下列步驟：

1. 只有管理帳戶或組織的委派管理員才能呼叫`StartDeclarativePoliciesReport`此操作。

1. 若要從委派管理員帳戶執行報告，該帳戶必須註冊為 EC2 服務的委派管理員。

1. 您必須先擁有 S3 儲存貯體，才能產生報告。建立新的儲存貯體或使用現有的儲存貯體。儲存貯體必須位於您提出請求的相同區域。儲存貯體必須具有適當的儲存貯體政策。如需範例 S3 政策，請參閱*《Amazon EC2 API 參考》中範例下的範例 Amazon S3 政策* [https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_StartDeclarativePoliciesReport.html#API_StartDeclarativePoliciesReport_Examples](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_StartDeclarativePoliciesReport.html#API_StartDeclarativePoliciesReport_Examples) *Amazon EC2 * 

1. 您必須啟用 Amazon EC2 的受信任存取。這會建立唯讀服務連結角色，為整個組織的帳戶產生現有組態的帳戶狀態報告。

   **使用主控台**

   針對 Organizations 主控台，此步驟是啟用 EC2 政策程序的一部分。

   **使用 AWS CLI**

   對於 AWS CLI，請使用 [EnableAWSServiceAccess](https://docs.aws.amazon.com/organizations/latest/APIReference/API_EnableAWSServiceAccess.html) 操作。

   如需如何使用 為特定服務啟用受信任存取的詳細資訊 AWS CLI，請參閱 [AWS 服務 以搭配 使用 AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_integrate_services_list.html)。

1. 每個組織一次只能產生一個報告。如果您在另一個報告進行時產生報告，操作會傳回錯誤。

## 產生合規狀態報告
<a name="orgs_manage_policies_ec2_accessing-status-report"></a>

**最低許可**  
若要產生合規狀態報告，您需要執行下列操作的許可：  
`ec2:StartDeclarativePoliciesReport`
`ec2:DescribeDeclarativePoliciesReports`
`ec2:GetDeclarativePoliciesReportSummary`
`ec2:CancelDeclarativePoliciesReport`
`organizations:DescribeAccount`
`organizations:DescribeOrganization`
`organizations:DescribeOrganizationalUnit`
`organizations:ListAccounts`
`organizations:ListDelegatedAdministrators`
`organizations:ListAWSServiceAccessForOrganization`
`s3:PutObject`

**注意**  
如果您的 Amazon S3 儲存貯體使用 SSE-KMS 加密，您還必須在政策中包含 `kms:GenerateDataKey`許可。

------
#### [ AWS 管理主控台 ]

使用下列程序來產生帳戶狀態報告。

**產生帳戶狀態報告**

1. 登入 [AWS Organizations 主控台](https://console.aws.amazon.com/organizations/v2)。您必須以 IAM 使用者登入、擔任 IAM 角色，或是以組織管理帳戶中的根使用者 ([不建議](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#lock-away-credentials)) 身分登入。

1. 在**政策**頁面上，選擇 **EC2 政策**。

1. 在 **EC2 政策**頁面上，從**動作**下拉式功能表中選擇**檢視帳戶狀態報告**。

1. 在**檢視帳戶狀態報告**頁面上，選擇**產生狀態報告**。

1. 在**組織結構**小工具中，指定您要包含在報告中的組織單位 OUs)。

1. 選擇**提交**。

------
#### [ AWS CLI & AWS SDKs ]

**產生帳戶狀態報告**

使用下列操作來產生合規狀態報告、檢查其狀態，以及檢視報告：
+ `ec2:start-declarative-policies-report`：產生帳戶狀態報告。報告會以非同步方式產生，可能需要數小時才能完成。如需詳細資訊，請參閱《*Amazon EC2 API 參考*》中的 [StartDeclarativePoliciesReport](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_StartDeclarativePoliciesReport.html)。
+ `ec2:describe-declarative-policies-report`：描述帳戶狀態報告的中繼資料，包括報告的狀態。如需詳細資訊，請參閱《*Amazon EC2 API 參考*》中的 [DescribeDeclarativePoliciesReports](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeDeclarativePoliciesReports.html)。
+ `ec2:get-declarative-policies-report-summary`：擷取帳戶狀態報告的摘要。如需詳細資訊，請參閱《*Amazon EC2 API 參考*》中的 [GetDeclarativePoliciesReportSummary](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_GetDeclarativePoliciesReportSummary.html)。
+ `ec2:cancel-declarative-policies-report`：取消產生帳戶狀態報告。如需詳細資訊，請參閱《*Amazon EC2 API 參考*》中的 [CancelDeclarativePoliciesReport](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CancelDeclarativePoliciesReport.html)。

產生報告之前，請將儲存報告之 Amazon S3 儲存貯體的存取權授予 EC2 政策委託人。若要執行此作業，請將下列政策連接至 儲存貯體。將 取代`amzn-s3-demo-bucket`為您實際的 Amazon S3 儲存貯體名稱，並將 `identity_ARN`取代為用於呼叫 `StartDeclarativePoliciesReport`操作的 IAM 身分。

下列 JSON 政策會授予將報告交付至儲存貯體的存取權：

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "DeclarativePoliciesReportDelivery",
            "Effect": "Allow",
            "Principal": {
                "AWS": "{{identity_ARN}}"
            },
            "Action": [
                "s3:PutObject"
            ],
            "Resource": "arn:aws:s3:::{{amzn-s3-demo-bucket}}/*",
            "Condition": {
                "StringEquals": {
                    "aws:CalledViaLast": "organizations.amazonaws.com"
                }
            }
        }
    ]
}
```

------

------