

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

# 的身分和存取管理 AWS IoT Greengrass
<a name="security-iam"></a>

AWS Identity and Access Management (IAM) 是一種 AWS 服務 ，可協助管理員安全地控制對 AWS 資源的存取。IAM 管理員可控制誰可以進行*驗證 *（登入） 和*授權* （具有許可） 來使用 AWS IoT Greengrass 資源。IAM 是您可以免費使用 AWS 服務 的 。

**注意**  
本主題說明 IAM 概念和功能。如需 支援的 IAM 功能的相關資訊 AWS IoT Greengrass，請參閱 [AWS IoT Greengrass 如何使用 IAM](security_iam_service-with-iam.md)。

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

使用方式 AWS Identity and Access Management (IAM) 會根據您的角色而有所不同：
+ **服務使用者** — 若無法存取某些功能，請向管理員申請所需許可 (請參閱 [對 的身分和存取問題進行故障診斷 AWS IoT Greengrass](security_iam_troubleshoot.md))
+ **服務管理員** — 負責設定使用者存取權並提交相關許可請求 (請參閱 [AWS IoT Greengrass 如何使用 IAM](security_iam_service-with-iam.md))
+ **IAM 管理員** — 撰寫政策以管理存取控制 (請參閱 [的身分型政策範例 AWS IoT Greengrass](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)。

## 另請參閱
<a name="security_iam_service-see-also"></a>
+ [AWS IoT Greengrass 如何使用 IAM](security_iam_service-with-iam.md)
+ [的身分型政策範例 AWS IoT Greengrass](security_iam_id-based-policy-examples.md)
+ [對 的身分和存取問題進行故障診斷 AWS IoT Greengrass](security_iam_troubleshoot.md)

# AWS IoT Greengrass 如何使用 IAM
<a name="security_iam_service-with-iam"></a>

在您使用 IAM 管理對 的存取之前 AWS IoT Greengrass，您應該了解可與 搭配使用的 IAM 功能 AWS IoT Greengrass。


| IAM 功能 | 受到 Greengrass 支援？ | 
| --- | --- | 
| [具有資源層級許可的身分型政策](#security_iam_service-with-iam-id-based-policies) | 是 | 
| [資源型政策](#security_iam_service-with-iam-resource-based-policies) | 否 | 
| [存取控制清單 (ACL)](#security_iam_service-with-iam-acls) | 否 | 
| [標籤型授權](#security_iam_service-with-iam-tags) | 是 | 
| [臨時憑證](#security_iam_service-with-iam-roles-tempcreds) | 是 | 
| [服務連結角色](#security_iam_service-with-iam-roles-service-linked) | 否 | 
| [服務角色](#security_iam_service-with-iam-roles-service-linked) | 是 | 

如需其他 AWS 服務如何與 IAM 搭配使用的高階檢視，請參閱《[AWS IAM 使用者指南》中的與 IAM 搭配使用的 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)。 **

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

透過 IAM 身分型政策，您可以指定允許或拒絕的動作和資源，以及允許或拒絕動作的條件。 AWS IoT Greengrass 支援特定動作、資源和條件索引鍵。若要了解您在政策中使用的所有元素，請參閱《[IAM 使用者指南》中的 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` 元素描述您可以用來允許或拒絕政策中存取的動作。政策會使用動作來授予執行相關聯動作的許可。

的政策動作會在動作之前 AWS IoT Greengrass 使用 `greengrass:`字首。例如，若要允許某人使用 `ListCoreDevices` API 操作在其中列出核心裝置 AWS 帳戶，請在其政策中包含 `greengrass:ListCoreDevices`動作。政策陳述式必須包含 `Action`或 `NotAction`元素。 AWS IoT Greengrass 會定義自己的一組動作，描述您可以使用此服務執行的任務。

若要在單一陳述式中指定多個動作，請在括號 (`[` `]`) 之間列出它們，並以逗號分隔，如下所示：

```
"Action": [
  "greengrass:action1",
  "greengrass:action2",
  "greengrass:action3"
]
```

您可以使用萬用字元 (`*`) 來指定多個動作。例如，若要指定開頭是 `List` 文字的所有動作，請包含以下動作：

```
"Action": "greengrass:List*"
```

**注意**  
建議您避免使用萬用字元來指定服務的所有可用動作。最佳實務是，您應該在政策中授予最低權限和範圍較窄的許可。如需詳細資訊，請參閱[盡可能授予最低的許可](security-best-practices.md#least-privilege)。

如需 AWS IoT Greengrass 動作的完整清單，請參閱《*IAM 使用者指南*》中的 [定義的動作 AWS IoT Greengrass](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awsiotgreengrass.html#awsiotgreengrass-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": "*"
```

下表包含可用於政策陳述式的 `Resource` 元素中的 AWS IoT Greengrass 資源 ARN。如需 AWS IoT Greengrass 動作支援的資源層級許可映射，請參閱《*IAM 使用者指南*》中的 [定義的動作 AWS IoT Greengrass](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awsiotgreengrass.html#awsiotgreengrass-actions-as-permissions)。

某些 AWS IoT Greengrass 動作 （例如，某些清單操作） 無法對特定資源執行。在這些情況下，您必須使用萬用字元 (\$1)。

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

若要在陳述式中指定多個資源 ARNs，請在括號 (`[` `]`) 之間列出它們，並以逗號分隔，如下所示：

```
"Resource": [
  "resource-arn1",
  "resource-arn2",
  "resource-arn3"
]
```

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

### 條件索引鍵
<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)。

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



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

## 的資源型政策 AWS IoT Greengrass
<a name="security_iam_service-with-iam-resource-based-policies"></a>

AWS IoT Greengrass 不支援[以資源為基礎的政策](security-iam.md#security_iam_access-manage-resource-based-policies)。

## 存取控制清單 (ACL)
<a name="security_iam_service-with-iam-acls"></a>

AWS IoT Greengrass 不支援 [ACLs](security-iam.md#security_iam_access-manage-acl)。

## 以 AWS IoT Greengrass 標籤為基礎的授權
<a name="security_iam_service-with-iam-tags"></a>

您可以將標籤連接到支援 AWS IoT Greengrass 的資源，或在請求中將標籤傳遞給 AWS IoT Greengrass。若要根據標籤控制存取，您可以使用 `aws:RequestTag/${TagKey}`、 `aws:ResourceTag/${TagKey}`或 [條件索引鍵，在政策的條件元素](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html)中提供標籤資訊。 `aws:TagKeys`如需詳細資訊，請參閱[標記您的 AWS IoT Greengrass Version 2 資源](tag-resources.md)。

## 的 IAM 角色 AWS IoT Greengrass
<a name="security_iam_service-with-iam-roles"></a>

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

### 搭配 使用臨時登入資料 AWS IoT Greengrass
<a name="security_iam_service-with-iam-roles-tempcreds"></a>

臨時登入資料用於使用聯合身分登入、擔任 IAM 角色，或擔任跨帳戶角色。您取得暫時安全憑證的方式是透過呼叫 AWS STS API 作業 (例如，[AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) 或 [GetFederationToken](https://docs.aws.amazon.com/STS/latest/APIReference/API_GetFederationToken.html))。

在 Greengrass 核心上，[裝置角色](device-service-role.md)的臨時登入資料可供 Greengrass 元件使用。如果您的元件使用 AWS SDK，您不需要新增邏輯來取得登入資料，因為 AWS SDK 會為您執行此操作。

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

AWS IoT Greengrass 不支援[服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-linked-role)。

### 服務角色
<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 管理員可以變更此角色的許可。不過，這樣可能會破壞此服務的功能。

AWS IoT Greengrass 核心裝置使用服務角色來允許 Greengrass 元件和 Lambda 函數代表您存取您的部分 AWS 資源。如需詳細資訊，請參閱[授權核心裝置與 AWS 服務互動](device-service-role.md)。

AWS IoT Greengrass 使用服務角色代表您存取您的部分 AWS 資源。如需詳細資訊，請參閱[Greengrass 服務角色](greengrass-service-role.md)。

# 的身分型政策範例 AWS IoT Greengrass
<a name="security_iam_id-based-policy-examples"></a>

根據預設，IAM 使用者和角色不具備建立或修改 AWS IoT Greengrass 資源的許可。他們也無法使用 AWS 管理主控台 AWS CLI或 AWS API 執行任務。IAM 管理員必須建立 IAM 政策，授予使用者和角色在指定資源上執行特定 API 作業的所需許可。管理員接著必須將這些政策連接至需要這些許可的 IAM 使用者或群組。

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

身分型政策會判斷您帳戶中的某個人員是否可以建立、存取或刪除 AWS IoT Greengrass 資源。這些動作可能會讓您的 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)。

## 政策範例
<a name="security_iam_id-based-policy-examples-list"></a>

下列客戶定義的政策範例會授予常見案例的許可。

**Topics**
+ [允許使用者檢視他們自己的許可](#security_iam_id-based-policy-examples-view-own-permissions)

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

### 允許使用者檢視他們自己的許可
<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": "*"
        }
    ]
}
```

# 授權核心裝置與 AWS 服務互動
<a name="device-service-role"></a>

AWS IoT Greengrass 核心裝置使用 AWS IoT Core 登入資料提供者來授權對 AWS 服務的呼叫。 AWS IoT Core 登入資料提供者可讓裝置使用其 X.509 憑證做為唯一裝置身分來驗證 AWS 請求。這不需要在 AWS IoT Greengrass 核心裝置上存放 AWS 存取金鑰 ID 和私密存取金鑰。如需詳細資訊，請參閱《 *AWS IoT Core 開發人員指南*》中的[授權直接呼叫 AWS 服務](https://docs.aws.amazon.com/iot/latest/developerguide/authorizing-direct-aws.html)。

當您執行 AWS IoT Greengrass Core 軟體時，您可以選擇佈建核心裝置所需的 AWS 資源。這包括核心裝置透過 AWS IoT Core 登入資料提供者擔任的 AWS Identity and Access Management (IAM) 角色。使用 `--provision true`引數來設定角色和政策，以允許核心裝置取得臨時 AWS 登入資料。此引數也會設定指向此 IAM AWS IoT 角色的角色別名。您可以指定要使用的 IAM 角色和 AWS IoT 角色別名的名稱。如果您在`--provision true`沒有這些其他名稱參數的情況下指定 ，Greengrass 核心裝置會建立並使用下列預設資源：
+ IAM 角色： `GreengrassV2TokenExchangeRole`

  此角色具有名為 的政策，`GreengrassV2TokenExchangeRoleAccess`以及允許 `credentials.iot.amazonaws.com`擔任該角色的信任關係。此政策包含核心裝置的最低許可。
**重要**  
此政策不包含對 S3 儲存貯體中檔案的存取。您必須將許可新增至角色，以允許核心裝置從 S3 儲存貯體擷取元件成品。如需詳細資訊，請參閱[允許存取元件成品的 S3 儲存貯體](#device-service-role-access-s3-bucket)。
+ AWS IoT 角色別名： `GreengrassV2TokenExchangeRoleAlias`

  此角色別名是指 IAM 角色。

如需詳細資訊，請參閱[步驟 3：安裝 AWS IoT Greengrass 核心軟體](install-greengrass-v2.md)。

您也可以設定現有核心裝置的角色別名。若要這樣做，請設定 [Greengrass 核元件](greengrass-nucleus-component.md)的`iotRoleAlias`組態參數。

您可以取得此 IAM 角色的臨時 AWS 登入資料，以在自訂元件中執行 AWS 操作。如需詳細資訊，請參閱[與 AWS 服務互動](interact-with-aws-services.md)。

**Topics**
+ [核心裝置的服務角色許可](#device-service-role-permissions)
+ [允許存取元件成品的 S3 儲存貯體](#device-service-role-access-s3-bucket)

## 核心裝置的服務角色許可
<a name="device-service-role-permissions"></a>

該角色允許下列服務擔任該角色：
+ `credentials.iot.amazonaws.com`

如果您使用 AWS IoT Greengrass 核心軟體建立此角色，它會使用下列許可政策來允許核心裝置連接和傳送日誌 AWS。政策的名稱預設為以 結尾的 IAM 角色名稱`Access`。例如，如果您使用預設 IAM 角色名稱，則此政策的名稱為 `GreengrassV2TokenExchangeRoleAccess`。

------
#### [ Greengrass nucleus v2.5.0 and later ]

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents",
        "logs:DescribeLogStreams",
        "s3:GetBucketLocation"
      ],
      "Resource": "*"
    }
  ]
}
```

------

------
#### [ v2.4.x ]

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iot:DescribeCertificate",
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents",
        "logs:DescribeLogStreams",
        "s3:GetBucketLocation"
      ],
      "Resource": "*"
    }
  ]
}
```

------

------
#### [ Earlier than v2.4.0 ]

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iot:DescribeCertificate",
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents",
        "logs:DescribeLogStreams",
        "iot:Connect",
        "iot:Publish",
        "iot:Subscribe",
        "iot:Receive",
        "s3:GetBucketLocation"
      ],
      "Resource": "*"
    }
  ]
}
```

------

------

## 允許存取元件成品的 S3 儲存貯體
<a name="device-service-role-access-s3-bucket"></a>

預設的核心裝置角色不允許核心裝置存取 S3 儲存貯體。若要部署在 S3 儲存貯體中具有成品的元件，您必須新增允許核心裝置下載元件成品的`s3:GetObject`許可。您可以將新政策新增至核心裝置角色，以授予此許可。

**新增允許存取 Amazon S3 中元件成品的政策**

1. 建立名為 的檔案`component-artifact-policy.json`，並將下列 JSON 複製到 檔案。此政策允許存取 S3 儲存貯體中的所有檔案。將 amzn-s3-demo-bucket 取代為 S3 儲存貯體的名稱，以允許核心裝置存取。

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

****  

   ```
   {
     "Version":"2012-10-17",		 	 	 
     "Statement": [
       {
         "Effect": "Allow",
         "Action": [
           "s3:GetObject"
         ],
         "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*"
       }
     ]
   }
   ```

------

1. 執行下列命令，從 中的政策文件建立政策`component-artifact-policy.json`。

------
#### [ Linux or Unix ]

   ```
   aws iam create-policy \
     --policy-name MyGreengrassV2ComponentArtifactPolicy \
     --policy-document file://component-artifact-policy.json
   ```

------
#### [ Windows Command Prompt (CMD) ]

   ```
   aws iam create-policy ^
     --policy-name MyGreengrassV2ComponentArtifactPolicy ^
     --policy-document file://component-artifact-policy.json
   ```

------
#### [ PowerShell ]

   ```
   aws iam create-policy `
     --policy-name MyGreengrassV2ComponentArtifactPolicy `
     --policy-document file://component-artifact-policy.json
   ```

------

   從輸出中的政策中繼資料複製政策 Amazon Resource Name (ARN)。您可以在下一個步驟中使用此 ARN 將此政策連接至核心裝置角色。

1. 執行下列命令，將政策連接至核心裝置角色。以您在執行 AWS IoT Greengrass Core 軟體時指定的角色名稱取代 *GreengrassV2TokenExchangeRole*。然後，將政策 ARN 取代為上一個步驟的 ARN。

------
#### [ Linux or Unix ]

   ```
   aws iam attach-role-policy \
     --role-name GreengrassV2TokenExchangeRole \
     --policy-arn arn:aws:iam::123456789012:policy/MyGreengrassV2ComponentArtifactPolicy
   ```

------
#### [ Windows Command Prompt (CMD) ]

   ```
   aws iam attach-role-policy ^
     --role-name GreengrassV2TokenExchangeRole ^
     --policy-arn arn:aws:iam::123456789012:policy/MyGreengrassV2ComponentArtifactPolicy
   ```

------
#### [ PowerShell ]

   ```
   aws iam attach-role-policy `
     --role-name GreengrassV2TokenExchangeRole `
     --policy-arn arn:aws:iam::123456789012:policy/MyGreengrassV2ComponentArtifactPolicy
   ```

------

   如果命令沒有輸出，則會成功，而且您的核心裝置可以存取您上傳至此 S3 儲存貯體的成品。

# 安裝程式佈建資源的最低 IAM 政策
<a name="provision-minimal-iam-policy"></a>

安裝 AWS IoT Greengrass Core 軟體時，您可以佈建必要的 AWS 資源，例如裝置的 AWS IoT 物件和 IAM 角色。您也可以將本機開發工具部署至裝置。安裝程式需要 AWS 登入資料，才能在您的 中執行這些動作 AWS 帳戶。如需詳細資訊，請參閱[安裝 AWS IoT Greengrass Core 軟體](install-greengrass-core-v2.md)。

下列範例政策包含安裝程式佈建這些資源所需的最低動作集。如果您指定安裝程式的 `--provision` 引數，則需要這些許可。將 *account-id* 取代為您的 AWS 帳戶 ID，並將 *GreengrassV2TokenExchangeRole* 取代為您使用`--tes-role-name`[安裝程式引數](configure-installer.md)指定的字符交換角色名稱。

**注意**  
只有在您指定安裝程式的 `--deploy-dev-tools` 引數時，才需要`DeployDevTools`政策陳述式。

------
#### [ Greengrass nucleus v2.5.0 and later ]

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "CreateTokenExchangeRole",
            "Effect": "Allow",
            "Action": [
                "iam:AttachRolePolicy",
                "iam:CreatePolicy",
                "iam:CreateRole",
                "iam:GetPolicy",
                "iam:GetRole",
                "iam:PassRole"
            ],
            "Resource": [
                "arn:aws:iam::123456789012:role/GreengrassV2TokenExchangeRole",
                "arn:aws:iam::123456789012:policy/GreengrassV2TokenExchangeRoleAccess",
                "arn:aws:iam::aws:policy/GreengrassV2TokenExchangeRoleAccess"
            ]
        },
        {
            "Sid": "CreateIoTResources",
            "Effect": "Allow",
            "Action": [
                "iot:AddThingToThingGroup",
                "iot:AttachPolicy",
                "iot:AttachThingPrincipal",
                "iot:CreateKeysAndCertificate",
                "iot:CreatePolicy",
                "iot:CreateRoleAlias",
                "iot:CreateThing",
                "iot:CreateThingGroup",
                "iot:DescribeEndpoint",
                "iot:DescribeRoleAlias",
                "iot:DescribeThingGroup",
                "iot:GetPolicy"
            ],
            "Resource": "*"
        },
        {
            "Sid": "DeployDevTools",
            "Effect": "Allow",
            "Action": [
                "greengrass:CreateDeployment",
                "iot:CancelJob",
                "iot:CreateJob",
                "iot:DeleteThingShadow",
                "iot:DescribeJob",
                "iot:DescribeThing",
                "iot:DescribeThingGroup",
                "iot:GetThingShadow",
                "iot:UpdateJob",
                "iot:UpdateThingShadow"
            ],
            "Resource": "*"
        }
    ]
}
```

------

------
#### [ Earlier than v2.5.0 ]

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "CreateTokenExchangeRole",
            "Effect": "Allow",
            "Action": [
                "iam:AttachRolePolicy",
                "iam:CreatePolicy",
                "iam:CreateRole",
                "iam:GetPolicy",
                "iam:GetRole",
                "iam:PassRole"
            ],
            "Resource": [
            "arn:aws:iam::123456789012:role/GreengrassV2TokenExchangeRole",
    "arn:aws:iam::123456789012:policy/GreengrassV2TokenExchangeRoleAccess",
                "arn:aws:iam::aws:policy/GreengrassV2TokenExchangeRoleAccess"
            ]
        },
        {
            "Sid": "CreateIoTResources",
            "Effect": "Allow",
            "Action": [
                "iot:AddThingToThingGroup",
                "iot:AttachPolicy",
                "iot:AttachThingPrincipal",
                "iot:CreateKeysAndCertificate",
                "iot:CreatePolicy",
                "iot:CreateRoleAlias",
                "iot:CreateThing",
                "iot:CreateThingGroup",
                "iot:DescribeEndpoint",
                "iot:DescribeRoleAlias",
                "iot:DescribeThingGroup",
                "iot:GetPolicy"
            ],
            "Resource": "*"
        },
        {
            "Sid": "DeployDevTools",
            "Effect": "Allow",
            "Action": [
                "greengrass:CreateDeployment",
                "iot:CancelJob",
                "iot:CreateJob",
                "iot:DeleteThingShadow",
                "iot:DescribeJob",
                "iot:DescribeThing",
                "iot:DescribeThingGroup",
                "iot:GetThingShadow",
                "iot:UpdateJob",
                "iot:UpdateThingShadow"
            ],
            "Resource": "*"
        }
    ]
}
```

------

------

# Greengrass 服務角色
<a name="greengrass-service-role"></a>

<a name="greengrass-service-role-intro"></a>Greengrass 服務角色是 AWS Identity and Access Management (IAM) 服務角色，授權 代表您 AWS IoT Greengrass 存取來自 AWS 服務的資源。此角色可讓 AWS IoT Greengrass 驗證用戶端裝置的身分，並管理核心裝置連線資訊。

**注意**  
AWS IoT Greengrass V1 也會使用此角色來執行基本任務。如需詳細資訊，請參閱《 *AWS IoT Greengrass V1 開發人員指南*》中的 [Greengrass 服務角色](https://docs.aws.amazon.com/greengrass/v1/developerguide/service-role.html)。

若要允許 AWS IoT Greengrass 存取您的 資源，Greengrass 服務角色必須與 相關聯， AWS 帳戶 並指定 AWS IoT Greengrass 為信任的實體。此角色必須包含 [AWSGreengrassResourceAccessRolePolicy](https://console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/service-role/AWSGreengrassResourceAccessRolePolicy) 受管政策或自訂政策，該政策會為您使用 AWS IoT Greengrass 的功能定義同等許可。 AWS 會維護此政策，此政策會定義 AWS IoT Greengrass 用於存取 AWS 資源的一組許可。如需詳細資訊，請參閱[AWS 受管政策：AWSGreengrassResourceAccessRolePolicy](security-iam-aws-managed-policies.md#aws-managed-policies-AWSGreengrassResourceAccessRolePolicy)。

您可以重複使用相同的 Greengrass 服務角色 AWS 區域，但必須在您使用的每個 AWS 區域 中將其與您的帳戶建立關聯 AWS IoT Greengrass。如果服務角色未在目前的 中設定 AWS 區域，核心裝置將無法驗證用戶端裝置，也無法更新連線資訊。

下列各節說明如何使用 AWS 管理主控台 或 建立和管理 Greengrass 服務角色 AWS CLI。

**Topics**
+ [管理 Greengrass 服務角色 （主控台）](#manage-greengrass-service-role-console)
+ [管理 Greengrass 服務角色 (CLI)](#manage-service-role-cli)
+ [另請參閱](#service-role-see-also)

**注意**  
除了授權服務層級存取的服務角色之外，您還可以將*權杖交換角色*指派給 Greengrass 核心裝置。字符交換角色是獨立的 IAM 角色，可控制核心裝置上的 Greengrass 元件和 Lambda 函數如何存取 AWS 服務。如需詳細資訊，請參閱[授權核心裝置與 AWS 服務互動](device-service-role.md)。

## 管理 Greengrass 服務角色 （主控台）
<a name="manage-greengrass-service-role-console"></a>

 AWS IoT 主控台可讓您輕鬆管理您的 Greengrass 服務角色。例如，當您設定核心裝置的用戶端裝置探索時，主控台會檢查 是否 AWS 帳戶 連接到目前 中的 Greengrass 服務角色 AWS 區域。如果未連接，主控台可以為您建立和設定服務角色。如需詳細資訊，請參閱[建立 Greengrass 服務角色 (主控台)](#create-greengrass-service-role-console)。

您可以使用 主控台執行下列角色管理任務：

**Topics**
+ [尋找您的 Greengrass 服務角色 (主控台)](#get-greengrass-service-role-console)
+ [建立 Greengrass 服務角色 (主控台)](#create-greengrass-service-role-console)
+ [變更 Greengrass 服務角色 (主控台)](#update-greengrass-service-role-console)
+ [分離 Greengrass 服務角色 (主控台)](#remove-greengrass-service-role-console)

**注意**  
登入主控台的使用者必須擁有可檢視、建立或變更服務角色的許可。

### 尋找您的 Greengrass 服務角色 (主控台)
<a name="get-greengrass-service-role-console"></a>

使用下列步驟來尋找目前 AWS IoT Greengrass 中使用的服務角色 AWS 區域。

1. <a name="open-iot-console"></a>導覽至 [AWS IoT 主控台](https://console.aws.amazon.com/iot)。

1. <a name="open-iot-settings"></a>在導覽窗格中，選擇**設定**。

1. 捲動至 **Greengrass service role (Greengrass 服務角色)** 區段，查看您的服務角色及其政策。

   如果您沒有看到服務角色，主控台可以為您建立或設定。如需詳細資訊，請參閱[建立 Greengrass 服務角色](#create-greengrass-service-role-console)。

### 建立 Greengrass 服務角色 (主控台)
<a name="create-greengrass-service-role-console"></a>

主控台可以為您建立和設定預設的 Greengrass 服務角色。這個角色具有以下屬性：


| 屬性 | Value | 
| --- | --- | 
| 名稱 | Greengrass\$1ServiceRole | 
| 信任實體 | AWS service: greengrass | 
| 政策 | [AWSGreengrassResourceAccessRolePolicy (AWSGreengrassResourceAccessRolePolicy)](https://console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/service-role/AWSGreengrassResourceAccessRolePolicy) | 

**注意**  
如果您使用[AWS IoT Greengrass V1 裝置設定指令碼](https://docs.aws.amazon.com/greengrass/v1/developerguide/quick-start.html)建立此角色，則角色名稱為 `GreengrassServiceRole_random-string`。

當您設定核心裝置的用戶端裝置探索時，主控台會檢查 Greengrass 服務角色是否與目前 AWS 帳戶 中的 相關聯 AWS 區域。如果沒有，主控台會提示您允許 代表您 AWS IoT Greengrass 讀取和寫入 AWS 服務。

如果您授予許可，主控台會檢查 `Greengrass_ServiceRole`中是否存在名為 的角色 AWS 帳戶。
+ 如果角色存在，主控台會將服務角色連接到目前 AWS 帳戶 中的 AWS 區域。
+ 如果角色不存在，主控台會建立預設 Greengrass 服務角色，並將其連接到目前 AWS 帳戶 中的 AWS 區域。

**注意**  
如果您想要使用自訂角色政策建立服務角色，請使用 IAM 主控台來建立或修改角色。如需詳細資訊，請參閱[《IAM 使用者指南》中的建立角色以將許可委派給 AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html)[或修改角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_modify.html)。 **請確定角色會授與與您所使用功能和資源之 `AWSGreengrassResourceAccessRolePolicy` 受管政策相同的許可。我們建議您也在信任政策中包含 `aws:SourceArn`和 `aws:SourceAccount`全域條件內容金鑰，以協助防止*混淆代理人*安全問題。條件內容索引鍵會限制存取，只允許來自指定帳戶和 Greengrass 工作區的這些請求。如需有關混淆代理人問題的詳細資訊，請參閱 [預防跨服務混淆代理人](cross-service-confused-deputy-prevention.md)。  
如果您建立服務角色，請返回 AWS IoT 主控台，並將該角色連接到您的 AWS 帳戶。您可以在**設定**頁面上的 **Greengrass 服務角色**下執行此操作。

### 變更 Greengrass 服務角色 (主控台)
<a name="update-greengrass-service-role-console"></a>

使用下列程序選擇不同的 Greengrass 服務角色，以在主控台 AWS 區域 目前選取的 AWS 帳戶 中連接至您的 。

1. <a name="open-iot-console"></a>導覽至 [AWS IoT 主控台](https://console.aws.amazon.com/iot)。

1. <a name="open-iot-settings"></a>在導覽窗格中，選擇**設定**。

1. 在 **Greengrass 服務角色**下，選擇**變更角色**。

   **更新 Greengrass 服務角色**對話方塊隨即開啟，並顯示 中定義為 AWS IoT Greengrass 信任實體 AWS 帳戶 的 IAM 角色。

1. 選擇要連接的 Greengrass 服務角色。

1. 選擇**連接角色**。

### 分離 Greengrass 服務角色 (主控台)
<a name="remove-greengrass-service-role-console"></a>

使用下列程序，在目前的 中將 Greengrass 服務角色從 AWS 您的帳戶分離 AWS 區域。這會撤銷 AWS IoT Greengrass 存取目前 AWS 服務的權限 AWS 區域。

**重要**  
分離服務角色可能會中斷作用中的操作。

1. <a name="open-iot-console"></a>導覽至 [AWS IoT 主控台](https://console.aws.amazon.com/iot)。

1. <a name="open-iot-settings"></a>在導覽窗格中，選擇**設定**。

1. 在 **Greengrass 服務角色**下，選擇**分離角色**。

1. 在確認對話方塊中，選擇 **Detach** (分離)。

**注意**  
如果您不再需要該角色，您可以在 IAM 主控台中刪除該角色。如需詳細資訊，請參閱 *IAM 使用者指南*中的[刪除角色或執行個體描述檔](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_delete.html)。  
其他角色可能允許 AWS IoT Greengrass 存取您的 資源。若要尋找允許 代表您 AWS IoT Greengrass 擔任許可的所有角色，請在 IAM 主控台的角色****頁面上，尋找包含**AWS 服務的角色：信任實體欄中的 greengrass**。 ****

## 管理 Greengrass 服務角色 (CLI)
<a name="manage-service-role-cli"></a>

在下列程序中，我們假設 AWS Command Line Interface 已安裝並設定為使用您的 AWS 帳戶。如需詳細資訊，請參閱*AWS Command Line Interface 《 使用者指南*》中的[安裝、更新和解除安裝 AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) 和[設定 AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)。

您可以使用 AWS CLI 執行下列角色管理任務：

**Topics**
+ [取得 Greengrass 服務角色 (CLI)](#get-service-role)
+ [建立 Greengrass 服務角色 (CLI)](#create-service-role)
+ [移除 Greengrass 服務角色 (CLI)](#remove-service-role)

### 取得 Greengrass 服務角色 (CLI)
<a name="get-service-role"></a>

使用下列程序來了解 Greengrass 服務角色是否與 AWS 帳戶 中的 相關聯 AWS 區域。
+ 取得服務角色。將*區域*取代為您的 AWS 區域 （例如，`us-west-2`)。

  ```
  aws greengrassv2 get-service-role-for-account --region region
  ```

  如果 Greengrass 服務角色已與您的帳戶建立關聯，則請求會傳回下列角色中繼資料。

  ```
  {
    "associatedAt": "timestamp",
    "roleArn": "arn:aws:iam::account-id:role/path/role-name"
  }
  ```

  如果請求未傳回角色中繼資料，則必須建立服務角色 （如果不存在），並將其與 中的帳戶建立關聯 AWS 區域。

### 建立 Greengrass 服務角色 (CLI)
<a name="create-service-role"></a>

使用下列步驟來建立角色，並將其與您的 建立關聯 AWS 帳戶。

**使用 IAM 建立服務角色**

1. 使用允許 AWS IoT Greengrass 擔任角色的信任政策來建立角色。此範例會建立名為 `Greengrass_ServiceRole` 的角色，但您可以使用不同的名稱。我們建議您也在信任政策中包含 `aws:SourceArn`和 `aws:SourceAccount`全域條件內容金鑰，以協助防止*混淆代理人*安全問題。條件內容索引鍵會限制存取，只允許來自指定帳戶和 Greengrass 工作區的這些請求。如需有關混淆代理人問題的詳細資訊，請參閱 [預防跨服務混淆代理人](cross-service-confused-deputy-prevention.md)。

------
#### [ Linux or Unix ]

   ```
   aws iam create-role --role-name Greengrass_ServiceRole --assume-role-policy-document '{
     "Version": "2012-10-17",		 	 	 
     "Statement": [
       {
         "Effect": "Allow",
         "Principal": {
           "Service": "greengrass.amazonaws.com"
         },
         "Action": "sts:AssumeRole",
         "Condition": {
           "ArnLike": {
             "aws:SourceArn": "arn:aws:greengrass:region:account-id:*"
           },
           "StringEquals": {
             "aws:SourceAccount": "account-id"
           }
         }
       }
     ]
   }'
   ```

------
#### [ Windows Command Prompt (CMD) ]

   ```
   aws iam create-role --role-name Greengrass_ServiceRole --assume-role-policy-document "{\"Version\":\"2012-10-17\",		 	 	 \"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"greengrass.amazonaws.com\"},\"Action\":\"sts:AssumeRole\",\"Condition\":{\"ArnLike\":{\"aws:SourceArn\":\"arn:aws:greengrass:region:account-id:*\"},\"StringEquals\":{\"aws:SourceAccount\":\"account-id\"}}}]}"
   ```

------
#### [ PowerShell ]

   ```
   aws iam create-role --role-name Greengrass_ServiceRole --assume-role-policy-document '{
     "Version": "2012-10-17",		 	 	 
     "Statement": [
       {
         "Effect": "Allow",
         "Principal": {
           "Service": "greengrass.amazonaws.com"
         },
         "Action": "sts:AssumeRole",
         "Condition": {
           "ArnLike": {
             "aws:SourceArn": "arn:aws:greengrass:region:account-id:*"
           },
           "StringEquals": {
             "aws:SourceAccount": "account-id"
           }
         }
       }
     ]
   }'
   ```

------

1. 從輸出中的角色中繼資料，複製角色 ARN。您使用 ARN 將角色與您的帳戶相關聯。

1. 將 `AWSGreengrassResourceAccessRolePolicy` 政策連接到角色。

   ```
   aws iam attach-role-policy --role-name Greengrass_ServiceRole --policy-arn arn:aws:iam::aws:policy/service-role/AWSGreengrassResourceAccessRolePolicy
   ```

**將服務角色與 建立關聯 AWS 帳戶**
+ 將角色與您的帳戶相關聯。將 *role-arn* 取代為服務角色 ARN，並將 *region* 取代為 your AWS 區域 （例如，`us-west-2`)。

  ```
  aws greengrassv2 associate-service-role-to-account --role-arn role-arn --region region
  ```

  如果成功，請求會傳回下列回應。

  ```
  {
    "associatedAt": "timestamp"
  }
  ```

### 移除 Greengrass 服務角色 (CLI)
<a name="remove-service-role"></a>

使用下列步驟取消 Greengrass 服務角色與 的關聯 AWS 帳戶。
+ 將服務角色與您的帳戶取消關聯。將*區域*取代為您的 AWS 區域 （例如，`us-west-2`)。

  ```
  aws greengrassv2 disassociate-service-role-from-account --region region
  ```

  如果成功，會傳回下列回應。

  ```
  {
    "disassociatedAt": "timestamp"
  }
  ```
**注意**  
如果您未在任何 中使用服務角色，您應該將其刪除 AWS 區域。首先，使用 [https://docs.aws.amazon.com/cli/latest/reference/iam/delete-role-policy.html](https://docs.aws.amazon.com/cli/latest/reference/iam/delete-role-policy.html) 將 `AWSGreengrassResourceAccessRolePolicy` 受管政策從角色中分離，然後使用 [https://docs.aws.amazon.com/cli/latest/reference/iam/delete-role.html](https://docs.aws.amazon.com/cli/latest/reference/iam/delete-role.html) 來刪除角色。如需詳細資訊，請參閱 *IAM 使用者指南*中的[刪除角色或執行個體描述檔](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_delete.html)。

## 另請參閱
<a name="service-role-see-also"></a>
+ 《*IAM 使用者指南*》中的[建立角色以將許可委派給 AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html) 
+ *IAM 使用者指南*中的[修改角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_modify.html) 
+ 《*IAM 使用者指南*》中的[刪除角色或執行個體描述](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_delete.html)檔
+ AWS IoT Greengrass 命令*AWS CLI 參考中的 命令*
  + [associate-service-role-to-account](https://docs.aws.amazon.com/cli/latest/reference/greengrassv2/associate-service-role-to-account.html)
  + [disassociate-service-role-from-account](https://docs.aws.amazon.com/cli/latest/reference/greengrassv2/disassociate-service-role-from-account.html)
  + [get-service-role-for-account](https://docs.aws.amazon.com/cli/latest/reference/greengrassv2/get-service-role-for-account.html)
+ 《 命令*AWS CLI 參考》中的 IAM 命令*
  + [attach-role-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/attach-role-policy.html)
  + [create-role](https://docs.aws.amazon.com/cli/latest/reference/iam/create-role.html)
  + [delete-role](https://docs.aws.amazon.com/cli/latest/reference/iam/delete-role.html)
  + [delete-role-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/delete-role-policy.html)

# AWS 的 受管政策 AWS IoT Greengrass
<a name="security-iam-aws-managed-policies"></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)。

**Topics**
+ [AWS 受管政策：AWSGreengrassFullAccess](#aws-managed-policies-AWSGreengrassFullAccess)
+ [AWS 受管政策：AWSGreengrassReadOnlyAccess](#aws-managed-policies-AWSGreengrassReadOnlyAccess)
+ [AWS 受管政策：AWSGreengrassResourceAccessRolePolicy](#aws-managed-policies-AWSGreengrassResourceAccessRolePolicy)
+ [AWS IoT Greengrass AWS 受管政策的更新](#aws-managed-policy-updates)

## AWS 受管政策：AWSGreengrassFullAccess
<a name="aws-managed-policies-AWSGreengrassFullAccess"></a>

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

此政策會授予管理許可，允許委託人完整存取所有 AWS IoT Greengrass 動作。

**許可詳細資訊**

此政策包含以下許可：
+ `greengrass` – 允許主體完整存取所有 AWS IoT Greengrass 動作。

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

****  

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

------

## AWS 受管政策：AWSGreengrassReadOnlyAccess
<a name="aws-managed-policies-AWSGreengrassReadOnlyAccess"></a>

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

此政策授予唯讀許可，允許委託人檢視但不修改其中的資訊 AWS IoT Greengrass。例如，具有這些許可的主體可以檢視部署到 Greengrass 核心裝置的元件清單，但無法建立部署來變更在該裝置上執行的元件。

**許可詳細資訊**

此政策包含以下許可：
+ `greengrass` – 允許主體執行傳回項目清單或項目詳細資訊的動作。這包括以 `List`或 開頭的 API 操作`Get`。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "greengrass:List*",
                "greengrass:Get*"
            ],
            "Resource": "*"
        }
    ]
}
```

------

## AWS 受管政策：AWSGreengrassResourceAccessRolePolicy
<a name="aws-managed-policies-AWSGreengrassResourceAccessRolePolicy"></a>

您可以將`AWSGreengrassResourceAccessRolePolicy`政策連接至 IAM 實體。 AWS IoT Greengrass 也會將此政策連接至允許 代表您 AWS IoT Greengrass 執行動作的服務角色。如需詳細資訊，請參閱[Greengrass 服務角色](greengrass-service-role.md)。

此政策授予管理許可， AWS IoT Greengrass 允許 執行基本任務，例如擷取 Lambda 函數、管理 AWS IoT 裝置影子，以及驗證 Greengrass 用戶端裝置。

**許可詳細資訊**

此政策包含以下許可。
+ `greengrass` – 管理 Greengrass 資源。
+ `iot` (`*Shadow`) – 管理名稱中具有下列特殊識別符的 AWS IoT 陰影。需要這些許可， AWS IoT Greengrass 才能與核心裝置通訊。
  + `*-gci` – AWS IoT Greengrass 使用此影子來存放核心裝置連線資訊，讓用戶端裝置可以探索並連線至核心裝置。
  + `*-gcm` – AWS IoT Greengrass V1 使用此影子來通知核心裝置 Greengrass 群組的憑證授權單位 (CA) 憑證已輪換。
  + `*-gda` – AWS IoT Greengrass V1 使用此影子來通知核心裝置部署。
  + `GG_*` – 未使用。
+ `iot` (`DescribeThing` 和 `DescribeCertificate`) – 擷取 AWS IoT 物件和憑證的相關資訊。需要這些許可， AWS IoT Greengrass 才能驗證連線至核心裝置的用戶端裝置。如需詳細資訊，請參閱[與本機 IoT 裝置互動](interact-with-local-iot-devices.md)。
+ `lambda` – 擷取 AWS Lambda 函數的相關資訊。需要此許可，V AWS IoT Greengrass V1 才能將 Lambda 函數部署到 Greengrass 核心。如需詳細資訊，請參閱《*AWS IoT Greengrass V1 開發人員指南*》中的[在 AWS IoT Greengrass 核心上執行 Lambda 函數](https://docs.aws.amazon.com/greengrass/v1/developerguide/lambda-functions.html)。
+ `secretsmanager` – 擷取名稱開頭為 之 AWS Secrets Manager 秘密的值`greengrass-`。需要此許可，V AWS IoT Greengrass V1 才能將 Secrets Manager 秘密部署到 Greengrass 核心。如需詳細資訊，請參閱《*AWS IoT Greengrass V1 開發人員指南*》中的[將秘密部署至 AWS IoT Greengrass 核心](https://docs.aws.amazon.com/greengrass/v1/developerguide/secrets.html)。
+ `s3` – 從名稱包含 `greengrass`或 的 S3 儲存貯體擷取檔案物件`sagemaker`。需要這些許可，V AWS IoT Greengrass V1 才能部署存放在 S3 儲存貯體中的機器學習資源。如需詳細資訊，請參閱《*AWS IoT Greengrass V1 開發人員指南*》中的[機器學習資源](https://docs.aws.amazon.com/greengrass/v1/developerguide/ml-inference.html#ml-resources)。
+ `sagemaker` – 擷取 Amazon SageMaker AI 機器學習推論模型的相關資訊。需要此許可，V AWS IoT Greengrass V1 才能將 ML 模型部署到 Greengrass 核心。如需詳細資訊，請參閱《*AWS IoT Greengrass V1 開發人員指南*》中的[執行機器學習推論](https://docs.aws.amazon.com/greengrass/v1/developerguide/ml-inference.html)。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowGreengrassAccessToShadows",
            "Action": [
                "iot:DeleteThingShadow",
                "iot:GetThingShadow",
                "iot:UpdateThingShadow"
            ],
            "Effect": "Allow",
            "Resource": [
                "arn:aws:iot:*:*:thing/GG_*",
                "arn:aws:iot:*:*:thing/*-gcm",
                "arn:aws:iot:*:*:thing/*-gda",
                "arn:aws:iot:*:*:thing/*-gci"
            ]
        },
        {
            "Sid": "AllowGreengrassToDescribeThings",
            "Action": [
                "iot:DescribeThing"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:iot:*:*:thing/*"
        },
        {
            "Sid": "AllowGreengrassToDescribeCertificates",
            "Action": [
                "iot:DescribeCertificate"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:iot:*:*:cert/*"
        },
        {
            "Sid": "AllowGreengrassToCallGreengrassServices",
            "Action": [
                "greengrass:*"
            ],
            "Effect": "Allow",
            "Resource": "*"
        },
        {
            "Sid": "AllowGreengrassToGetLambdaFunctions",
            "Action": [
                "lambda:GetFunction",
                "lambda:GetFunctionConfiguration"
            ],
            "Effect": "Allow",
            "Resource": "*"
        },
        {
            "Sid": "AllowGreengrassToGetGreengrassSecrets",
            "Action": [
                "secretsmanager:GetSecretValue"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:secretsmanager:*:*:secret:greengrass-*"
        },
        {
            "Sid": "AllowGreengrassAccessToS3Objects",
            "Action": [
                "s3:GetObject"
            ],
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::*Greengrass*",
                "arn:aws:s3:::*GreenGrass*",
                "arn:aws:s3:::*greengrass*",
                "arn:aws:s3:::*Sagemaker*",
                "arn:aws:s3:::*SageMaker*",
                "arn:aws:s3:::*sagemaker*"
            ]
        },
        {
            "Sid": "AllowGreengrassAccessToS3BucketLocation",
            "Action": [
                "s3:GetBucketLocation"
            ],
            "Effect": "Allow",
            "Resource": "*"
        },
        {
            "Sid": "AllowGreengrassAccessToSageMakerTrainingJobs",
            "Action": [
                "sagemaker:DescribeTrainingJob"
            ],
            "Effect": "Allow",
            "Resource": [
                "arn:aws:sagemaker:*:*:training-job/*"
            ]
        }
    ]
}
```

------

## AWS IoT Greengrass AWS 受管政策的更新
<a name="aws-managed-policy-updates"></a>

從此服務開始追蹤這些變更起 AWS IoT Greengrass ，您可以檢視 AWS 受管政策更新的詳細資訊。如需此頁面變更的自動提醒，請訂閱 [AWS IoT Greengrass V2 文件歷史記錄頁面上](document-history.md)的 RSS 摘要。


| 變更 | 描述 | Date | 
| --- | --- | --- | 
|  AWS IoT Greengrass 開始追蹤變更  |  AWS IoT Greengrass 已開始追蹤其 AWS 受管政策的變更。  |  2021 年 7 月 2 日  | 

# 預防跨服務混淆代理人
<a name="cross-service-confused-deputy-prevention"></a>

混淆代理人問題屬於安全性議題，其中沒有執行動作許可的實體可以強制具有更多許可的實體執行該動作。在 中 AWS，跨服務模擬可能會導致混淆代理人問題。在某個服務 (*呼叫服務*) 呼叫另一個服務 (*被呼叫服務*) 時，可能會發生跨服務模擬。可以操縱呼叫服務來使用其許可，以其不應有存取許可的方式對其他客戶的資源採取動作。為了預防這種情況， AWS 提供的工具可協助您保護所有服務的資料，而這些服務主體已獲得您帳戶中資源的存取權。

我們建議在資源政策中使用 [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcearn](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcearn)和 [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceaccount](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceaccount)全域條件內容索引鍵，以限制將另一個 服務 AWS IoT Greengrass 提供給資源的許可。如果同時使用全域條件內容金鑰，則在相同政策陳述式中使用 `aws:SourceAccount` 值和 `aws:SourceArn` 值中的帳戶時，必須使用相同的帳戶 ID。

的值`aws:SourceArn`必須是與`sts:AssumeRole`請求相關聯的 Greengrass 客戶資源。

防範混淆代理人問題最有效的方法，是使用 `aws:SourceArn` 全域條件內容金鑰，以及資源的完整 ARN。如果不知道資源的完整 ARN，或者如果您指定了多個資源，請使用 `aws:SourceArn` 全域條件內容金鑰，同時使用萬用字元 (`*`) 表示 ARN 的未知部分。例如 `arn:aws:greengrass::account-id:*`。

如需使用 `aws:SourceArn`和 `aws:SourceAccount`全域條件內容索引鍵的政策範例，請參閱 [建立 Greengrass 服務角色](greengrass-service-role.md#create-service-role)。

# 對 的身分和存取問題進行故障診斷 AWS IoT Greengrass
<a name="security_iam_troubleshoot"></a>

使用以下資訊來協助您診斷和修正使用 AWS IoT Greengrass 和 IAM 時可能遇到的常見問題。

**Topics**
+ [我未獲授權在 中執行動作 AWS IoT Greengrass](#security_iam_troubleshoot-no-permissions)
+ [我未獲授權執行 iam:PassRole](#security_iam_troubleshoot-passrole)
+ [我是管理員，想要允許其他人存取 AWS IoT Greengrass](#security_iam_troubleshoot-admin-delegate)
+ [我想要允許 以外的人員 AWS 帳戶 存取我的 AWS IoT Greengrass 資源](#security_iam_troubleshoot-cross-account-access)

如需一般的故障診斷協助，請參閱 [故障診斷 AWS IoT Greengrass V2](troubleshooting.md)。

## 我未獲授權在 中執行動作 AWS IoT Greengrass
<a name="security_iam_troubleshoot-no-permissions"></a>

若您收到指出您未獲授權執行動作的錯誤，您必須聯絡管理員以取得協助。您的管理員是提供您使用者名稱和密碼的人員。

當 IAM `mateojackson` 使用者嘗試檢視核心裝置的詳細資訊，但沒有`greengrass:GetCoreDevice`許可時，會發生下列範例錯誤。

```
User: arn:aws:iam::123456789012:user/mateojackson is not authorized to perform: greengrass:GetCoreDevice on resource: arn:aws:greengrass:us-west-2:123456789012:coreDevices/MyGreengrassCore
```

在此情況下，Mateo 會請求管理員更新他的政策，允許他使用 `arn:aws:greengrass:us-west-2:123456789012:coreDevices/MyGreengrassCore` 動作存取 `greengrass:GetCoreDevice` 資源。

以下是使用 時可能遇到的一般 IAM 問題 AWS IoT Greengrass。

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

如果您收到錯誤，告知您未獲授權執行 `iam:PassRole` 動作，您的政策必須更新，允許您將角色傳遞給 AWS IoT Greengrass。

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

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

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

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

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

## 我是管理員，想要允許其他人存取 AWS IoT Greengrass
<a name="security_iam_troubleshoot-admin-delegate"></a>

若要允許其他人存取 AWS IoT Greengrass，您必須將許可授予需要存取的人員或應用程式。如果您使用 AWS IAM Identity Center 管理人員和應用程式，您可以將許可集指派給使用者或群組，以定義其存取層級。許可集會自動建立 IAM 政策，並將其指派給與該人員或應用程式相關聯的 IAM 角色。如需詳細資訊，請參閱*AWS IAM Identity Center 《 使用者指南*》中的[許可集](https://docs.aws.amazon.com/singlesignon/latest/userguide/permissionsetsconcept.html)。

如果您不是使用 IAM Identity Center，則必須為需要存取的人員或應用程式建立 IAM 實體 （使用者或角色）。您接著必須將政策連接到實體，在 AWS IoT Greengrass中授予他們正確的許可。授予許可後，請將登入資料提供給使用者或應用程式開發人員。他們將使用這些登入資料來存取 AWS。若要進一步了解如何建立 IAM 使用者、群組、政策和許可，請參閱《IAM **[使用者指南》中的 IAM 身分](https://docs.aws.amazon.com/IAM/latest/UserGuide/id.html)[和政策和許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html)。

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

您可以建立 IAM 角色，讓其他帳戶中的使用者或您組織外部的人員可用來存取您的 AWS 資源。您可以指定要允許哪些信任對象擔任該角色。如需詳細資訊，請參閱《[IAM 使用者指南》中的提供存取權給您 AWS 帳戶 擁有的另一個 IAM 使用者](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_aws-accounts.html)，以及[提供存取權給第三方 AWS 帳戶擁有的 ](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_third-party.html)。 **

AWS IoT Greengrass 不支援以資源型政策或存取控制清單 (ACLs) 為基礎的跨帳戶存取。