

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

# 共用報告群組
<a name="report-groups-sharing"></a>

報告群組共用可讓多個 AWS 帳戶或使用者檢視報告群組、其未過期的報告，以及其報告的測試結果。在此模型中，擁有報告群組的帳戶 (擁有者) 會與其他帳戶 (消費者) 共用報告群組。消費者無法編輯報告群組。報告會在建立 30 天後過期。

**Topics**
+ [共用報告群組](#report-groups-sharing-share)
+ [相關服務](#report-groups-sharing-related)
+ [存取與您共用的報告群組](report-groups-sharing-access-prereqs.md)
+ [取消共用共用報告群組](report-groups-sharing-unshare.md)
+ [識別共用報告群組](report-groups-sharing-identify.md)
+ [共用報告群組的許可](report-groups-sharing-perms.md)

## 共用報告群組
<a name="report-groups-sharing-share"></a>

 當您共用報告群組時，就會授予消費者報告群組及其報告的唯讀存取權。取用者可以使用 AWS CLI 來檢視報告群組、其報告，以及每個報告的測試案例結果。消費者無法：
+  在 CodeBuild 主控台中檢視共用報告群組或其報告。
+  編輯共用報告群組。
+  使用專案中共用報告群組的 ARN 來執行報告。指定共用報告群組的專案建置會失敗。

您可以使用 CodeBuild 主控台將報告群組新增至現有的資源共享。如果您想要將報告群組新增至新的資源共用，需先在 [AWS RAM 主控台](https://console.aws.amazon.com/ram)中建立它。

若要與組織單位或整個組織共用報告群組，必須啟用透過 AWS Organizations來共用的功能。如需詳細資訊，請參閱《*AWS RAM 使用者指南*》中的[透過 AWS Organizations啟用共用](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html)。

您可以使用 CodeBuild AWS RAM 主控台、主控台或 AWS CLI 來共用您擁有的報告群組。

**先決條件**  
若要共用報告群組， AWS 您的帳戶必須擁有該群組。您無法將已共用給您的報告群組再共用出去。

**共用您擁有的報告群組 (CodeBuild 主控台）**

1. 在 https：//[https://console.aws.amazon.com/codesuite/codebuild/home](https://console.aws.amazon.com/codesuite/codebuild/home) 開啟 AWS CodeBuild 主控台。

1. 在導覽窗格中，選擇 **Report groups (報告群組)**。

1.  選擇您要共用的專案，然後選擇 **Share (共用)**。如需詳細資訊，請參閱*《AWS RAM 使用者指南》*中的[建立資源共用](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-create)。

**共用您擁有的報告群組AWS RAM （主控台）**  
請參閱 *AWS RAM 使用者指南*中的[建立資源共用](https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing.html#working-with-sharing-create)。

**共用您擁有的報告群組 (AWS RAM 命令）**  
使用 [create-resource-share](https://docs.aws.amazon.com/cli/latest/reference/ram/create-resource-share.html) 命令。

 **共用您擁有的報告群組 (CodeBuild 命令）** 

使用 [put-resource-policy](https://docs.aws.amazon.com/cli/latest/reference/codebuild/put-resource-policy.html) 命令：

1. 建立名為 `policy.json` 的檔案，並將以下命令複製到其中。

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

****  

   ```
   {
      "Version":"2012-10-17",		 	 	 
      "Statement":[{
        "Effect":"Allow",
        "Principal":{
          "AWS":"{{111122223333}}"
        },
        "Action":[
          "codebuild:BatchGetReportGroups",
          "codebuild:BatchGetReports",
          "codebuild:ListReportsForReportGroup",
          "codebuild:DescribeTestCases"],
        "Resource":"{{arn:aws:iam::*:role/Service*}}"
      }]
    }
   ```

------

1. 使用報告群組 ARN 和識別符更新 `policy.json`，以與之共用。下列範例使用 Alice 的 ARN 和 123456789012 所識別 AWS 帳戶的根使用者`arn:aws:codebuild:us-west-2:123456789012:report-group/my-report-group`，授予報告群組的唯讀存取權。

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

****  

   ```
   {
      "Version":"2012-10-17",		 	 	 
      "Statement":[{
        "Effect":"Allow",
        "Principal":{
          "AWS": [
             "arn:aws:iam::123456789012:user/Alice",
             "123456789012"
           ]
        },
        "Action":[
          "codebuild:BatchGetReportGroups",
          "codebuild:BatchGetReports",
          "codebuild:ListReportsForReportGroup",
          "codebuild:DescribeTestCases"],
        "Resource":"arn:aws:codebuild:us-west-2:123456789012:report-group/my-report-group"
      }]
    }
   ```

------

1. 執行下列命令。

   ```
   aws codebuild put-resource-policy --resource-arn {{report-group-arn}} --policy file://policy.json
   ```

## 相關服務
<a name="report-groups-sharing-related"></a>

報告群組共用與 AWS Resource Access Manager (AWS RAM) 整合，這項服務可讓您與任何 AWS 帳戶或透過 共用 AWS 資源 AWS Organizations。與 共用您擁有的資源 AWS RAM，方法是建立*資源共用*，指定要共用的資源和取用者。消費者可以是 中的個別 AWS 帳戶 AWS Organizations、組織單位或整個組織 AWS Organizations。

如需詳細資訊，請參閱*「[AWS RAM 使用者指南」](https://docs.aws.amazon.com/ram/latest/userguide/)*。