

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

# Amazon Detective 的身分和存取管理
<a name="security-iam"></a>

AWS Identity and Access Management (IAM) 是一種 AWS 服務 ，可協助管理員安全地控制對 AWS 資源的存取。IAM 管理員可以控制*完成身分驗證* (已登入) 和*獲得授權* (具有許可) 而得以使用 Detective 資源的對象。IAM 是 AWS 服務 您可以免費使用的 。

**Topics**
+ [目標對象](#security_iam_audience)
+ [使用身分來驗證](#security_iam_authentication)
+ [使用政策管理存取權](#security_iam_access-manage)
+ [Amazon Detective 如何搭配 IAM 運作](security_iam_service-with-iam.md)
+ [Amazon Detective 身分型政策範例](security_iam_id-based-policy-examples.md)
+ [AWS Amazon Detective 的 受管政策](security-iam-awsmanpol.md)
+ [使用 Detective 的服務連結角色](using-service-linked-roles.md)
+ [Amazon Detective 身分識別和存取疑難排解](security_iam_troubleshoot.md)

## 目標對象
<a name="security_iam_audience"></a>

使用方式 AWS Identity and Access Management (IAM) 會根據您的角色而有所不同：
+ **服務使用者** — 若無法存取某些功能，請向管理員申請所需許可 (請參閱 [Amazon Detective 身分識別和存取疑難排解](security_iam_troubleshoot.md))
+ **服務管理員** — 負責設定使用者存取權並提交相關許可請求 (請參閱 [Amazon Detective 如何搭配 IAM 運作](security_iam_service-with-iam.md))
+ **IAM 管理員** — 撰寫政策以管理存取控制 (請參閱 [Amazon Detective 身分型政策範例](security_iam_id-based-policy-examples.md))

## 使用身分來驗證
<a name="security_iam_authentication"></a>

身分驗證是您 AWS 使用身分憑證登入 的方式。您必須以 AWS 帳戶根使用者、IAM 使用者或擔任 IAM 角色身分進行身分驗證。

您可以使用身分來源的登入資料，例如 AWS IAM Identity Center (IAM Identity Center)、單一登入身分驗證或 Google/Facebook 登入資料，以聯合身分的形式登入。如需有關登入的詳細資訊，請參閱《AWS 登入 使用者指南》**中的[如何登入您的 AWS 帳戶](https://docs.aws.amazon.com/signin/latest/userguide/how-to-sign-in.html)。

對於程式設計存取， AWS 提供 SDK 和 CLI 以密碼編譯方式簽署請求。如需詳細資訊，請參閱《IAM 使用者指南》**中的 [API 請求的AWS 第 4 版簽署程序](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html)。

### AWS 帳戶 根使用者
<a name="security_iam_authentication-rootuser"></a>

 當您建立 時 AWS 帳戶，您會從一個名為 AWS 帳戶 *theroot 使用者的*登入身分開始，該身分具有對所有 AWS 服務 和 資源的完整存取權。強烈建議不要使用根使用者來執行日常任務。有關需要根使用者憑證的任務，請參閱《IAM 使用者指南》**中的[需要根使用者憑證的任務](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html#root-user-tasks)。

### IAM 使用者和群組
<a name="security_iam_authentication-iamuser"></a>

*IAM 使用者*[https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html)是一種身分具備單人或應用程式的特定許可權。建議以臨時憑證取代具備長期憑證的 IAM 使用者。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[要求人類使用者使用聯合身分提供者來 AWS 使用臨時憑證存取](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#bp-users-federation-idp) 。

[IAM 群組](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html)**會指定 IAM 使用者集合，使管理大量使用者的許可權更加輕鬆。如需詳細資訊，請參閱《IAM 使用者指南》**中的 [IAM 使用者的使用案例](https://docs.aws.amazon.com/IAM/latest/UserGuide/gs-identities-iam-users.html)。

### IAM 角色
<a name="security_iam_authentication-iamrole"></a>

*IAM 角色*[https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)的身分具有特定許可權，其可以提供臨時憑證。您可以透過[從使用者切換到 IAM 角色 （主控台） ](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-console.html)或呼叫 AWS CLI 或 AWS API 操作來擔任角色。如需詳細資訊，請參閱《IAM 使用者指南》**中的[擔任角色的方法](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage-assume.html)。

IAM 角色適用於聯合身分使用者存取、臨時 IAM 使用者許可、跨帳戶存取權與跨服務存取，以及在 Amazon EC2 執行的應用程式。如需詳細資訊，請參閱《*IAM 使用者指南*》中的 [IAM 中的快帳戶資源存取](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html)。

## 使用政策管理存取權
<a name="security_iam_access-manage"></a>

您可以透過建立政策並將其連接到身分或資源 AWS 來控制 AWS 中的存取。政策定義與身分或資源相關聯的許可。當委託人提出請求時 AWS ， 會評估這些政策。大多數政策會以 JSON 文件 AWS 形式存放在 中。如需進一步了解 JSON 政策文件，請參閱《*IAM 使用者指南*》中的 [JSON 政策概觀](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#access_policies-json)。

管理員會使用政策，透過定義哪些**主體**可在哪些**條件**下對哪些**資源**執行**動作**，以指定可存取的範圍。

預設情況下，使用者和角色沒有許可。IAM 管理員會建立 IAM 政策並將其新增至角色，供使用者後續擔任。IAM 政策定義動作的許可，無論採用何種方式執行。

### 身分型政策
<a name="security_iam_access-manage-id-based-policies"></a>

身分型政策是附加至身分 (使用者、使用者群組或角色) 的 JSON 許可政策文件。這類政策控制身分可對哪些資源執行哪些動作，以及適用的條件。如需了解如何建立身分型政策，請參閱《*IAM 使用者指南*》中的[透過客戶管理政策定義自訂 IAM 許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html)。

身分型政策可分為*內嵌政策* (直接內嵌於單一身分) 與*受管政策* (可附加至多個身分的獨立政策)。如需了解如何在受管政策及內嵌政策之間做選擇，請參閱《IAM 使用者指南》**中的[在受管政策與內嵌政策之間選擇](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-choosing-managed-or-inline.html)。

### 資源型政策
<a name="security_iam_access-manage-resource-based-policies"></a>

資源型政策是附加到資源的 JSON 政策文件。範例包括 IAM *角色信任政策*與 Amazon S3 *儲存貯體政策*。在支援資源型政策的服務中，服務管理員可以使用它們來控制對特定資源的存取權限。您必須在資源型政策中[指定主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html)。

資源型政策是位於該服務中的內嵌政策。您無法在以資源為基礎的政策中使用來自 IAM 的 AWS 受管政策。

### 存取控制清單 (ACL)
<a name="security_iam_access-manage-acl"></a>

存取控制清單 (ACL) 可控制哪些主體 (帳戶成員、使用者或角色) 擁有存取某資源的許可。ACL 類似於資源型政策，但它們不使用 JSON 政策文件格式。

Amazon S3 AWS WAF和 Amazon VPC 是支援 ACLs的服務範例。如需進一步了解 ACL，請參閱《Amazon Simple Storage Service 開發人員指南》**中的[存取控制清單 (ACL) 概觀](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html)。

### 其他政策類型
<a name="security_iam_access-manage-other-policies"></a>

AWS 支援其他政策類型，可設定更多常見政策類型授予的最大許可：
+ **許可界限** — 設定身分型政策可授與 IAM 實體的最大許可。如需詳細資訊，請參閱《 IAM 使用者指南》**中的 [IAM 實體許可界限](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html)。
+ **服務控制政策 (SCP)** — 為 AWS Organizations中的組織或組織單位指定最大許可。如需詳細資訊，請參閱《AWS Organizations 使用者指南》**中的[服務控制政策](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html)。
+ **資源控制政策 (RCP)** — 設定您帳戶中資源可用許可的上限。如需詳細資訊，請參閱《AWS Organizations 使用者指南》**中的[資源控制政策 (RCP)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html)。
+ **工作階段政策** — 在以程式設計方式為角色或聯合身分使用者建立臨時工作階段時，以參數形式傳遞的進階政策。如需詳細資訊，請參《*IAM 使用者指南*》中的[工作階段政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_session)。

### 多種政策類型
<a name="security_iam_access-manage-multiple-policies"></a>

當多種類型的政策套用到請求時，產生的許可會更複雜而無法理解。若要了解如何 AWS 在涉及多種政策類型時決定是否允許請求，請參閱《*IAM 使用者指南*》中的[政策評估邏輯](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html)。

# Amazon Detective 如何搭配 IAM 運作
<a name="security_iam_service-with-iam"></a>

根據預設，使用者和角色不具備建立或修改 Amazon Detective 資源的許可。他們也無法使用 AWS 管理主控台 AWS CLI或 AWS API 執行任務。Detective 管理員必須具有 AWS Identity and Access Management (IAM) 政策，授予 IAM 使用者和角色許可，以對他們所需的指定資源執行特定 API 操作。管理員接著必須將這些政策連接至需要此類許可的主體。

Detective 使用 IAM 身分型政策，為以下類型的使用者和動作授予許可：
+ **管理員帳戶**：管理員帳戶是行為圖表的擁有者，可使用其帳戶中的資料。管理員帳戶可以邀請成員帳戶將其資料提供至行為圖表。管理員帳戶也可以使用行為圖表來分類和調查與這些帳戶相關聯的問題清單和資源。

  您可以設定政策以允許管理員帳戶以外的使用者執行不同類型的工作。例如，來自管理員帳戶的使用者可能只有管理成員帳戶的許可。其他使用者可能只有使用行為圖表進行調查的許可。
+ **成員帳戶**：成員帳戶是受邀為行為圖表提供資料的帳戶。成員帳戶會回應邀請。接受邀請後，成員帳戶可以從行為圖表中移除其帳戶。

若要全面了解 Detective 和其他 AWS 服務 如何使用 IAM，請參閱《*IAM 使用者指南*》中的[在 JSON 標籤上建立政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html#access_policies_create-json-editor)。

## Detective 身分型政策
<a name="security_iam_service-with-iam-id-based-policies"></a>

使用 IAM 身分型政策，您可以指定允許或拒絕的動作和資源，以及在何種條件下允許或拒絕動作。Detective 支援特定動作、資源和條件金鑰。

若要了解您在 JSON 政策中使用的所有元素，請參閱 *IAM 使用者指南*中的 [JSON 政策元素參考](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html)。

### 動作
<a name="security_iam_service-with-iam-id-based-policies-actions"></a>

管理員可以使用 AWS JSON 政策來指定誰可以存取內容。也就是說，哪個**主體**在什麼**條件**下可以對什麼**資源**執行哪些**動作**。

JSON 政策的 `Action` 元素描述您可以用來允許或拒絕政策中存取的動作。政策會使用動作來授予執行相關聯動作的許可。

政策陳述式必須包含 `Action` 或 `NotAction` 元素。`Action` 元素會列出政策允許的動作。`NotAction` 元素會列出不允許的動作。

針對 Detective 定義的動作反映了您可以使用 Detective 執行的工作。Detective 中的政策動作具有以下前綴：`detective:`。

例如，若要授予使用 `CreateMembers` API 操作邀請成員帳戶加入行為圖表的許可，您應在其政策中加入 `detective:CreateMembers` 動作。

若要在單一陳述式中指定多個動作，請用逗號分隔。例如，對於成員帳戶，政策包括與管理邀請相關的一組動作：

```
"Action": [
      "detective:ListInvitations",
      "detective:AcceptInvitation",
      "detective:RejectInvitation",
      "detective:DisassociateMembership
]
```

您可以使用萬用字元 (\$1) 來指定多個動作。例如，若要管理其行為圖表中使用的資料，Detective 中的管理員帳戶必須能夠執行以下工作：
+ 檢視他們的成員帳戶清單 (`ListMembers`)。
+ 取得已選取成員帳戶的資訊 (`GetMembers`)。
+ 邀請成員帳戶至其行為圖表 (`CreateMembers`)。
+ 從成員的行為圖表 (`DeleteMembers`) 中移除成員。

您可以向以文字 `Members` 結尾的所有動作授予存取，而無需個別列出此類動作。該政策可能包括以下動作：

```
"Action": "detective:*Members"
```



若要查看 Detective 動作的清單，請參閱《服務授權參考**》中的[由 Amazon Detective 定義的動作](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazondetective.html#amazondetective-actions-as-permissions)。

### Resources
<a name="security_iam_service-with-iam-id-based-policies-resources"></a>

管理員可以使用 AWS JSON 政策來指定誰可以存取內容。也就是說，哪個**主體**在什麼**條件**下可以對什麼**資源**執行哪些**動作**。

`Resource` JSON 政策元素可指定要套用動作的物件。最佳實務是使用其 [Amazon Resource Name (ARN)](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html) 來指定資源。若動作不支援資源層級許可，使用萬用字元 (\$1) 表示該陳述式適用於所有資源。

```
"Resource": "*"
```



如需 ARNs 格式的詳細資訊，請參閱 [Amazon Resource Name (ARNs AWS 和服務命名空間](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)。

針對 Detective，唯一的資源類型是行為圖表。Detective 中的行為圖表資源具有以下 ARN：

```
arn:aws:detective:${Region}:${AccountId}:graph:${GraphId}
```

例如，行為圖表具有以下值：
+ 行為圖表的區域是 `us-east-1`。
+ 管理員帳戶 ID 的帳戶 ID 為 `111122223333`。
+ 行為圖表的圖表 ID 是 `027c7c4610ea4aacaf0b883093cab899`。

若要在 `Resource` 陳述式中識別此行為圖表，您可以使用以下 ARN：

```
"Resource": "arn:aws:detective:us-east-1:111122223333:graph:027c7c4610ea4aacaf0b883093cab899"
```

若要在 `Resource` 陳述式中指定多項資源，請使用逗號進行分隔。

```
"Resource": [
      "resource1",
      "resource2"
]
```

例如，同一個 AWS 帳戶可能會受邀成為多個行為圖表中的成員帳戶。在該成員帳戶的政策中，`Resource` 陳述式將列出帳戶被邀請使用的行為圖表。

```
"Resource": [
      "arn:aws:detective:us-east-1:111122223333:graph:027c7c4610ea4aacaf0b883093cab899",
      "arn:aws:detective:us-east-1:444455556666:graph:056d2a9521xi2bbluw1d164680eby416"
]
```

建立行為圖表、列出行為圖表和列出行為圖表邀請等部分 Detective 動作不會在特定行為圖表上執行。對於此類動作，`Resource` 陳述式必須使用萬用字元 (\$1)。

```
"Resource": "*"
```

針對管理員帳戶動作，Detective 一律會驗證提出要求的使用者是否屬於受影響行為圖表的管理員帳戶。對於成員帳戶動作，Detective 始終會驗證發出請求的使用者是否屬於該成員帳戶。即使 IAM 政策向行為圖表授予存取權，但如果使用者不屬於正確的帳戶，使用者也無法執行動作。

針對在特定行為圖表上執行的所有動作，IAM 政策應包含圖表 ARN。圖表 ARN 可以在以後新增。例如，當帳戶首次啟用 Detective 時，初始 IAM 政策會使用圖表 ARN 的萬用字元，向所有 Detective 動作提供存取。透過此舉，使用者可以立即開始管理其行為圖表中的成員帳戶並進行調查。建立行為圖表之後，您可以更新政策以新增圖表 ARN。

### 條件索引鍵
<a name="security_iam_service-with-iam-id-based-policies-conditionkeys"></a>

管理員可以使用 AWS JSON 政策來指定誰可以存取內容。也就是說，哪個**主體**在什麼**條件**下可以對什麼**資源**執行哪些**動作**。

`Condition` 元素會根據定義的條件，指定陳述式的執行時機。您可以建立使用[條件運算子](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html)的條件運算式 (例如等於或小於)，來比對政策中的條件和請求中的值。若要查看所有 AWS 全域條件索引鍵，請參閱《*IAM 使用者指南*》中的[AWS 全域條件內容索引鍵](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)。

Detective 不會定義自己的條件金鑰組。其會支援使用某些全域條件金鑰。若要查看所有 AWS 全域條件金鑰，請參閱《*IAM 使用者指南*》中的[AWS 全域條件內容金鑰](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)。



若要了解您可以搭配哪些動作和資源使用條件金鑰，請參閱 [Amazon Detective 定義的動作](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazondetective.html#amazondetective-actions-as-permissions)。

### 範例
<a name="security_iam_service-with-iam-id-based-policies-examples"></a>



若要檢視 Detective 身分型政策範例，請參閱 [Amazon Detective 身分型政策範例](security_iam_id-based-policy-examples.md)。

## Detective 資源型政策 (不支援)。
<a name="security_iam_service-with-iam-resource-based-policies"></a>

Detective 不支援資源型政策。

## 基於 Detective 行為圖表標籤的授權
<a name="security_iam_service-with-iam-tags"></a>

每個行為圖表都可以分配標籤值。您可以在條件陳述式中使用此類標籤值，來管理行為圖表的存取權。

標籤值的條件陳述式使用以下格式。

```
{"StringEquals"{"aws:ResourceTag/<tagName>": "<tagValue>"}}
```

例如，當 `Department` 標籤值為 `Finance` 時，使用以下程式碼來允許或拒絕動作。

```
{"StringEquals"{"aws:ResourceTag/Department": "Finance"}}
```

如需使用資源標籤值的政策範例，請參閱 [管理員帳戶：根據標籤值限制存取許可](security_iam_id-based-policy-examples.md#security_iam_id-based-policy-examples-graph-tags)。

## Detective IAM 角色
<a name="security_iam_service-with-iam-roles"></a>

[IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)是您 AWS 帳戶中具有特定許可的實體。

### 將臨時憑證與 Detective 搭配使用
<a name="security_iam_service-with-iam-roles-tempcreds"></a>

您可以搭配聯合使用暫時憑證、擔任 IAM 角色，或是擔任跨帳戶角色。您可以透過呼叫 [AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) 或 [GetFederationToken](https://docs.aws.amazon.com/STS/latest/APIReference/API_GetFederationToken.html) 等 AWS STS API 操作來取得臨時安全登入資料。

Detective 支援使用臨時憑證。

### 服務連結角色
<a name="security_iam_service-with-iam-roles-service-linked"></a>

[服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-linked-role)可讓 AWS 服務存取其他服務中的資源，以代表您完成 動作。服務連結角色會顯示在您的 IAM 帳戶中，並由該服務所擁有。IAM 管理員可以檢視，但不能編輯服務連結角色的許可。

如需建立或管理 Detective 服務連結角色的詳細資訊，請參閱 [使用 Detective 的服務連結角色](using-service-linked-roles.md)。

### 服務角色 (不支援)
<a name="security_iam_service-with-iam-roles-service"></a>

此功能可讓服務代表您擔任[服務角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-role)。此角色可讓服務存取其他服務中的資源，以代表您完成動作。服務角色會出現在您的 IAM 帳戶中，且由該帳戶所擁有。這表示 IAM 管理員可以變更此角色的許可。不過，這樣可能會破壞此服務的功能。

Detective 不支援服務角色。

# Amazon Detective 身分型政策範例
<a name="security_iam_id-based-policy-examples"></a>

根據預設，IAM 使用者和角色不具備建立或修改 Detective 資源的許可。他們也無法使用 AWS 管理主控台 AWS CLI或 AWS API 執行任務。

IAM 管理員必須建立 IAM 政策，授予使用者和角色在指定資源上執行特定 API 作業的所需許可。管理員接著必須將此類政策附加至需要此類許可的 IAM 使用者或群組。

若要了解如何使用這些範例 JSON 政策文件建立 IAM 身分型政策，請參閱《IAM 使用者指南》**中的[在 JSON 索引標籤上建立政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html#access_policies_create-json-editor)。

**Topics**
+ [政策最佳實務](#security_iam_service-with-iam-policy-best-practices)
+ [使用 Detective 主控台](#security_iam_id-based-policy-examples-console)
+ [允許使用者檢視自己的許可](#security_iam_id-based-policy-examples-view-own-permissions)
+ [管理員帳戶：在行為圖表中管理成員帳戶](#security_iam_id-based-policy-examples-admin-account-mgmt)
+ [管理員帳戶：使用行為圖表進行調查](#security_iam_id-based-policy-examples-admin-investigate)
+ [成員帳戶：管理行為圖表邀請和成員資格](#security_iam_id-based-policy-examples-member-account)
+ [管理員帳戶：根據標籤值限制存取許可](#security_iam_id-based-policy-examples-graph-tags)

## 政策最佳實務
<a name="security_iam_service-with-iam-policy-best-practices"></a>

身分型政策會判斷您帳戶中的某個人員是否可以建立、存取或刪除 Detective 資源。這些動作可能會讓您的 AWS 帳戶產生費用。當您建立或編輯身分型政策時，請遵循下列準則及建議事項：
+ **開始使用 AWS 受管政策並邁向最低權限許可** – 若要開始將許可授予您的使用者和工作負載，請使用將許可授予許多常見使用案例的 *AWS 受管政策*。它們可在您的 中使用 AWS 帳戶。我們建議您定義特定於使用案例 AWS 的客戶受管政策，進一步減少許可。如需更多資訊，請參閱《*IAM 使用者指南*》中的 [AWS 受管政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies)或[任務職能的AWS 受管政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html)。
+ **套用最低權限許可** – 設定 IAM 政策的許可時，請僅授予執行任務所需的許可。為實現此目的，您可以定義在特定條件下可以對特定資源採取的動作，這也稱為*最低權限許可*。如需使用 IAM 套用許可的更多相關資訊，請參閱《*IAM 使用者指南*》中的 [IAM 中的政策和許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html)。
+ **使用 IAM 政策中的條件進一步限制存取權** – 您可以將條件新增至政策，以限制動作和資源的存取。例如，您可以撰寫政策條件，指定必須使用 SSL 傳送所有請求。如果透過特定 例如 使用服務動作 AWS 服務，您也可以使用條件來授予其存取權 CloudFormation。如需詳細資訊，請參閱《*IAM 使用者指南*》中的 [IAM JSON 政策元素：條件](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html)。
+ **使用 IAM Access Analyzer 驗證 IAM 政策，確保許可安全且可正常運作** – IAM Access Analyzer 驗證新政策和現有政策，確保這些政策遵從 IAM 政策語言 (JSON) 和 IAM 最佳實務。IAM Access Analyzer 提供 100 多項政策檢查及切實可行的建議，可協助您撰寫安全且實用的政策。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[使用 IAM Access Analyzer 驗證政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-policy-validation.html)。
+ **需要多重要素驗證 (MFA)** – 如果您的案例需要 IAM 使用者或 中的根使用者 AWS 帳戶，請開啟 MFA 以提高安全性。如需在呼叫 API 操作時請求 MFA，請將 MFA 條件新增至您的政策。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[透過 MFA 的安全 API 存取](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html)。

如需 IAM 中最佳實務的相關資訊，請參閱《*IAM 使用者指南*》中的 [IAM 安全最佳實務](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)。

## 使用 Detective 主控台
<a name="security_iam_id-based-policy-examples-console"></a>

若要使用 Amazon Detective 主控台，使用者或角色必須能夠存取相關動作，此類動作與 API 中的對應動作相符。

若要啟用 Detective 並成為行為圖表的管理員帳戶，必須向使用者或角色授予 `CreateGraph` 動作的許可。

若要使用 Detective 主控台執行任何管理員帳戶動作，必須向使用者或角色授予 `ListGraphs` 動作的許可。這會授予擷取其帳戶為管理員帳戶行為圖表的許可。他們也必須獲得執行特定管理員帳戶動作的許可。

最基本的管理員帳戶動作是檢視行為圖表中的成員帳戶清單，並使用行為圖表進行調查。
+ 若要檢視行為圖表中的成員帳戶清單，必須向主體授予 `ListMembers` 動作的許可。
+ 若要在行為圖表中進行調查，必須向主體授予 `SearchGraph` 動作的許可。

若要使用 Detective 主控台執行任何成員帳戶動作，必須向使用者或角色授予 `ListInvitations` 動作的許可。這會授予檢視行為圖表邀請的許可。然後，他們可以被授予特定成員帳戶動作的許可。

## 允許使用者檢視自己的許可
<a name="security_iam_id-based-policy-examples-view-own-permissions"></a>

此範例會示範如何建立政策，允許 IAM 使用者檢視連接到他們使用者身分的內嵌及受管政策。此政策包含在主控台或使用 或 AWS CLI AWS API 以程式設計方式完成此動作的許可。

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ViewOwnUserInfo",
            "Effect": "Allow",
            "Action": [
                "iam:GetUserPolicy",
                "iam:ListGroupsForUser",
                "iam:ListAttachedUserPolicies",
                "iam:ListUserPolicies",
                "iam:GetUser"
            ],
            "Resource": ["arn:aws:iam::*:user/${aws:username}"]
        },
        {
            "Sid": "NavigateInConsole",
            "Effect": "Allow",
            "Action": [
                "iam:GetGroupPolicy",
                "iam:GetPolicyVersion",
                "iam:GetPolicy",
                "iam:ListAttachedGroupPolicies",
                "iam:ListGroupPolicies",
                "iam:ListPolicyVersions",
                "iam:ListPolicies",
                "iam:ListUsers"
            ],
            "Resource": "*"
        }
    ]
}
```

## 管理員帳戶：在行為圖表中管理成員帳戶
<a name="security_iam_id-based-policy-examples-admin-account-mgmt"></a>

此範例政策適用於僅負責管理行為圖表中使用的成員帳戶的管理員帳戶使用者。透過此政策，使用者也可以檢視用量資訊，並停用 Detective。此政策未授予使用行為圖表進行調查的許可。

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

****  

```
{"Version":"2012-10-17",		 	 	 
  "Statement":[
   {
    "Effect":"Allow",
    "Action":["detective:ListMembers","detective:CreateMembers","detective:DeleteMembers","detective:DeleteGraph","detective:Get*","detective:StartMonitoringMember"],
    "Resource":"arn:aws:detective:us-east-1:111122223333:graph:027c7c4610ea4aacaf0b883093cab899"
  },
  {
    "Effect":"Allow",
    "Action":["detective:CreateGraph","detective:ListGraphs"],
    "Resource":"*"
  }
 ]
}
```

------

## 管理員帳戶：使用行為圖表進行調查
<a name="security_iam_id-based-policy-examples-admin-investigate"></a>

此範例政策適用於僅使用行為圖表進行調查的管理員帳戶使用者。他們無法檢視或編輯行為圖表中的成員帳戶清單。

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

****  

```
{"Version":"2012-10-17",		 	 	 
  "Statement":[
   {
    "Effect":"Allow",
    "Action":["detective:SearchGraph"],
    "Resource":"arn:aws:detective:us-east-1:111122223333:graph:027c7c4610ea4aacaf0b883093cab899"
   },
   {
    "Effect":"Allow",
    "Action":["detective:ListGraphs"],
    "Resource":"*"
  }
 ]
}
```

------

## 成員帳戶：管理行為圖表邀請和成員資格
<a name="security_iam_id-based-policy-examples-member-account"></a>

此範例政策適用於屬於成員帳戶的使用者。在此範例中，成員帳戶屬於兩個行為圖表。此政策會授予回應邀請並從行為圖表中移除成員帳戶的許可。

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

****  

```
{"Version":"2012-10-17",		 	 	 
  "Statement":[
   {
    "Effect":"Allow",
   "Action":["detective:AcceptInvitation","detective:RejectInvitation","detective:DisassociateMembership"],
   "Resource":[
       "arn:aws:detective:us-east-1:111122223333:graph:027c7c4610ea4aacaf0b883093cab899",
       "arn:aws:detective:us-east-1:444455556666:graph:056d2a9521xi2bbluw1d164680eby416"
    ]
  },
  {
    "Effect":"Allow",
    "Action":["detective:ListInvitations"],
    "Resource":"*"
  }
 ]
}
```

------

## 管理員帳戶：根據標籤值限制存取許可
<a name="security_iam_id-based-policy-examples-graph-tags"></a>

如果行為圖表的 `SecurityDomain` 標籤符合使用者的 `SecurityDomain` 標籤，透過以下政策，使用者可以使用行為圖表進行調查。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "detective:SearchGraph"
            ],
            "Resource": "arn:aws:detective:*:*:graph:*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/SecurityDomain": "aws:PrincipalTag/SecurityDomain"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "detective:ListGraphs"
            ],
            "Resource": "*"
        }
    ]
}
```

------

如果行為圖表的 `SecurityDomain` 標籤值為 `Finance`，以下政策可防止使用者使用行為圖表進行調查。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":[ {
        "Effect":"Deny",
        "Action":["detective:SearchGraph"],
        "Resource":"arn:aws:detective:*:*:graph:*",
        "Condition": {
            "StringEquals": {"aws:ResourceTag/SecurityDomain": "Finance"}
        }
    } ]
}
```

------

# AWS Amazon Detective 的 受管政策
<a name="security-iam-awsmanpol"></a>

 AWS 受管政策是由 AWS AWS 受管政策建立和管理的獨立政策旨在為許多常用案例提供許可，以便您可以開始將許可指派給使用者、群組和角色。

請記住， AWS 受管政策可能不會授予特定使用案例的最低權限許可，因為這些許可可供所有 AWS 客戶使用。我們建議您定義特定於使用案例的[客戶管理政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#customer-managed-policies)，以便進一步減少許可。

您無法變更 AWS 受管政策中定義的許可。如果 AWS 更新受 AWS 管政策中定義的許可，則更新會影響政策連接的所有主體身分 （使用者、群組和角色）。當新的 AWS 服務 啟動或新的 API 操作可用於現有服務時， AWS 最有可能更新 AWS 受管政策。

如需詳細資訊，請參閱 *IAM 使用者指南*中的 [AWS 受管政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies)。







## AWS 受管政策： AmazonDetectiveFullAccess
<a name="security-iam-awsmanpol-amazondetectivefullaccess"></a>

您可將 `AmazonDetectiveFullAccess` 政策連接到 IAM 身分。

此政策會授予管理許可，允許主體完整存取所有 Amazon Detective 動作。您可以將此政策附加到主體，然後再針對帳戶啟用 Detective。它還必須附加到用於執行 Detective Python 指令碼以建立和管理行為圖表的角色。

具有此類許可的主體可以管理成員帳戶、將標籤新增至其行為圖表，以及使用 Detective 進行調查。他們還可以封存 GuardDuty 調查結果。政策提供 Detective 主控台顯示所在帳戶的帳戶名稱所需的許可 AWS Organizations。

**許可詳細資訊**

此政策包含以下許可：
+ `detective`：允許主體完整存取所有 Detective 動作。
+ `organizations`：允許主體從組織中擷取針對帳戶的 AWS Organizations 資訊。如果帳戶屬於某個組織，除了帳號之外，此類許可還允許 Detective 主控台顯示帳戶名稱。
+ `guardduty`：允許主體從 Detective 內部取得和封存 GuardDuty 調查結果。
+ `securityhub` – 允許主體從 Detective 中取得 Security Hub CSPM 問題清單。



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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "detective:*",
                "organizations:DescribeOrganization",
                "organizations:ListAccounts"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "guardduty:ArchiveFindings"
            ],
            "Resource": "arn:aws:guardduty:*:*:detector/*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "guardduty:GetFindings",
                "guardduty:ListDetectors"
                
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                 "securityHub:GetFindings"
            ],
            "Resource": "*"
         } 
    ]
}
```

------

## AWS 受管政策： AmazonDetectiveMemberAccess
<a name="security-iam-awsmanpol-amazondetectivememberaccess"></a>

您可將 `AmazonDetectiveMemberAccess` 政策附加至 IAM 實體。





此政策會向成員提供 Amazon Detective 的存取，以及主控台的特定範圍存取。

使用此政策，您可以：
+ 檢視向 Detective 圖表成員發出的邀請，並接受或拒絕邀請。
+ 在**用量**頁面查看您在 Detective 中的活動如何影響使用此服務的成本。
+ 放棄圖表中的成員資格。

此政策授予唯讀許可，允許在一定範圍内存取 Detective 主控台。



**許可詳細資訊**

此政策包含以下許可：




+ `detective`：允許成員存取 Detective。



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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "detective:AcceptInvitation",
        "detective:BatchGetMembershipDatasources",
        "detective:DisassociateMembership",
        "detective:GetFreeTrialEligibility",
        "detective:GetPricingInformation",
        "detective:GetUsageInformation",
        "detective:ListInvitations",
        "detective:RejectInvitation"
      ],
      "Resource": "*"
    }
  ]
}
```

------

## AWS 受管政策： AmazonDetectiveInvestigatorAccess
<a name="security-iam-awsmanpol-amazondetectiveinvestigatoraccesspolicy"></a>

您可將 `AmazonDetectiveInvestigatorAccess` 政策附加至 IAM 實體。





此政策向調查人員提供對 Detective 服務的存取，以及 Detective 主控台 UI 相依性的特定範圍存取。此政策授予在 Detective 中對 IAM 使用者和 IAM 角色啟用 Detective 調查的許可。您可以使用調查報告來調查以識別調查結果等入侵指標，該報告提供有關安全指標的分析和見解。該報告按嚴重性進行排名，由 Detective 的行為分析和機器學習決定。您可以使用報告來排定資源修補的優先順序。



**許可詳細資訊**

此政策包含以下許可：




+ `detective`：允許主體調查者存取 Detective 動作，以啟用 Detective 調查，以及啟用調查結果群組摘要。
+ `guardduty`：允許主體從 Detective 內部取得和封存 GuardDuty 調查結果。
+ `securityhub` – 允許主體從 Detective 中取得 Security Hub CSPM 問題清單。
+ `organizations` – 允許主體從中擷取組織中帳戶的相關資訊 AWS Organizations。如果帳戶屬於某個組織，則除了帳號之外，此類許可還允許 Detective 主控台顯示帳戶名稱。



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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "DetectivePermissions",
      "Effect": "Allow",
      "Action": [ 
        "detective:BatchGetGraphMemberDatasources",
        "detective:BatchGetMembershipDatasources",
        "detective:DescribeOrganizationConfiguration",
        "detective:GetFreeTrialEligibility",
        "detective:GetGraphIngestState",
        "detective:GetMembers",
        "detective:GetPricingInformation",
        "detective:GetUsageInformation",
        "detective:ListDatasourcePackages",
        "detective:ListGraphs",
        "detective:ListHighDegreeEntities",
        "detective:ListInvitations",
        "detective:ListMembers",
        "detective:ListOrganizationAdminAccount",
        "detective:ListTagsForResource",
        "detective:SearchGraph",
        "detective:StartInvestigation",
        "detective:GetInvestigation",
        "detective:ListInvestigations",
        "detective:UpdateInvestigationState",
        "detective:ListIndicators",
        "detective:InvokeAssistant"
      ],
      "Resource": "*"
    },
    {
      "Sid": "OrganizationsPermissions",
      "Effect": "Allow",
      "Action": [
        "organizations:DescribeOrganization",
        "organizations:ListAccounts"
      ],
      "Resource": "*"
    },
    {
      "Sid": "GuardDutyPermissions",
      "Effect": "Allow",
      "Action": [
        "guardduty:ArchiveFindings",
        "guardduty:GetFindings",
        "guardduty:ListDetectors"
      ],
      "Resource": "*"
    },
    {
      "Sid": "SecurityHubPermissions",
      "Effect": "Allow",
      "Action": [
        "securityHub:GetFindings"
      ],
      "Resource": "*"
    }
  ]
}
```

------

## AWS 受管政策：AmazonDetectiveOrganizationsAccess
<a name="security-iam-awsmanpol-amazondetectiveorganizationsaccesspolicy"></a>

您可將 `AmazonDetectiveOrganizationsAccess` 政策附加至 IAM 實體。

此政策授予在組織內啟用和管理 Amazon Detective 的許可。您可以在整個組織中啟用 Detective，並決定 Detective 的委派管理員帳戶。

**許可詳細資訊**

此政策包含以下許可：




+ `detective`：允許主體存取 Detective 動作。
+ `iam`：指定在 Detective 呼叫 `EnableOrganizationAdminAccount` 時建立服務連結角色。
+ `organizations` – 允許主體從中擷取組織中帳戶的相關資訊 AWS Organizations。如果帳戶屬於某個組織，則除了帳號之外，此類許可還允許 Detective 主控台顯示帳戶名稱。啟用 AWS 服務的整合、允許以委派管理員身分註冊和取消註冊指定的成員帳戶，以及允許委託人擷取 Amazon Detective、Amazon GuardDuty、Amazon Macie 和 等其他安全服務中的委派管理員帳戶 AWS Security Hub CSPM。



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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "detective:DisableOrganizationAdminAccount",
        "detective:EnableOrganizationAdminAccount",
        "detective:ListOrganizationAdminAccount"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "iam:CreateServiceLinkedRole"
      ],
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "iam:AWSServiceName": "detective.amazonaws.com"
        }
      }
    },
    {
      "Effect": "Allow",
      "Action": [
        "organizations:EnableAWSServiceAccess",
        "organizations:RegisterDelegatedAdministrator",
        "organizations:DeregisterDelegatedAdministrator"
      ],
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "organizations:ServicePrincipal": [
            "detective.amazonaws.com"
          ]
        }
      }
    },
    {
      "Effect": "Allow",
      "Action": [
        "organizations:DescribeAccount",
        "organizations:DescribeOrganization",
        "organizations:ListAccounts"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "organizations:ListDelegatedAdministrators"
      ],
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "organizations:ServicePrincipal": [
            "detective.amazonaws.com",
            "guardduty.amazonaws.com",
            "macie.amazonaws.com",
            "securityhub.amazonaws.com"
          ]
        }
      }
    }
  ]
}
```

------

## AWS 受管政策： AmazonDetectiveServiceLinkedRole
<a name="security-iam-awsmanpol-amazondetectiveservicelinkedrolepolicy"></a>

您無法將 `AmazonDetectiveServiceLinkedRole` 政策附加至 IAM 實體。此政策會附加到服務連結角色，透過該角色，Detective 可代表您執行動作。如需詳細資訊，請參閱 [使用 Detective 的服務連結角色](using-service-linked-roles.md)。



此政策會授予管理許可，允許服務連結角色擷取組織的帳戶資訊。

**許可詳細資訊**

此政策包含以下許可：


+ `organizations`：擷取組織的帳戶資訊。



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

****  

```
{
  "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
              "organizations:DescribeAccount",
              "organizations:ListAccounts"
            ],
            "Resource": "*"
        }
    ]
}
```

------

## AWS 受管政策的偵測更新
<a name="security-iam-awsmanpol-updates"></a>

檢視自此服務開始追蹤這些變更以來 Detective AWS 受管政策更新的詳細資訊。如需自動收到有關此頁面變更的提醒，請前往 [ 文件歷史記錄頁面](doc-history.md)上訂閱 RSS 摘要。








| 變更 | 描述 | Date | 
| --- | --- | --- | 
|  [AmazonDetectiveInvestigatorAccess](#security-iam-awsmanpol-amazondetectiveinvestigatoraccesspolicy)：現有政策的更新  |  在 `AmazonDetectiveInvestigatorAccess` 政策中新增了 Detective 調查和調查結果群組摘要動作。 此類動作允許啟動，擷取和更新 Detective 調查結果並從 Detective 內部獲得調查結果群組的摘要。  | 2023 年 11 月 26 日 | 
|  [AmazonDetectiveFullAccess](#security-iam-awsmanpol-amazondetectivefullaccess) 和 [AmazonDetectiveInvestigatorAccess](#security-iam-awsmanpol-amazondetectiveorganizationsaccesspolicy) – 對現有政策的更新  |  Detective 已將 Security Hub CSPM `GetFindings`動作新增至 `AmazonDetectiveFullAccess`和 `AmazonDetectiveInvestigatorAccess`政策。 這些動作允許從 Detective 內取得 Security Hub CSPM 調查結果。  | 2023 年 5 月 16 日 | 
|  [AmazonDetectiveOrganizationsAccess](#security-iam-awsmanpol-amazondetectiveorganizationsaccesspolicy) – 新政策  |  Detective 新增了 `AmazonDetectiveOrganizationsAccess` 政策。 此政策授予在組織內啟用和管理 Detective 的許可  | 2023 年 3 月 2 日 | 
|  [AmazonDetectiveMemberAccess](#security-iam-awsmanpol-amazondetectivememberaccess) – 新政策  |  Detective 新增了 `AmazonDetectiveMemberAccess` 政策。 此政策會向成員提供 Detective 的存取，以及主控台 UI 依存關系的特定範圍存取。  |  2023 年 1 月 17 日  | 
|  [AmazonDetectiveFullAccess](#security-iam-awsmanpol-amazondetectivefullaccess)：現有政策的更新  |  Detective 向 `AmazonDetectiveFullAccess` 政策新增了 GuardDuty `GetFindings` 動作。 透過此類動作，可從 Detective 內部取得 GuardDuty 調查結果。  | 2023 年 1 月 17 日 | 
|  [AmazonDetectiveInvestigatorAccess](#security-iam-awsmanpol-amazondetectiveinvestigatoraccesspolicy) – 新政策  | Detective 新增了 `AmazonDetectiveInvestigatorAccess` 政策。 透過此類政策，主體可在 Detective 中進行調查。 | 2023 年 1 月 17 日  | 
|  [AmazonDetectiveServiceLinkedRole](#security-iam-awsmanpol-amazondetectiveservicelinkedrolepolicy) – 新政策  |  Detective 為其服務連結角色新增了新政策。 透過政策，服務連結角色可以擷取組織中帳戶的相關資訊。  | 2021 年 12 月 16 日 | 
|  Detective 開始追蹤變更  |  Detective 開始追蹤其 AWS 受管政策的變更。  | 2021 年 5 月 10 日 | 

# 使用 Detective 的服務連結角色
<a name="using-service-linked-roles"></a>

Amazon Detective 使用 AWS Identity and Access Management (IAM)[ 服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-linked-role)。服務連結角色是直接連結至 Detective 的一種特殊 IAM 角色類型。服務連結角色由 Detective 預先定義，並包含該服務代表您呼叫其他 AWS 服務所需的所有許可。

服務連結角色可簡化 Detective 的設定，因為您不必手動新增必要的許可。Detective 定義其服務連結角色的許可，除非另有定義，否則僅有 Detective 可以擔任其角色。定義的許可包括信任政策和許可政策，且該許可政策無法附加至其他 IAM 實體。

您必須先刪除服務連結角色的相關資源，才能將其刪除。如此可保護您 Detective 的資源，避免您不小心移除資源的存取許可。

如需支援服務連結角色的其他服務資訊，請參閱[可搭配 IAM 運作的 AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)，並尋找**服務連結角色**欄位顯示**是**的服務。選擇具有連結的 **Yes** (是)，以檢視該服務的服務連結角色文件。

## Detective 的服務連結角色許可
<a name="slr-permissions"></a>

Detective 使用名為 **AWSServiceRoleForDetective** 的服務連結角色 – 允許 Detective 代表您存取 AWS Organizations 資訊。

AWSServiceRoleForDetective 服務連結角色信任以下服務可擔任該角色：
+ `detective.amazonaws.com`

AWSServiceRoleForDetective 服務連結角色會使用受管政策，即 [`AmazonDetectiveServiceLinkedRolePolicy`](security-iam-awsmanpol.md#security-iam-awsmanpol-amazondetectiveservicelinkedrolepolicy)。

如需`AmazonDetectiveServiceLinkedRolePolicy`政策更新的詳細資訊，請參閱 [Amazon Detective AWS 受管政策的更新](https://docs.aws.amazon.com//detective/latest/userguide/security-iam-awsmanpol.html#security-iam-awsmanpol-updates)。如需此政策變更的自動提醒，請訂閱 [Detective 文件歷史記錄](https://docs.aws.amazon.com//detective/latest/userguide/doc-history.html)頁面上的 RSS 摘要。

您必須設定許可，IAM 實體 (如使用者、群組或角色) 才可建立、編輯或刪除服務連結角色。如需詳細資訊，請參閱 *IAM 使用者指南*中的[服務連結角色許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#service-linked-role-permissions)。

## 為 Detective 建立服務連結角色
<a name="create-slr"></a>

您不需要手動建立一個服務連結角色。當您在 AWS CLI、 或 AWS API 中為組織指定 Detective AWS 管理主控台管理員帳戶時，Detective 會為您建立服務連結角色。

若您刪除此服務連結角色，之後需要再次建立，您可以在帳戶中使用相同程序重新建立角色。當您為組織指定 Detective 管理員帳戶時，Detective 可再次為您建立服務連結角色。

## 為 Detective 編輯服務連結角色
<a name="edit-slr"></a>

Detective 不允許您編輯 AWSServiceRoleForDetective 服務連結角色。因為有各種實體可能會參考服務連結角色，所以您無法在建立角色之後變更角色名稱。然而，您可使用 IAM 來編輯角色描述。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[編輯服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#edit-service-linked-role)。

## 為 Detective 刪除服務連結角色
<a name="delete-slr"></a>

若您不再使用需要服務連結角色的功能或服務，我們建議您刪除該角色。如此一來，您就沒有未主動監控或維護的未使用實體。然而，在手動刪除服務連結角色之前，您必須先清除資源。

**注意**  
若 Detective 服務在您試圖刪除資源時正在使用該角色，刪除可能會失敗。若此情況發生，請等待數分鐘後，然後再次嘗試操作。

**若要刪除 AWSServiceRoleForDetective 所使用的 Detective 資源**

1. 移除 Detective 管理員帳戶。請參閱 [指定組織的 Detective 管理員](accounts-designate-admin.md)。

1. 在您指定 Detective 管理員帳戶的每個區域中重複此程序。

**使用 IAM 手動刪除服務連結角色**

使用 IAM 主控台 AWS CLI、 或 AWS API 來刪除 AWSServiceRoleForDetective 服務連結角色。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[刪除服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#delete-service-linked-role)。

## Detective 服務連結角色支援的區域
<a name="slr-regions"></a>

Detective 支援在所有提供服務的區域中使用服務連結角色。如需詳細資訊，請參閱 [AWS 區域與端點](https://docs.aws.amazon.com/general/latest/gr/rande.html)。

# Amazon Detective 身分識別和存取疑難排解
<a name="security_iam_troubleshoot"></a>

請參考以下資訊，診斷及修正使用 Detective 和 IAM 時可能發生的常見問題。如果您在使用 AWS Identity and Access Management(IAM) 時遇到存取遭拒問題或類似困難，請參閱《[IAM 使用者指南》中的疑難排解](https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot.html) *IAM* 主題。

## 我未獲授權，不得在 Detective 中執行動作
<a name="security_iam_troubleshoot-no-permissions"></a>

如果 AWS 管理主控台 告知您無權執行 動作，則必須聯絡您的管理員尋求協助。您的管理員是為您提供使用者名稱和密碼的人員。

以下範例錯誤會在 `mateojackson` IAM 使用者嘗試使用主控台接受成為行為圖表成員帳戶的邀請，但卻無 `detective:AcceptInvitation` 許可時發生。

```
User: arn:aws:iam::123456789012:user/mateojackson is not authorized to perform: detective:AcceptInvitation on resource: arn:aws:detective:us-east-1:444455556666:graph:567856785678
```

在此情況下，Mateo 會請求管理員更新他的政策，允許他使用 `arn:aws:detective:us-east-1:444455556666:graph:567856785678` 動作存取 `detective:AcceptInvitation` 資源。

## 我未獲得執行 iam:PassRole 的授權
<a name="security_iam_troubleshoot-passrole"></a>

如果錯誤訊息告知您未獲得授權，無法執行 `iam:PassRole` 動作，您必須更新政策，以允許您將角色傳遞給 Detective。

有些 AWS 服務 可讓您將現有角色傳遞給該服務，而不是建立新的服務角色或服務連結角色。如需執行此作業，您必須擁有將角色傳遞至該服務的許可。

名為 `marymajor` 的 IAM 使用者嘗試使用主控台在 Detective 中執行動作時，會發生以下範例所示的錯誤。但是，動作請求服務具備服務角色授予的許可。Mary 沒有將角色傳遞給服務的許可。

```
User: arn:aws:iam::123456789012:user/marymajor is not authorized to perform: iam:PassRole
```

在這種情況下，Mary 的政策必須更新，允許她執行 `iam:PassRole` 動作。

如果您需要協助，請聯絡您的 AWS 管理員。您的管理員提供您的簽署憑證。

## 我想要允許 AWS 帳戶外的人員存取我的 Detective 資源
<a name="security_iam_troubleshoot-cross-account-access"></a>

您可以建立一個角色，讓其他帳戶中的使用者或您組織外部的人員存取您的資源。您可以指定要允許哪些信任物件取得該角色。針對支援基於資源的政策或存取控制清單 (ACL) 的服務，您可以使用那些政策來授予人員存取您的資源的許可。

如需進一步了解，請參閱以下內容：
+ 若要了解 Detective 是否支援此類功能，請參閱 [Amazon Detective 如何搭配 IAM 運作](security_iam_service-with-iam.md)。
+ 若要了解如何 AWS 帳戶 在您擁有的 資源之間提供存取權，請參閱《[IAM 使用者指南》中的在您擁有 AWS 帳戶 的另一個 IAM 使用者中提供存取權](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_aws-accounts.html)。 **
+ 若要了解如何將資源的存取權提供給第三方 AWS 帳戶，請參閱《*IAM 使用者指南*》中的[將存取權提供給第三方 AWS 帳戶 擁有](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_third-party.html)。
+ 如需了解如何透過聯合身分提供存取權，請參閱《*IAM 使用者指南*》中的[將存取權提供給在外部進行身分驗證的使用者 (聯合身分)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_federated-users.html)。
+ 如需了解使用角色和資源型政策進行跨帳戶存取之間的差異，請參閱《IAM 使用者指南》**中的 [IAM 中的跨帳戶資源存取](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html)。