

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

# Amazon Lex V2 如何與 IAM 搭配使用
<a name="security_iam_service-with-iam"></a>

在您使用 IAM 管理 Amazon Lex V2 的存取權之前，請先了解哪些 IAM 功能可與 Amazon Lex V2 搭配使用。






**您可以搭配 Amazon Lex V2 使用的 IAM 功能**  

| IAM 功能 | Amazon Lex V2 支援 | 
| --- | --- | 
| [身分型政策](#security_iam_service-with-iam-id-based-policies) | *是* | 
| [資源型政策](#security_iam_service-with-iam-resource-based-policies) | *是* | 
| [政策動作](#security_iam_service-with-iam-id-based-policies-actions) | *是* | 
| [政策資源](#security_iam_service-with-iam-id-based-policies-resources) | *是* | 
| [政策條件索引鍵](#security_iam_service-with-iam-id-based-policies-conditionkeys) | *否* | 
| [ACL](#security_iam_service-with-iam-acls) | *否* | 
| [ABAC (政策中的標籤)](#security_iam_service-with-iam-tags) | *是* | 
| [臨時憑證](#security_iam_service-with-iam-roles-tempcreds) | *否* | 
| [主體許可](#security_iam_service-with-iam-principal-permissions) | *是* | 
| [服務角色](#security_iam_service-with-iam-roles-service) | *是* | 
| [服務連結角色](#security_iam_service-with-iam-roles-service-linked) | *部分* | 

若要全面了解 Amazon Lex V2 和其他 AWS 服務如何與大多數 IAM 功能搭配使用，請參閱《*IAM 使用者指南*》中的[可與 IAM 搭配使用的 AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)。

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

**支援以身分為基礎的政策：***是*

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

使用 IAM 身分型政策，您可以指定允許或拒絕的動作和資源，以及在何種條件下允許或拒絕動作。如要了解您在 JSON 政策中使用的所有元素，請參閱《*IAM 使用者指南*》中的 [IAM JSON 政策元素參考](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html)。

### Amazon Lex V2 的身分型政策範例
<a name="security_iam_service-with-iam-id-based-policies-examples"></a>



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

## Amazon Lex V2 內的資源型政策
<a name="security_iam_service-with-iam-resource-based-policies"></a>

**支援以資源為基礎的政策：***是*

資源型政策是附加到資源的 JSON 政策文件。資源型政策的最常見範例是 IAM 角色信任政策和 Amazon S3 儲存貯體政策。在支援資源型政策的服務中，服務管理員可以使用它們來控制對特定資源的存取權限。對於附加政策的資源，政策會定義指定的主體可以對該資源執行的動作以及在何種條件下執行的動作。您必須在資源型政策中[指定主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html)。委託人可以包含使用者、角色、聯合身分使用者或 AWS 服務。

您無法搭配 Amazon Lex V2 使用跨帳戶或跨區域政策。如果您為具有跨帳戶或跨區域 ARN 的資源建立政策，Amazon Lex V2 會傳回錯誤。

Amazon Lex V2 服務支援稱為*機器人*政策和*機器人別名*政策的資源型政策，這些政策會連接到機器人或機器人別名。這些政策定義哪些主體可以在機器人或機器人別名上執行動作。

動作只能用於特定資源。例如，`UpdateBot`動作只能用於機器人資源，`UpdateBotAlias`動作只能用於機器人別名資源。如果您在政策中指定無法用於政策中指定資源的動作，Amazon Lex V2 會傳回錯誤。如需動作清單及其可使用的資源，請參閱下表。


| Action | 支援以資源為基礎的政策 | 資源 | 
| --- | --- | --- | 
| BuildBotLocale | 支援 | BotId | 
| CreateBot | 否 |   | 
| CreateBotAlias | 否 |   | 
| CreateBotChannel 【僅限許可】 | 支援 | BotId | 
| CreateBotLocale | 支援 | BotId | 
| CreateBotVersion | 支援 | BotId | 
| CreateExport | 支援 | BotId | 
| CreateIntent | 支援 | BotId | 
| CreateResourcePolicy | 支援 | BotId、BotAliasId | 
| CreateSlot | 支援 | BotId | 
| CreateSlotType | 支援 | BotId | 
| CreateUploadUrl | 否 |   | 
| DeleteBot | 支援 | BotId、BotAliasId | 
| DeleteBotAlias | 支援 | BotAliasId | 
| DeleteBotChannel 【僅限許可】 | 支援 | BotId | 
| DeleteBotLocale | 支援 | BotId | 
| DeleteBotVersion | 支援 | BotId | 
| DeleteExport | 支援 | BotId | 
| DeleteImport | 支援 | BotId | 
| DeleteIntent | 支援 | BotId | 
| DeleteResourcePolicy | 支援 | BotId、BotAliasId | 
| DeleteSession | 支援 | BotAliasId | 
| DeleteSlot | 支援 | BotId | 
| DeleteSlotType | 支援 | BotId | 
| DescribeBot | 支援 | BotId | 
| DescribeBotAlias | 支援 | BotAliasId | 
| DescribeBotChannel 【僅限許可】 | 支援 | BotId | 
| DescribeBotLocale | 支援 | BotId | 
| DescribeBotVersion | 支援 | BotId | 
| DescribeExport | 支援 | BotId | 
| DescribeImport | 支援 | BotId | 
| DescribeIntent | 支援 | BotId | 
| DescribeResourcePolicy | 支援 | BotId、BotAliasId | 
| DescribeSlot | 支援 | BotId | 
| DescribeSlotType | 支援 | BotId | 
| GetSession | 支援 | BotAliasId | 
| ListBotAliases | 支援 | BotId | 
| ListBotChannels 【僅限許可】 | 支援 | BotId | 
| ListBotLocales | 支援 | BotId | 
| ListBots | 否 |   | 
| ListBotVersions | 支援 | BotId | 
| ListBuiltInIntents | 否 |   | 
| ListBuiltIntSlotTypes | 否 |   | 
| ListExports | 否 |   | 
| ListImports | 否 |   | 
| ListIntents | 支援 | BotId | 
| ListSlots | 支援 | BotId | 
| ListSlotTypes | 支援 | BotId | 
| PutSession | 支援 | BotAliasId | 
| RecognizeText | 支援 | BotAliasId | 
| RecognizeUtterance | 支援 | BotAliasId | 
| StartConversation | 支援 | BotAliasId | 
| StartImport | 支援 | BotId、BotAliasId | 
| TagResource | 否 |   | 
| UpdateBot | 支援 | BotId | 
| UpdateBotAlias | 支援 | BotAliasId | 
| UpdateBotLocale | 支援 | BotId | 
| UpdateBotVersion | 支援 | BotId | 
| UpdateExport | 支援 | BotId | 
| UpdateIntent | 支援 | BotId | 
| UpdateResourcePolicy | 支援 | BotId、BotAliasId | 
| UpdateSlot | 支援 | BotId | 
| UpdateSlotType | 支援 | BotId | 
| UntagResource | 否 |   | 

若要了解如何將資源型政策連接至機器人或機器人別名，請參閱 [Amazon Lex V2 的資源型政策範例](security_iam_resource-based-policy-examples.md)。

### Amazon Lex V2 中的資源型政策範例
<a name="security_iam_service-with-iam-resource-based-policies-examples"></a>



若要檢視 Amazon Lex V2 資源型政策的範例，請參閱 [Amazon Lex V2 的資源型政策範例](security_iam_resource-based-policy-examples.md)。

## Amazon Lex V2 的政策動作
<a name="security_iam_service-with-iam-id-based-policies-actions"></a>

**支援政策動作：***是*

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

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



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

Amazon Lex V2 中的政策動作在動作之前使用下列字首：

```
lex
```

若要在單一陳述式中指定多個動作，請用逗號分隔。

```
"Action": [
      "lex:{{action1}}",
      "lex:{{action2}}"
         ]
```





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

## Amazon Lex V2 的政策資源
<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) 來指定資源。若動作不支援資源層級許可，使用萬用字元 (\*) 表示該陳述式適用於所有資源。

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

若要查看 Amazon Lex V2 資源類型及其 ARNs，請參閱*《服務授權參考*》中的 [Amazon Lex V2 定義的資源](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonlexv2.html#amazonlexv2-resources-for-iam-policies)。若要了解您可以使用哪些動作指定每個資源的 ARN，請參閱 [Amazon Lex V2 定義的動作](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonlexv2.html#amazonlexv2-actions-as-permissions)。





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

## Amazon Lex V2 的政策條件索引鍵
<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)。

若要查看 Amazon Lex V2 條件索引鍵的清單，請參閱*《服務授權參考*》中的 [Amazon Lex V2 的條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonlexv2.html#amazonlexv2-policy-keys)。若要了解您可以使用條件金鑰的動作和資源，請參閱 [Amazon Lex V2 定義的動作](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonlexv2.html#amazonlexv2-actions-as-permissions)。

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

## Amazon Lex V2 中的存取控制清單 (ACLs)
<a name="security_iam_service-with-iam-acls"></a>

**支援 ACLs：***否*

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

## 使用 Amazon Lex V2 的屬性型存取控制 (ABAC)
<a name="security_iam_service-with-iam-tags"></a>

**支援 ABAC （政策中的標籤）：***是*

屬性型存取控制 (ABAC) 是一種授權策略，依據稱為標籤的屬性來定義許可。您可以將標籤連接至 IAM 實體和 AWS 資源，然後設計 ABAC 政策，以便在委託人的標籤符合資源上的標籤時允許操作。

如需根據標籤控制存取，請使用 `aws:ResourceTag/{{key-name}}`、`aws:RequestTag/{{key-name}}` 或 `aws:TagKeys` 條件索引鍵，在政策的[條件元素](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html)中，提供標籤資訊。

如果服務支援每個資源類型的全部三個條件金鑰，則對該服務而言，值為 **Yes**。如果服務僅支援某些資源類型的全部三個條件金鑰，則值為 **Partial**。

如需 ABAC 的詳細資訊，請參閱《*IAM 使用者指南*》中的[使用 ABAC 授權定義許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction_attribute-based-access-control.html)。如要查看含有設定 ABAC 步驟的教學課程，請參閱《*IAM 使用者指南*》中的[使用屬性型存取控制 (ABAC)](https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_attribute-based-access-control.html)。

## 搭配 Amazon Lex V2 使用暫時登入資料
<a name="security_iam_service-with-iam-roles-tempcreds"></a>

**支援臨時登入資料：***否*

暫時登入資料可讓您短期存取 AWS 資源，並在您使用聯合或切換角色時自動建立。AWS 建議您動態產生臨時憑證，而不是使用長期存取金鑰。如需詳細資訊，請參閱《*IAM 使用者指南*》中的 [IAM 中的臨時安全憑證](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html)與[可與 IAM 搭配運作的AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)。

## Amazon Lex V2 的跨服務主體許可
<a name="security_iam_service-with-iam-principal-permissions"></a>

**支援轉送存取工作階段 (FAS)：***是*

 轉送存取工作階段 (FAS) 使用呼叫 的委託人許可 AWS 服務，並結合 AWS 服務 請求向下游服務提出請求。如需提出 FAS 請求時的政策詳細資訊，請參閱[轉發存取工作階段](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html)。

## Amazon Lex V2 的服務角色
<a name="security_iam_service-with-iam-roles-service"></a>

**支援服務角色：***是*

 服務角色是服務擔任的 [IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)，可代您執行動作。IAM 管理員可以從 IAM 內建立、修改和刪除服務角色。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[建立角色以委派許可給 AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html)。

**警告**  
變更服務角色的許可可能會中斷 Amazon Lex V2 功能。只有在 Amazon Lex V2 提供指引時，才能編輯服務角色。

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

**支援服務連結角色：***部分*

 服務連結角色是連結至 的一種服務角色 AWS 服務。服務可以擔任代表您執行動作的角色。服務連結角色會出現在您的 中 AWS 帳戶 ，並由服務擁有。IAM 管理員可以檢視，但不能編輯服務連結角色的許可。

如需建立或管理服務連結角色的詳細資訊，請參閱[使用 IAM 的 AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)。在資料表中尋找服務，其中包含**服務連結角色**欄中的 `Yes`。選擇**是**連結，以檢視該服務的服務連結角色文件。