

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

# 驗證政策檢查
<a name="access-analyzer-checks-validating-policies"></a>

IAM Access Analyzer 提供政策檢查功能，協助您在將 IAM 政策連接到實體之前驗證這些政策。包括政策驗證提供的基本政策檢查，根據[政策文法](reference_policies_grammar.md)和 [AWS 最佳實務](best-practices.md)來驗證您的政策。您可以檢視政策驗證檢查問題清單，包含安全警告、錯誤、一般警告和政策的建議。

您可以使用自訂政策檢查，根據您的安全標準來檢查是否有新的存取權。每次檢查新存取權都會收取費用。如需定價的詳細資訊，請參閱 [IAM Access Analyzer 定價](https://aws.amazon.com/iam/access-analyzer/pricing)。

## 自訂政策檢查的運作方式
<a name="access-analyzer-custom-policy-checks-overview"></a>

您可以使用 AWS Identity and Access Management Access Analyzer 自訂政策檢查，根據您指定的安全標準來驗證 IAM 政策。您可以執行以下類型的自訂政策檢查：
+ **對照參考政策進行檢查**：編輯政策時，您可以檢查更新版政策是否與參考政策 (例如現有政策版本) 相比，是否會授予新的存取權。您可以在使用 IAM 主控台中的 AWS Command Line Interface (AWS CLI)、IAM Access Analyzer API (API) 或 JSON 政策編輯器編輯政策時執行此檢查。
**注意**  
IAM Access Analyzer 自訂政策檢查允許在 `Principal` 元素中使用萬用字元來參考資源政策。
+ **根據 IAM 動作或資源清單進行檢查**：您可以進行檢查以確保政策不允許特定的 IAM 動作或資源。如果只指定動作，則 IAM Access Analyzer 會檢查該動作對政策中所有資源的存取。如果只指定資源，則 IAM Access Analyzer 會檢查哪些動作可以存取指定的資源。如果同時指定了動作和資源，則 IAM Access Analyzer 會檢查哪些指定的動作可以存取指定的資源。您可以在使用 或 AWS CLI API 建立或編輯政策時執行此檢查。
+ **檢查公開存取**：您可以檢查資源政策是否可以將公開存取授予指定的資源類型。您可以在使用 或 AWS CLI API 建立或編輯政策時執行此檢查。這種類型的自訂政策檢查與[預覽存取](https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-access-preview.html)不同，因為該檢查不需要任何帳戶或外部存取分析器內容。存取預覽可讓您在部署資源許可之前預覽 IAM Access Analyzer 調查結果，而自訂檢查則會判斷政策是否可能授予公開存取。

每次自訂政策檢查都會收取費用。如需定價的詳細資訊，請參閱 [IAM Access Analyzer 定價](https://aws.amazon.com/iam/access-analyzer/pricing)。

您可以對身分和資源型政策執行自訂政策檢查。自訂政策檢查不會依賴模式比對技術或檢查存取日誌，來判斷政策是否允許新存取權或指定存取權。與外部存取權調查結果類似，自訂政策檢查是以 [Zelkova](https://aws.amazon.com/blogs/security/protect-sensitive-data-in-the-cloud-with-automated-reasoning-zelkova/) 為基礎。會將 IAM 政策轉換為等效的邏輯陳述式，並針對問題執行一套通用和專用的邏輯求解器 (可滿足性模數理論)。為了檢查是否有新的存取權或指定存取權，IAM Access Analyzer 會將 Zelkova 重複套用至政策。根據政策內容，查詢範圍會越來越限縮，以符合政策允許的行為類別特徵。如需可滿足性模數理論的詳細資訊，請參閱[可滿足性模數理論](https://people.eecs.berkeley.edu/~sseshia/pubdir/SMT-BookChapter.pdf)。

在罕見情況下，IAM Access Analyzer 無法完全判斷政策陳述式是否會授予新的存取權或指定存取權。若發生這種情況，會錯誤地因為未通過自訂政策檢查而宣告誤判。IAM Access Analyzer 旨在提供全方位政策評估，並致力將誤判降到最低。此做法表示 IAM Access Analyzer 可充分保證，通過檢查就表示政策不會授予存取權。您可以檢視 IAM Access Analyzer 回應中報告的政策陳述式，以手動方式審視失敗的檢查。

## 檢查新存取權的參考政策範例
<a name="access-analyzer-custom-policy-checks-reference"></a>

如需參考政策的範例，並了解如何設定和執行自訂政策檢查以檢查新存取權，請參閱 GitHub 上的 [IAM Access Analyzer 自訂政策檢查範例](https://github.com/aws-samples/iam-access-analyzer-custom-policy-check-samples)儲存庫。

**使用這些範例之前**  
使用這些參考政策範例前，請執行下列操作：  
詳閱參考政策並根據您的獨特需求自訂內容。
在您的環境中搭配您使用的 AWS 服務 徹底測試參考政策。  
參考政策示範如何實作和使用自訂政策檢查。他們***並非***闡述為完全如圖所示實作的官方 AWS 建議或最佳實務。您有責任仔細測試任何參考政策是否適合解決您環境的安全需求。
自訂政策檢查分析與環境無關。分析僅考慮輸入政策中包含的資訊。例如，自訂政策檢查無法檢查帳戶是否為特定 AWS 組織的成員。因此，自訂政策檢查無法根據 [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-principalorgid](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-principalorgid) 和 [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-principalaccount](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-principalaccount) 條件索引鍵的條件索引鍵值來比較新存取權。

## 檢查失敗的自訂政策檢查
<a name="access-analyzer-custom-policy-checks-failed-check"></a>

自訂政策檢查失敗時，IAM Access Analyzer 的回應中會包含造成檢查失敗的政策陳述式之 [陳述式 ID (`Sid`)](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_sid.html)。雖然陳述式 ID 是選用的政策元素，但建議您為每個政策陳述式都新增陳述式 ID。自訂政策檢查也會傳回陳述式索引，以協助識別檢查失敗的原因。陳述式索引遵循以零為基準的編號方式，第一個陳述式會參考為 0。有多個陳述式造成檢查失敗時，檢查一次只會傳回一個陳述式 ID。建議您修正原因中反白的陳述式，然後重新執行檢查，直到通過檢查為止。

# 使用 IAM Access Analyzer 來驗證政策
<a name="access-analyzer-policy-validation"></a>

您可以使用政策驗證來驗證您的 AWS Identity and Access Management Access Analyzer 政策。您可以使用 IAM 主控台中的 AWS CLI、 AWS API 或 JSON 政策編輯器來建立或編輯政策。IAM Access Analyzer 會根據 IAM [政策文法](reference_policies_grammar.md)和 [AWS 最佳實務](best-practices.md)來驗證您的政策。您可以檢視政策驗證檢查問題清單，包含安全警告、錯誤、一般警告和政策的建議。這些問題清單提供可行的建議，協助您撰寫具有功能性且符合安全最佳實務的政策。若要檢視 IAM Access Analyzer 執行的基本政策檢查清單，請參閱：[IAM 政策驗證檢查參考](access-analyzer-reference-policy-checks.md)。

## 在 IAM (主控台) 中驗證政策
<a name="access-analyzer-policy-validation-iam-console"></a>

您在 IAM 主控台中建立或編輯受管政策時，可以檢視 IAM Access Analyzer 政策驗證產生的調查結果。您也可以檢視內嵌使用者或角色政策的這些問題清單。IAM Access Analyzer 不會為內嵌群組政策產生調查結果。

**檢視由 IAM JSON 政策的政策檢查產生的問題清單**

1. 登入 AWS 管理主控台 並開啟位於 https：//[https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/) 的 IAM 主控台。

1. 使用以下其中一個方法開始建立或編輯政策：

   1. 若要建立新的受管政策，請移至 **Policies (政策)** 頁面並建立新政策。如需詳細資訊，請參閱[正在使用 JSON 編輯器建立政策](access_policies_create-console.md#access_policies_create-json-editor)。

   1. 若要檢視現有客戶管理政策的政策檢查，請移至**政策**頁面，選擇政策的名稱，然後選擇**編輯**。如需詳細資訊，請參閱[編輯客戶受管政策 (主控台)](access_policies_manage-edit-console.md#edit-customer-managed-policy-console)。

   1. 若要檢視使用者或角色內嵌政策的政策檢查，請移至**使用者**或**角色**頁面，選擇使用者或角色的名稱，然後選擇**許可**索引標籤上的政策名稱，然後選擇**編輯**。如需詳細資訊，請參閱[編輯內嵌政策 (主控台)](access_policies_manage-edit-console.md#edit-inline-policy-console)。

1. 在政策編輯器中，選擇 **JSON** 標籤。

1. 在政策下方的政策驗證窗格中，選擇下列一或多個標籤。標籤名稱也會指出政策的每個問題清單類型數目。
   + **安全** – 如果您的政策允許因存取過於寬鬆而 AWS 被視為安全風險的存取，請檢視警告。
   + **錯誤** – 如果您的政策包含使政策無法運作的行，請檢視錯誤。
   + **警告** – 如果您的政策不符合最佳做法，但問題不屬於安全風險，請檢視警告。
   + **建議** – 如果 AWS 建議不影響政策之許可的改進功能，請檢視警告。

1. 檢閱 IAM Access Analyzer 政策檢查所提供的問題清單詳細資訊。每個問題清單都會指出報告問題的位置。若要深入了解造成問題的原因以及如何解決問題，請選擇報告問題旁的 **Learn more (進一步了解)** 連結。您也可以在 [Access Analyzer policy checks (Access Analyzer 政策檢查)](access-analyzer-reference-policy-checks.md) 參考頁面中搜尋與每個問題清單相關聯的政策檢查。

1. 選用。如果您正在編輯現有政策，可以執行自訂政策檢查，以判斷更新版政策與現有版本相比，是否會授予新的存取權。在政策下方的政策驗證窗格中，選擇**檢查新的存取權**索引標籤，然後選擇**檢查政策**。如果修改後的許可會授予新存取權，該陳述式會在政策驗證窗格中反白顯示。如果您不打算授予新的存取權，請更新政策陳述式並選擇**檢查政策**，直到沒有偵測到新的存取權為止。如需詳細資訊，請參閱[使用 IAM Access Analyzer 自訂政策檢查來驗證政策](access-analyzer-custom-policy-checks.md)。
**注意**  
每次檢查新存取權都會收取費用。如需定價的詳細資訊，請參閱 [IAM Access Analyzer 定價](https://aws.amazon.com/iam/access-analyzer/pricing)。

1. 更新您的政策以解決問題清單。
**重要**  
在您的生產工作流程中實作新的或已編輯的政策之前，請先完整測試。

1. 完成時，選擇 **Next (下一步)**。[政策驗證器](access_policies_policy-validator.md)會報告 IAM Access Analyzer 未報告的所有語法錯誤。
**注意**  
您可以隨時在**視覺化**和 **JSON** 索引標籤之間切換。不過，如果您進行變更或在**視覺化**索引標籤中選擇**下一步**，IAM 可能會調整您的政策結構，以針對視覺化編輯器進行最佳化。如需詳細資訊，請參閱[政策結構調整](troubleshoot_policies.md#troubleshoot_viseditor-restructure)。

1. 若使用新政策，在**檢閱與建立**頁面上，為您正在建立的政策輸入**政策名稱**與**描述** (選用)。檢閱**此政策中定義的許可**，來查看您的政策所授予的許可。然後選擇 **Create policy (建立政策)** 來儲存您的工作。

   若使用現有的政策，在**檢閱與儲存**頁面上，檢閱**在此政策中定義的許可**來查看您的政策所授予的許可。選擇**將此新版本設定為預設值。**核取方塊，將更新版政策儲存為預設版政策。選擇**儲存變更**以儲存編輯內容。

## 使用 IAM Access Analyzer (AWS CLI 或 AWS API) 驗證政策
<a name="access-analyzer-policy-validation-cli"></a>

您可以從 AWS Command Line Interface (AWS CLI) 檢視 IAM Access Analyzer 政策驗證所產生的調查結果。

**檢視 IAM Access Analyzer 政策驗證 (AWS CLI 或 AWS API) 所產生的問題清單**  
請使用下列其中一個：
+ AWS CLI：[aws accessanalyzer validate-policy](https://docs.aws.amazon.com/cli/latest/reference/accessanalyzer/validate-policy.html) 
+ AWS API：[ValidatePolicy](https://docs.aws.amazon.com/access-analyzer/latest/APIReference/API_ValidatePolicy.html) 

# IAM 政策驗證檢查參考
<a name="access-analyzer-reference-policy-checks"></a>

您可以使用政策驗證來驗證您的 AWS Identity and Access Management Access Analyzer 政策。您可以使用 IAM 主控台中的 AWS CLI、 AWS API 或 JSON 政策編輯器來建立或編輯政策。IAM Access Analyzer 會根據 IAM [政策文法](reference_policies_grammar.md)和 [AWS 最佳實務](best-practices.md)來驗證您的政策。您可以檢視政策驗證檢查問題清單，包含安全警告、錯誤、一般警告和政策的建議。這些問題清單提供可行的建議，協助您撰寫具有功能性且符合安全最佳實務的政策。IAM Access Analyzer 提供的基本政策檢查清單如下。執行政策驗證檢查不會額外收費。若要進一步了解如何使用政策驗證來驗證政策，請參閱：[使用 IAM Access Analyzer 來驗證政策](access-analyzer-policy-validation.md)。

## 錯誤 – 不允許 ARN 帳戶
<a name="access-analyzer-reference-policy-checks-error-arn-account-not-allowed"></a>

**問題代碼：**ARN\$1ACCOUNT\$1NOT\$1ALLOWED

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
ARN account not allowed: The service {{service}} does not support specifying an account ID in the resource ARN.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The service {{service}} does not support specifying an account ID in the resource ARN."
```

**解決錯誤**

從資源 ARN 中移除帳戶 ID。某些 AWS 服務的資源 ARNs 不支援指定帳戶 ID。

例如，Amazon S3 不支援帳戶 ID 做為儲存貯體 ARN 中的命名空間。Amazon S3 儲存貯體名稱是全域唯一的，且命名空間由所有 AWS 帳戶共用。若要檢視 Amazon S3 中可用的所有資源類型，請參閱*服務授權參考*中的 [Amazon S3 定義的資源類型](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html#amazons3-resources-for-iam-policies)。

**相關用語**
+ [政策資源](reference_policies_elements_resource.md)
+ [帳戶識別符](https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [AWS 具有 ARN 格式的服務資源](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 – 不允許 ARN 區域
<a name="access-analyzer-reference-policy-checks-error-arn-region-not-allowed"></a>

**問題代碼：**ARN\$1REGION\$1NOT\$1ALLOWED

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
ARN Region not allowed: The service {{service}} does not support specifying a Region in the resource ARN.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The service {{service}} does not support specifying a Region in the resource ARN."
```

**解決錯誤**

從資源 ARN 中移除區域。某些 AWS 服務的資源 ARNs 不支援指定區域。

例如，IAM 是全球服務。IAM 資源 ARN 的「區域」部分一律保持空白。IAM 資源是全域的，就像帳戶 AWS 現在一樣。例如，以 IAM 使用者身分登入後，您可以存取任何地理區域中的 AWS 服務。
+ [政策資源](reference_policies_elements_resource.md)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [AWS 具有 ARN 格式的服務資源](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 – 資料類型不符
<a name="access-analyzer-reference-policy-checks-error-data-type-mismatch"></a>

**問題代碼：**DATA\$1TYPE\$1MISMATCH

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Data type mismatch: The text does not match the expected JSON data type {{data_type}}.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The text does not match the expected JSON data type {{data_type}}."
```

**解決錯誤**

更新文字以使用支援的資料類型。

例如，`Version` 全域條件鍵需要 `String` 資料類型。如果您提供日期或整數，則資料類型將不相符。

**相關用語**
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)

## 錯誤 – 重複鍵使用不同的大小寫
<a name="access-analyzer-reference-policy-checks-error-duplicate-keys-with-different-case"></a>

**問題代碼：**DUPLICATE\$1KEYS\$1WITH\$1DIFFERENT\$1CASE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Duplicate keys with different case: The condition key {{key}} appears more than once with different capitalization in the same condition block. Remove the duplicate condition keys.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition key {{key}} appears more than once with different capitalization in the same condition block. Remove the duplicate condition keys."
```

**解決錯誤**

檢閱相同條件區塊中的類似條件鍵，並針對所有執行個體使用相同的大小寫。

*條件區塊*是政策聲明 `Condition` 元素內的文字。條件鍵 *names* 不區分大小寫。條件鍵 *values* 是否區分大小寫取決於您使用的條件運算子。如需條件鍵中區分大小寫的詳細資訊，請參閱 [IAM JSON 政策元素：Condition](reference_policies_elements_condition.md)。

**相關用語**
+ [條件](reference_policies_elements_condition.md)
+ [條件區塊](reference_policies_elements_condition.md#AccessPolicyLanguage_ConditionBlock)
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [AWS 服務條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - 無效的動作
<a name="access-analyzer-reference-policy-checks-error-invalid-action"></a>

**問題代碼：**INVALID\$1ACTION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid action: The action {{action}} does not exist. Did you mean {{valid_action}}?
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The action {{action}} does not exist. Did you mean {{valid_action}}?"
```

**解決錯誤**

您指定的動作無效。如果您輸入錯誤的服務字首或動作名稱，就會發生這種情況。對於某些常見問題，政策檢查會傳回建議的動作。

**相關用語**
+ [政策動作](reference_policies_elements_action.md)
+ [AWS 服務動作](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

### AWS 具有此錯誤的 受管政策
<a name="accan-ref-policy-check-message-fix-error-invalid-action-awsmanpol"></a>

[AWS 受管政策](access_policies_managed-vs-inline.md#aws-managed-policies)可讓您根據一般 AWS 使用案例指派許可 AWS ，以開始使用 。

下列 AWS 受管政策在其政策陳述式中包含無效的動作。無效的動作並不會影響政策所授與的許可。使用 AWS 受管政策做為建立受管政策的參考時， AWS 建議您從政策中移除無效的動作。
+ [AmazonEMRFullAccessPolicy\$1v2](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonEMRFullAccessPolicy_v2)
+ [CloudWatchSyntheticsFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/CloudWatchSyntheticsFullAccess)

## 錯誤 - 無效的 ARN 帳戶
<a name="access-analyzer-reference-policy-checks-error-invalid-arn-account"></a>

**問題代碼：**INVALID\$1ARN\$1ACCOUNT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid ARN account: The resource ARN account ID {{account}} is not valid. Provide a 12-digit account ID.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The resource ARN account ID {{account}} is not valid. Provide a 12-digit account ID."
```

**解決錯誤**

更新資源 ARN 中的帳戶 ID。帳戶 ID 是 12 位數的整數。若要了解如何檢視您的帳戶 ID，請參閱[尋找 AWS 您的帳戶 ID](https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html#FindingYourAccountIdentifiers)。

**相關用語**
+ [政策資源](reference_policies_elements_resource.md)
+ [帳戶識別符](https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [AWS 具有 ARN 格式的服務資源](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - 無效的 ARN 字首
<a name="access-analyzer-reference-policy-checks-error-invalid-arn-prefix"></a>

**問題代碼：**INVALID\$1ARN\$1PREFIX

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid ARN prefix: Add the required prefix (arn) to the resource ARN.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add the required prefix (arn) to the resource ARN."
```

**解決錯誤**

AWS 資源 ARNs必須包含必要的`arn:`字首。

**相關用語**
+ [政策資源](reference_policies_elements_resource.md)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [AWS 具有 ARN 格式的 服務資源](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - 無效的 ARN 區域
<a name="access-analyzer-reference-policy-checks-error-invalid-arn-region"></a>

**問題代碼：**INVALID\$1ARN\$1REGION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid ARN Region: The Region {{region}} is not valid for this resource. Update the resource ARN to include a supported Region.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The Region {{region}} is not valid for this resource. Update the resource ARN to include a supported Region."
```

**解決錯誤**

資源類型在指定區域中不支援。如需每個區域中支援 AWS 的服務資料表，請參閱[區域資料表](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/)。

**相關用語**
+ [政策資源](reference_policies_elements_resource.md)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [區域名稱和代碼](https://docs.aws.amazon.com/general/latest/gr/rande.html#region-names-codes)

## 錯誤 - 無效的 ARN 資源
<a name="access-analyzer-reference-policy-checks-error-invalid-arn-resource"></a>

**問題代碼：**INVALID\$1ARN\$1RESOURCE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid ARN resource: Resource ARN does not match the expected ARN format. Update the resource portion of the ARN.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Resource ARN does not match the expected ARN format. Update the resource portion of the ARN."
```

**解決錯誤**

資源 ARN 必須符合已知資源類型的規格。若要檢視服務的預期 ARN 格式，請參閱 [AWS 服務的動作、資源和條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)。選擇服務的名稱，以檢視其資源類型和 ARN 格式。

**相關用語**
+ [政策資源](reference_policies_elements_resource.md)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [AWS 具有 ARN 格式的 服務資源](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - 無效的 ARN 服務案例
<a name="access-analyzer-reference-policy-checks-error-invalid-arn-service-case"></a>

**問題代碼：**INVALID\$1ARN\$1SERVICE\$1CASE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid ARN service case: Update the service name {{service}} in the resource ARN to use all lowercase letters.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Update the service name {{service}} in the resource ARN to use all lowercase letters."
```

**解決錯誤**

資源 ARN 中的服務必須符合服務字首的規格 (包括大小寫)。若要檢視服務的字首，請參閱 [AWS 服務的動作、資源和條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)。選擇服務的名稱，然後在第一句中找到該服務的字首。

**相關用語**
+ [政策資源](reference_policies_elements_resource.md)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [AWS 具有 ARN 格式的服務資源](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - 無效的條件資料類型
<a name="access-analyzer-reference-policy-checks-error-invalid-condition-data-type"></a>

**問題代碼：**INVALID\$1CONDITION\$1DATA\$1TYPE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid condition data type: The condition value data types do not match. Use condition values of the same JSON data type.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition value data types do not match. Use condition values of the same JSON data type."
```

**解決錯誤**

條件鍵值組中的值必須符合條件鍵和條件運算子的資料類型。若要檢視服務的條件索引鍵資料類型，請參閱 [AWS 服務的動作、資源和條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)。選擇服務的名稱，以檢視該服務的條件鍵。

例如，[`CurrentTime`](reference_policies_condition-keys.md#condition-keys-currenttime)全域條件鍵支援 `Date` 條件運算子。如果您為條件區塊中的值提供字串或整數，則資料類型將不相符。

**相關用語**
+ [條件](reference_policies_elements_condition.md)
+ [條件區塊](reference_policies_elements_condition.md#AccessPolicyLanguage_ConditionBlock)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [AWS 服務條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - 無效的條件鍵格式
<a name="access-analyzer-reference-policy-checks-error-invalid-condition-key-format"></a>

**問題代碼：**INVALID\$1CONDITION\$1KEY\$1FORMAT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid condition key format: The condition key format is not valid. Use the format service:keyname.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition key format is not valid. Use the format service:keyname."
```

**解決錯誤**

條件鍵值組中的鍵必須符合服務的規格。若要檢視服務的條件索引鍵，請參閱 [AWS 服務的動作、資源和條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)。選擇服務的名稱，以檢視該服務的條件鍵。

**相關用語**
+ [條件](reference_policies_elements_condition.md)
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [AWS 服務條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - 無效條件多重布林值
<a name="access-analyzer-reference-policy-checks-error-invalid-condition-multiple-boolean"></a>

**問題代碼：**INVALID\$1CONDITION\$1MULTIPLE\$1BOOLEAN

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid condition multiple Boolean: The condition key does not support multiple Boolean values. Use a single Boolean value.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition key does not support multiple Boolean values. Use a single Boolean value."
```

**解決錯誤**

條件鍵值對中的鍵需要單一布林值。當您提供多個布林值時，條件比對可能不會傳回您預期的結果。

若要檢視服務的條件索引鍵，請參閱 [AWS 服務的動作、資源和條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)。選擇服務的名稱，以檢視該服務的條件鍵。
+ [條件](reference_policies_elements_condition.md)
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [AWS 服務條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - 無效的條件運算子
<a name="access-analyzer-reference-policy-checks-error-invalid-condition-operator"></a>

**問題代碼：**INVALID\$1CONDITION\$1OPERATOR

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid condition operator: The condition operator {{operator}} is not valid. Use a valid condition operator.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition operator {{operator}} is not valid. Use a valid condition operator."
```

**解決錯誤**

更新條件以使用支援的條件運算子。

**相關用語**
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)
+ [條件元素](reference_policies_elements_condition.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 錯誤 — 效果的無效
<a name="access-analyzer-reference-policy-checks-error-invalid-effect"></a>

**問題代碼：**INVALID\$1EFFECT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid effect: The effect {{effect}} is not valid. Use Allow or Deny.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The effect {{effect}} is not valid. Use Allow or Deny."
```

**解決錯誤**

更新 `Effect` 元素以使用有效的效果。`Effect` 的有效值為 **Allow** 和 **Deny**。

**相關用語**
+ [效果元素](reference_policies_elements_effect.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 錯誤 — 無效的全域條件鍵
<a name="access-analyzer-reference-policy-checks-error-invalid-global-condition-key"></a>

**問題代碼：**INVALID\$1GLOBAL\$1CONDITION\$1KEY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid global condition key: The condition key {{key}} does not exist. Use a valid condition key.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition key {{key}} does not exist. Use a valid condition key."
```

**解決錯誤**

更新條件鍵值組中的條件鍵，以使用支援的全域條件鍵。

全域條件索引鍵是具有 `aws:` 字首的條件索引鍵。 AWS services 可以支援全域條件索引鍵，或提供包含其服務字首的服務特定索引鍵。例如，IAM 條件鍵會包含 `iam:` 字首。如需詳細資訊，請參閱  [AWS 服務的動作、資源和條件金鑰](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html) ，然後選擇您要檢視其金鑰的服務。

**相關用語**
+ [全域條件鍵](reference_policies_condition-keys.md)

## 錯誤 — 無效的分割區
<a name="access-analyzer-reference-policy-checks-error-invalid-partition"></a>

**問題代碼：**INVALID\$1PARTITION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid partition: The resource ARN for the service {{service}} does not support the partition {{partition}}. Use the supported values: {{partitions}}
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The resource ARN for the service {{service}} does not support the partition {{partition}}. Use the supported values: {{partitions}}"
```

**解決錯誤**

更新資源 ARN 以包含支援的分割區。如果您包含支援的分割區，則服務或資源可能不支援您包含的分割區。

*分割區*是一組 AWS 區域。每個 AWS 帳戶的範圍為一個分割區。在傳統區域中，使用 `aws` 分割區。在中國區域，使用 `aws-cn`。

**相關用語**
+ [Amazon 資源名稱 (ARN) - 分割區](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)

## 錯誤 — 無效的政策元素
<a name="access-analyzer-reference-policy-checks-error-invalid-policy-element"></a>

**問題代碼：**INVALID\$1POLICY\$1ELEMENT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid policy element: The policy element {{element}} is not valid.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The policy element {{element}} is not valid."
```

**解決錯誤**

更新政策以僅包含支援的 JSON 政策元素。

**相關用語**
+ [ JSON 政策元素](reference_policies_elements.md)：

## 錯誤 — 無效的主體格式
<a name="access-analyzer-reference-policy-checks-error-invalid-principal-format"></a>

**問題代碼：**INVALID\$1PRINCIPAL\$1FORMAT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid principal format: The Principal element contents are not valid. Specify a key-value pair in the Principal element.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The Principal element contents are not valid. Specify a key-value pair in the Principal element."
```

**解決錯誤**

更新主體，以使用支援的鍵值組格式。

您可以在以資源為基礎的政策中指定主體，但不能在以身分為基礎的政策中指定。

例如，若要為 AWS 帳戶中的每個人定義存取權，請在政策中使用下列委託人：

```
"Principal": { "AWS": "123456789012" }
```

**相關用語**
+ [JSON 政策元素：主體](reference_policies_elements_principal.md)
+ [以身分為基礎的政策和以資源為基礎的政策](access_policies_identity-vs-resource.md)

## 錯誤 - 無效的主體鍵
<a name="access-analyzer-reference-policy-checks-error-invalid-principal-key"></a>

**問題代碼：**INVALID\$1PRINCIPAL\$1KEY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid principal key: The principal key {{principal-key}} is not valid.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The principal key {{principal-key}} is not valid."
```

**解決錯誤**

更新主體鍵值組中的鍵，以使用支援的主體鍵。以下是支援的主體鍵：
+ AWS
+ CanonicalUser
+ 聯合
+ 服務

**相關用語**
+ [主體元素](reference_policies_elements_principal.md)

## 錯誤 - 無效的區域
<a name="access-analyzer-reference-policy-checks-error-invalid-region"></a>

**問題代碼：**INVALID\$1REGION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid Region: The Region {{region}} is not valid. Update the condition value to a suported Region.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The Region {{region}} is not valid. Update the condition value to a suported Region."
```

**解決錯誤**

更新條件鍵值組的值，以包含支援的區域。如需每個區域中支援 AWS 的服務資料表，請參閱[區域資料表](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/)。

**相關用語**
+ [政策資源](reference_policies_elements_resource.md)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [區域名稱和代碼](https://docs.aws.amazon.com/general/latest/gr/rande.html#region-names-codes)

## 錯誤 - 無效的服務
<a name="access-analyzer-reference-policy-checks-error-invalid-service"></a>

**問題代碼：**INVALID\$1SERVICE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid service: The service {{service}} does not exist. Use a valid service name.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The service {{service}} does not exist. Use a valid service name."
```

**解決錯誤**

動作或條件鍵中的服務字首必須符合服務字首的規格 (包括大小寫)。若要檢視服務的字首，請參閱 [AWS 服務的動作、資源和條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)。選擇服務的名稱，然後在第一句中找到該服務的字首。

**相關用語**
+ [已知的服務及其動作、資源和條件鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - 無效的服務條件鍵
<a name="access-analyzer-reference-policy-checks-error-invalid-service-condition-key"></a>

**問題代碼：**INVALID\$1SERVICE\$1CONDITION\$1KEY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid service condition key: The condition key {{key}} does not exist in the service {{service}}. Use a valid condition key.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition key {{key}} does not exist in the service {{service}}. Use a valid condition key."
```

**解決錯誤**

更新條件鍵值組中的鍵，以使用服務的已知條件鍵。全域條件鍵名稱是以 `aws` 字首為開頭。 AWS 服務可提供包含其服務字首的服務專屬鍵。若要檢視服務的字首，請參閱 [AWS 服務的動作、資源和條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)。

**相關用語**
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [已知的服務及其動作、資源和條件鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - 動作中的服務無效
<a name="access-analyzer-reference-policy-checks-error-invalid-service-in-action"></a>

**問題代碼：**INVALID\$1SERVICE\$1IN\$1ACTION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid service in action: The service {{service}} specified in the action does not exist. Did you mean {{service2}}?
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The service {{service}} specified in the action does not exist. Did you mean {{service2}}?"
```

**解決錯誤**

動作中的服務字首必須符合服務字首的規格 (包括大小寫)。若要檢視服務的字首，請參閱 [AWS 服務的動作、資源和條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)。選擇服務的名稱，然後在第一句中找到該服務的字首。

**相關用語**
+ [動作元素](reference_policies_elements_action.md)
+ [已知的服務及其行動](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 — 運算子的無效變數
<a name="access-analyzer-reference-policy-checks-error-invalid-variable-for-operator"></a>

**問題代碼：**INVALID\$1VARIABLE\$1FOR\$1OPERATOR

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid variable for operator: Policy variables can only be used with String and ARN operators.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Policy variables can only be used with String and ARN operators."
```

**解決錯誤**

您可以在 `Resource` 元素中使用政策變數，也可以在 `Condition` 元素中使用字串比較。當您使用字串運算子或 ARN 運算子時，條件支援變數。字串運算子包括 `StringEquals`、`StringLike` 和 `StringNotLike`。ARN 運算子包括 `ArnEquals` 和 `ArnLike`。您無法使用政策變數搭配其他運算子，例如 Numeric、Date、Boolean、Binary、IP Address 或 Null 運算子。

**相關用語**
+ [在「條件」元素中使用政策變數](reference_policies_variables.md#policy-vars-conditionelement)
+ [條件元素](reference_policies_elements_condition.md)

## 錯誤 - 無效的版本
<a name="access-analyzer-reference-policy-checks-error-invalid-version"></a>

**問題代碼：**INVALID\$1VERSION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid version: The version {{version}} is not valid. Use one of the following versions: {{versions}}
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The version {{version}} is not valid. Use one of the following versions: {{versions}}"
```

**解決錯誤**

 `Version` 政策元素指定 AWS 用於處理政策的語言語法規則。若要使用所有可用的政策功能，請在所有政策的 `Statement` 元素前面包含最新的 `Version` 元素。

```
"Version": "2012-10-17"
```

**相關用語**
+ [版本元素](reference_policies_elements_version.md)

## 錯誤 – Json 語法錯誤
<a name="access-analyzer-reference-policy-checks-error-json-syntax-error"></a>

**問題代碼：**JSON\$1SYNTAX\$1ERROR

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Json syntax error: Fix the JSON syntax error at index {{index}} line {{line}} column {{column}}.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Fix the JSON syntax error at index {{index}} line {{line}} column {{column}}."
```

**解決錯誤**

您的政策包含語法錯誤。檢查您的 JSON 語法。

**相關用語**
+ [JSON 驗證器](https://json-validate.com/)
+ [IAM JSON 政策元素參考](reference_policies_elements.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 錯誤 – Json 語法錯誤
<a name="access-analyzer-reference-policy-checks-error-json-syntax-error"></a>

**問題代碼：**JSON\$1SYNTAX\$1ERROR

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Json syntax error: Fix the JSON syntax error.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Fix the JSON syntax error."
```

**解決錯誤**

您的政策包含語法錯誤。檢查您的 JSON 語法。

**相關用語**
+ [JSON 驗證器](https://json-validate.com/)
+ [IAM JSON 政策元素參考](reference_policies_elements.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 錯誤 - 缺少動作
<a name="access-analyzer-reference-policy-checks-error-missing-action"></a>

**問題代碼：**MISSING\$1ACTION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing action: Add an Action or NotAction element to the policy statement.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add an Action or NotAction element to the policy statement."
```

**解決錯誤**

AWS JSON 政策必須包含 `Action`或 `NotAction`元素。

**相關用語**
+ [動作元素](reference_policies_elements_action.md)
+ [NotAction 元素](reference_policies_elements_notaction.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 錯誤 – 缺少 ARN 欄位
<a name="access-analyzer-reference-policy-checks-error-missing-arn-field"></a>

**問題代碼：**MISSING\$1ARN\$1FIELD

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing ARN field: Resource ARNs must include at least {{fields}} fields in the following structure: arn:partition:service:region:account:resource
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Resource ARNs must include at least {{fields}} fields in the following structure: arn:partition:service:region:account:resource"
```

**解決錯誤**

資源 ARN 中的所有欄位必須符合已知資源類型的規格。若要檢視服務的預期 ARN 格式，請參閱 [AWS 服務的動作、資源和條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)。選擇服務的名稱，以檢視其資源類型和 ARN 格式。

**相關用語**
+ [政策資源](reference_policies_elements_resource.md)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [AWS 具有 ARN 格式的服務資源](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 – 缺少 ARN 區域
<a name="access-analyzer-reference-policy-checks-error-missing-arn-region"></a>

**問題代碼：**MISING\$1ARN\$1REGION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing ARN Region: Add a Region to the {{service}} resource ARN.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add a Region to the {{service}} resource ARN."
```

**解決錯誤**

大多數 AWS 服務的資源 ARNs 需要您指定區域。如需每個區域中支援 AWS 的服務資料表，請參閱[區域資料表](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/)。

**相關用語**
+ [政策資源](reference_policies_elements_resource.md)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [區域名稱和代碼](https://docs.aws.amazon.com/general/latest/gr/rande.html#region-names-codes)

## 錯誤 – 缺少效果
<a name="access-analyzer-reference-policy-checks-error-missing-effect"></a>

**問題代碼：**MISSING\$1EFFECT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing effect: Add an Effect element to the policy statement with a value of Allow or Deny.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add an Effect element to the policy statement with a value of Allow or Deny."
```

**解決錯誤**

AWS JSON 政策必須包含值為 和 的 **Allow** `Effect`元素 **Deny**。

**相關用語**
+ [效果元素](reference_policies_elements_effect.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 錯誤 – 缺少主體
<a name="access-analyzer-reference-policy-checks-error-missing-principal"></a>

**問題代碼：**MISSING\$1PRINCIPAL

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing principal: Add a Principal element to the policy statement.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add a Principal element to the policy statement."
```

**解決錯誤**

以資源為基礎的政策必須包含 `Principal` 元素。

例如，若要為 AWS 帳戶中的每個人定義存取權，請在政策中使用下列委託人：

```
"Principal": { "AWS": "123456789012" }
```

**相關用語**
+ [主體元素](reference_policies_elements_principal.md)
+ [以身分為基礎的政策和以資源為基礎的政策](access_policies_identity-vs-resource.md)

## 錯誤 – 缺少限定詞
<a name="access-analyzer-reference-policy-checks-error-missing-qualifier"></a>

**問題代碼：**MISSING\$1QUALIFIER

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing qualifier: The request context key {{key}} has multiple values. Use the ForAllValues or ForAnyValue condition key qualifiers in your policy.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The request context key {{key}} has multiple values. Use the ForAllValues or ForAnyValue condition key qualifiers in your policy."
```

**解決錯誤**

在 `Condition` 元素中，您所建置的表達式使用條件運算子 (例如等於或小於) 來比較政策中的條件鍵與值，以及請求內容中的鍵與值。對於包含單一條件鍵之多個值的請求，您必須像陣列一樣，在括號內括住條件 ("Key2":["Value2A", "Value2B"])。您還必須使用 `ForAllValues` 或 `ForAnyValue` 設定運算子搭配 `StringLike` 條件運算子。這些限定詞新增設定操作功能到條件運算子，以便您可以針對多個條件值測試多個請求值。

**相關用語**
+ [多值內容鍵](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)
+ [條件元素](reference_policies_elements_condition.md)

### AWS 具有此錯誤的 受管政策
<a name="accan-ref-policy-check-message-fix-error-missing-qualifier-awsmanpol"></a>

[AWS 受管政策](access_policies_managed-vs-inline.md#aws-managed-policies)可讓您根據一般 AWS 使用案例指派許可 AWS ，以開始使用 。

下列 AWS 受管政策在其政策陳述式中包含缺少條件索引鍵的限定詞。使用 AWS 受管政策做為建立客戶受管政策的參考時， AWS 建議您將 `ForAllValues`或 `ForAnyValue`條件金鑰限定詞新增至 `Condition`元素。
+ [AWSGlueConsoleSageMakerNotebookFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AWSGlueConsoleSageMakerNotebookFullAccess)

## 錯誤 – 缺少資源
<a name="access-analyzer-reference-policy-checks-error-missing-resource"></a>

**問題代碼：**MISSING\$1RESOURCE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing resource: Add a Resource or NotResource element to the policy statement.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add a Resource or NotResource element to the policy statement."
```

**解決錯誤**

角色信任政策以外的所有政策都必須包含 `Resource` 或 `NotResource` 元素。

**相關用語**
+ [資源元素](reference_policies_elements_resource.md)
+ [NotResource 元素](reference_policies_elements_notresource.md)
+ [以身分為基礎的政策和以資源為基礎的政策](access_policies_identity-vs-resource.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 錯誤 – 缺少陳述式
<a name="access-analyzer-reference-policy-checks-error-missing-statement"></a>

**問題代碼：**MISSING\$1STATEMENT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing statement: Add a statement to the policy
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add a statement to the policy"
```

**解決錯誤**

JSON 政策必須包含陳述式。

**相關用語**
+ [ JSON 政策元素](reference_policies_elements.md)：

## 錯誤 – 如果存在，則為空
<a name="access-analyzer-reference-policy-checks-error-null-with-if-exists"></a>

**問題代碼：**NULL\$1WITH\$1IF\$1EXISTS

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Null with if exists: The Null condition operator cannot be used with the IfExists suffix. Update the operator or the suffix.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The Null condition operator cannot be used with the IfExists suffix. Update the operator or the suffix."
```

**解決錯誤**

除 `Null` 條件運算子外，您可在任何條件運算子名稱的結尾新增 `IfExists`。使用 `Null` 條件運算子檢查授權時是否有條件鍵。使用 `...ifExists` 來表示「如果請求的內容中存在政策鍵，則依照政策所述來處理鍵。如果該鍵不存在，則評估條件元素為 true。」

**相關用語**
+ [...IfExists 條件運算子](reference_policies_elements_condition_operators.md#Conditions_IfExists)
+ [Null 條件運算子](reference_policies_elements_condition_operators.md#Conditions_Null)
+ [條件元素](reference_policies_elements_condition.md)

## 錯誤 – SCP 語法錯誤動作萬用字元
<a name="access-analyzer-reference-policy-checks-error-scp-syntax-error-action-wildcard"></a>

**問題代碼：**SCP\$1SYNTAX\$1ERROR\$1ACTION\$1WILDCARD

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
SCP syntax error action wildcard: SCP actions can include wildcards (*) only at the end of a string. Update {{action}}.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "SCP actions can include wildcards (*) only at the end of a string. Update {{action}}."
```

**解決錯誤**

AWS Organizations 服務控制政策 SCPs) 支援在 `Action`或 `NotAction`元素中指定值。不過，這些值只能在字串結尾包含萬用字元 (\$1)。這表示您可指定 `iam:Get*` 而不是 `iam:*role`。

若要指定多個動作， AWS 建議您個別列出這些動作。

**相關用語**
+ [SCP 動作與 NotAction 元素](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_syntax.html#scp-syntax-action)
+ [SCP 評估](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_evaluation.html)
+ [AWS Organizations 服務控制政策](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html)
+ [IAM JSON 政策元素：動作](reference_policies_elements_action.md)

## 錯誤 – SCP 語法錯誤主體
<a name="access-analyzer-reference-policy-checks-error-scp-syntax-error-principal"></a>

**問題代碼：**SCP\$1SYNTAX\$1ERROR\$1PRINCIPAL

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
SCP syntax error principal: SCPs do not support specifying principals. Remove the Principal or NotPrincipal element.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "SCPs do not support specifying principals. Remove the Principal or NotPrincipal element."
```

**解決錯誤**

AWS Organizations 服務控制政策 SCPs) 不支援 `Principal`或 `NotPrincipal`元素。

您可以使用 `Condition` 元素中的 `aws:PrincipalArn` 全域條件鍵來指定 Amazon Resource Name (ARN)。

**相關用語**
+ [SCP 語法](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_syntax.html)
+ [主體的全域條件鍵](reference_policies_condition-keys.md#condition-keys-principalarn)

## 錯誤 – 需要唯一 Sid
<a name="access-analyzer-reference-policy-checks-error-unique-sids-required"></a>

**問題代碼：**UNIQUE\$1SIDS\$1REQUIRED

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unique Sids required: Duplicate statement IDs are not supported for this policy type. Update the Sid value.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Duplicate statement IDs are not supported for this policy type. Update the Sid value."
```

**解決錯誤**

對於某些政策類型，陳述式 ID 必須是唯一的。`Sid` (陳述式 ID) 元素允許您輸入您為政策陳述式提供的可選識別符。您可以使用 `SID` 元素將陳述式 ID 值指派給陳述式陣列中的每個陳述式。在允許您指定 ID 元素的服務中 (例如 SQS 和 SNS)，`Sid` 值只是政策文件 ID 的子 ID。例如，在 IAM 中，`Sid` 值在 JSON 政策中必須是唯一的。

**相關用語**
+ [IAM JSON 政策元素：Sid](reference_policies_elements_sid.md)

## 錯誤 - 政策中不支援的動作
<a name="access-analyzer-reference-policy-checks-error-unsupported-action-in-policy"></a>

**問題代碼：**UNSUPPORTED\$1ACTION\$1IN\$1POLICY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported action in policy: The action {{action}} is not supported for the resource-based policy attached to the resource type {{resourceType}}.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The action {{action}} is not supported for the resource-based policy attached to the resource type {{resourceType}}."
```

**解決錯誤**

在連接至不同資源類型的資源型政策中，部分動作在其 `Action` 元素中不受支援。例如，Amazon S3 儲存貯體政策不支援 AWS Key Management Service 動作。指定連接至資源型政策的資源類型支援的動作。

**相關用語**
+ [JSON 政策元素：動作](reference_policies_elements_action.md)

## 錯誤 – 不支援的元素組合
<a name="access-analyzer-reference-policy-checks-error-unsupported-element-combination"></a>

**問題代碼：**UNSUPPORTED\$1ELEMENT\$1COMBINATION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported element combination: The policy elements {{element1}} and {{element2}} can not be used in the same statement. Remove one of these elements.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The policy elements {{element1}} and {{element2}} can not be used in the same statement. Remove one of these elements."
```

**解決錯誤**

JSON 政策元素的某些組合無法一起使用。例如，您不能在同一政策陳述式中同時使用 `Action` 與 `NotAction`。相互排斥的其他組合包括 `Principal/NotPrincipal` 和 `Resource/NotResource`。

**相關用語**
+ [IAM JSON 政策元素參考](reference_policies_elements.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 錯誤 – 不支援的全域條件鍵
<a name="access-analyzer-reference-policy-checks-error-unsupported-global-condition-key"></a>

**問題代碼：**UNSUPPORTED\$1GLOBAL\$1CONDITION\$1KEY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported global condition key: The condition key aws:ARN is not supported. Use aws:PrincipalArn or aws:SourceArn instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition key aws:ARN is not supported. Use aws:PrincipalArn or aws:SourceArn instead."
```

**解決錯誤**

AWS 不支援使用指定的全域條件金鑰。視您的使用案例而定，您可以使用 `aws:PrincipalArn` 或 `aws:SourceArn` 全域條件鍵。例如，並非使用 `aws:ARN`，而是使用 `aws:PrincipalArn` 來將提出請求主體的 Amazon Resource Name (ARN)) 與您在政策中所指定的 ARN 進行比較。或者，使用 `aws:SourceArn` 全域條件鍵，將提出服務對服務請求之資源的 Amazon Resource Name (ARN) 與您在政策中所指定的 ARN 進行比較。

**相關用語**
+ [AWS 全域條件內容索引鍵](reference_policies_condition-keys.md)

## 錯誤 – 不支援的主體
<a name="access-analyzer-reference-policy-checks-error-unsupported-principal"></a>

**問題代碼：**UNSUPPORTED\$1PRINCIPAL

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported principal: The policy type {{policy_type}} does not support the Principal element. Remove the Principal element.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The policy type {{policy_type}} does not support the Principal element. Remove the Principal element."
```

**解決錯誤**

`Principal` 元素會指定允許或拒絕存取資源的主體。您無法在以 IAM 身分為基礎的政策中使用 `Principal` 元素。您可以在 IAM 角色和以資源為基礎政策的信任政策中使用該元素。資源型政策是您直接內嵌在資源中的政策。例如，您可以在 Amazon S3 儲存貯體或 AWS KMS 金鑰中嵌入政策。

**相關用語**
+ [AWS JSON 政策元素：主體](reference_policies_elements_principal.md)
+ [IAM 中的跨帳戶資源存取](access_policies-cross-account-resource-access.md)

## 錯誤 – 政策中不支援的資源 ARN
<a name="access-analyzer-reference-policy-checks-error-unsupported-resource-arn-in-policy"></a>

**問題代碼：**UNSUPPORTED\$1RESOURCE\$1ARN\$1IN\$1POLICY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported resource ARN in policy: The resource ARN is not supported for the resource-based policy attached to the resource type {{resourceType}}.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The resource ARN is not supported for the resource-based policy attached to the resource type {{resourceType}}."
```

**解決錯誤**

當資源型政策連接至不同的資源類型時，部分資源 ARN 在此政策的 `Resource` 元素中不受支援。例如，Amazon S3 儲存貯體政策的 `Resource`元素不支援 AWS KMS ARNs。指定連接至資源型政策的資源類型支援的資源 ARN。

**相關用語**
+ [JSON 政策元素：動作](reference_policies_elements_action.md)

## 錯誤 – 不支援的 Sid
<a name="access-analyzer-reference-policy-checks-error-unsupported-sid"></a>

**問題代碼：**UNSUPPORTED\$1SID

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported Sid: Update the characters in the Sid element to use one of the following character types: [a-z, A-Z, 0-9]
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Update the characters in the Sid element to use one of the following character types: [a-z, A-Z, 0-9]"
```

**解決錯誤**

`Sid` 元素支援大寫字母，小寫字母和數字。

**相關用語**
+ [IAM JSON 政策元素：Sid](reference_policies_elements_sid.md)

## 錯誤 – 主體中不支援的萬用字元
<a name="access-analyzer-reference-policy-checks-error-unsupported-wildcard-in-principal"></a>

**問題代碼：**UNSUPPORTED\$1WILDCARD\$1IN\$1PRINCIPAL

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported wildcard in principal: Wildcards (*, ?) are not supported with the principal key {{principal_key}}. Replace the wildcard with a valid principal value.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Wildcards (*, ?) are not supported with the principal key {{principal_key}}. Replace the wildcard with a valid principal value."
```

**解決錯誤**

`Principal` 元素結構支援使用鍵值組。政策中指定的主體值包括萬用字元 (\$1)。您不能在指定的主體鍵中包含萬用字元。例如，當您在 `Principal` 元素中指定使用者時，您無法使用萬用字元來表示「所有使用者」。您必須命名特定的一個或多個使用者。同樣地，當您指定擔任的角色工作階段時，您無法使用萬用字元來表示「所有工作階段」。您必須命名特定工作階段。您同樣不能使用萬用字元來符合部分名稱或 ARN。

若要解決此問題清單，請移除萬用字元，並提供更具體的主體。

**相關用語**
+ [AWS JSON 政策元素：主體](reference_policies_elements_principal.md)

## 錯誤 – 變數中缺少大括號
<a name="access-analyzer-reference-policy-checks-error-missing-brace-in-variable"></a>

**問題代碼：**MISING\$1BRACE\$1IN\$1VARIABLE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing brace in variable: The policy variable is missing a closing curly brace. Add } after the variable text.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The policy variable is missing a closing curly brace. Add } after the variable text."
```

**解決錯誤**

政策變數結構支援使用 `$` 字首，後面接著一對大括號 (`{ }`)。在 `${ }` 字元內，包含要在政策中想要使用的請求中的值的名稱。

若要解決此問題清單，請新增遺失的大括號，以確定一組完整的大括號開頭和結尾已存在。

**相關用語**
+ [IAM 政策元素：變數](reference_policies_variables.md)

## 錯誤 – 變數中缺少引號
<a name="access-analyzer-reference-policy-checks-error-missing-quote-in-variable"></a>

**問題代碼：**MISSING\$1QUOTE\$1IN\$1VARIABLE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing quote in variable: The policy variable default value must begin and end with a single quote. Add the missing quote.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The policy variable default value must begin and end with a single quote. Add the missing quote."
```

**解決錯誤**

將變數新增至政策時，您可以指定變數的預設值。如果變數不存在， AWS 會使用您提供的預設文字。

若要將預設值新增到一個變數，請以單引號 (`' '`) 括住預設值，並使用逗號和空格 (`, `) 分隔變數文字和預設值。

例如，如果主體標記為 `team=yellow`，他們可以存取名為 `amzn-s3-demo-bucket-yellow` 的 `amzn-s3-demo-bucket` Amazon S3 儲存貯體。具有此資源的政策可讓團隊成員存取其自己的資源，但不能存取其他團隊的資源。對於沒有團隊標籤的使用者，您可以將預設值設定為 `company-wide`。這些使用者只能存取 `amzn-s3-demo-bucket-company-wide` 儲存貯體，其中他們可以檢視廣泛的資訊，例如加入團隊的指示。

```
"Resource":"arn:aws:s3:::amzn-s3-demo-bucket-${aws:PrincipalTag/team, 'company-wide'}"
```

**相關用語**
+ [IAM 政策元素：變數](reference_policies_variables.md)

## 錯誤 – 變數中不支援的空間
<a name="access-analyzer-reference-policy-checks-error-unsupported-space-in-variable"></a>

**問題代碼：**UNSUPPORTED\$1SPACE\$1IN\$1VARIABLE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported space in variable: A space is not supported within the policy variable text. Remove the space.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "A space is not supported within the policy variable text. Remove the space."
```

**解決錯誤**

政策變數結構支援使用 `$` 字首，後面接著一對大括號 (`{ }`)。在 `${ }` 字元內，包含要在政策中想要使用的請求中的值的名稱。雖然您在指定預設變數時可以包含空格，但不能在變數名稱中包含空格。

**相關用語**
+ [IAM 政策元素：變數](reference_policies_variables.md)

## 錯誤 – 空的變數
<a name="access-analyzer-reference-policy-checks-error-empty-variable"></a>

**問題代碼：**EMPTY\$1VARIABLE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty variable: Empty policy variable. Remove the ${ } variable structure or provide a variable within the structure.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Empty policy variable. Remove the ${ } variable structure or provide a variable within the structure."
```

**解決錯誤**

政策變數結構支援使用 `$` 字首，後面接著一對大括號 (`{ }`)。在 `${ }` 字元內，包含要在政策中想要使用的請求中的值的名稱。

**相關用語**
+ [IAM 政策元素：變數](reference_policies_variables.md)

## 錯誤 – 元素中不支援變數
<a name="access-analyzer-reference-policy-checks-error-variable-unsupported-in-element"></a>

**問題代碼：**VARIABLE\$1UNSUPPORTED\$1IN\$1ELEMENT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Variable unsupported in element: Policy variables are supported in the Resource and Condition elements. Remove the policy variable {{variable}} from this element.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Policy variables are supported in the Resource and Condition elements. Remove the policy variable {{variable}} from this element."
```

**解決錯誤**

您可以在 `Resource` 元素中使用政策變數，也可以在 `Condition` 元素中使用字串比較。

**相關用語**
+ [IAM 政策元素：變數](reference_policies_variables.md)

## 錯誤 – 版本中不支援變數
<a name="access-analyzer-reference-policy-checks-error-variable-unsupported-in-version"></a>

**問題代碼：**VARIABLE\$1UNSUPPORTED\$1IN\$1VERSION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Variable unsupported in version: To include variables in your policy, use the policy version 2012-10-17 or later.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "To include variables in your policy, use the policy version 2012-10-17 or later."
```

**解決錯誤**

若要使用政策變數，必須包含 `Version` 元素，並將其設定為支援政策變數的版本。變數已導入版本 `2012-10-17`。舊版的政策語言不支援政策變數。如果您未將 `Version` 設定為 `2012-10-17` 或更高版本，則 `${aws:username}` 等變數會被視為政策中的常值字串。

`Version` 政策元素與政策版本不同。`Version` 政策元素是在政策內使用，並定義政策語言的版本。政策版本會在您在 IAM 中變更客戶受管政策時建立。變更的政策不會覆寫現有的政策。反而，IAM 會建立新版本的受管政策。

**相關用語**
+ [IAM 政策元素：變數](reference_policies_variables.md)
+ [IAM JSON 政策元素：版本](reference_policies_elements_version.md)

## 錯誤 – 私有 IP 地址
<a name="access-analyzer-reference-policy-checks-error-private-ip-address"></a>

**問題代碼：**PRIVATE\$1IP\$1ADDRESS

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Private IP address: aws:SourceIp works only for public IP address ranges. The values for condition key aws:SourceIp include only private IP addresses and will not have the desired effect. Update the value to include only public IP addresses.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "aws:SourceIp works only for public IP address ranges. The values for condition key aws:SourceIp include only private IP addresses and will not have the desired effect. Update the value to include only public IP addresses."
```

**解決錯誤**

全域條件鍵 `aws:SourceIp` 僅適用於公有 IP 地址範圍。當您的政策只允許私有 IP 地址時，您會收到此錯誤。在這種情況下，條件永遠不會符合。
+ [aws:SourceIp 全域條件鍵](reference_policies_condition-keys.md#condition-keys-sourceip)
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 錯誤 – 私有 NotIpAddress
<a name="access-analyzer-reference-policy-checks-error-private-not-ip-address"></a>

**問題代碼：**PRIVATE\$1NOT\$1IP\$1ADDRESS

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Private NotIpAddress: The values for condition key aws:SourceIp include only private IP addresses and has no effect. aws:SourceIp works only for public IP address ranges. Update the value to include only public IP addresses.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The values for condition key aws:SourceIp include only private IP addresses and has no effect. aws:SourceIp works only for public IP address ranges. Update the value to include only public IP addresses."
```

**解決錯誤**

全域條件鍵 `aws:SourceIp` 僅適用於公有 IP 地址範圍。當您使用 `NotIpAddress` 條件運算子，並只列出私有 IP 位址時，您會收到這個錯誤。在此情況下，條件會一律符合且為無效。
+ [aws:SourceIp 全域條件鍵](reference_policies_condition-keys.md#condition-keys-sourceip)
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 錯誤 – 政策大小超過 SCP 配額
<a name="access-analyzer-reference-policy-checks-error-policy-size-exceeds-scp-quota"></a>

**問題代碼：**POLICY\$1SIZE\$1EXCEEDS\$1SCP\$1QUOTA

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Policy size exceeds SCP quota: The {{policySize}} characters in the service control policy (SCP) exceed the {{policySizeQuota}} character maximum for SCPs. We recommend that you use multiple granular policies.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The {{policySize}} characters in the service control policy (SCP) exceed the {{policySizeQuota}} character maximum for SCPs. We recommend that you use multiple granular policies."
```

**解決錯誤**

AWS Organizations 服務控制政策 SCPs) 支援在 `Action`或 `NotAction`元素中指定值。不過，這些值只能在字串結尾包含萬用字元 (\$1)。這表示您可指定 `iam:Get*` 而不是 `iam:*role`。

若要指定多個動作， AWS 建議您個別列出這些動作。

**相關用語**
+ [AWS Organizations 配額](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_limits.html)
+ [AWS Organizations 服務控制政策](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html)

## 錯誤 — 無效的服務委託人格式
<a name="access-analyzer-reference-policy-checks-error-invalid-service-principal-format"></a>

**問題代碼：**INVALID\$1SERVICE\$1PRINCIPAL\$1FORMAT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid service principal format: The service principal does not match the expected format. Use the format {{expectedFormat}}.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The service principal does not match the expected format. Use the format {{expectedFormat}}."
```

**解決錯誤**

條件鍵值組中的值必須符合已定義的服務主體格式。

*服務主體*是用來將許可授予給服務的識別符。您可以在 `Principal` 元素中指定服務主體，或將其作為某些全域條件鍵和服務特定鍵的值。服務主體是由每個服務定義。

服務主體的識別符包含服務名稱，而且通常採用以下全小寫字母格式：

`service-name.amazonaws.com`

某些服務特定鍵可能會針對服務主體使用不同的格式。例如，`kms:ViaService` 條件鍵需要下列全小寫字母格式的服務主體：

`service-name.AWS_region.amazonaws.com`

**相關用語**
+ [服務主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services)
+ [AWS 全域條件索引鍵](reference_policies_condition-keys.md)
+ [`kms:ViaService` 條件鍵](https://docs.aws.amazon.com/kms/latest/developerguide/policy-conditions.html#conditions-kms-via-service)

## 錯誤 – 條件中缺少標籤鍵
<a name="access-analyzer-reference-policy-checks-error-missing-tag-key-in-condition"></a>

**問題代碼：**MISING\$1TAG\$1KEY\$1IN\$1CONDITION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing tag key in condition: The condition key {{conditionKeyName}} must include a tag key to control access based on tags. Use the format {{conditionKeyName}}tag-key and specify a key name for tag-key.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition key {{conditionKeyName}} must include a tag key to control access based on tags. Use the format {{conditionKeyName}}tag-key and specify a key name for tag-key."
```

**解決錯誤**

若要根據標籤控制存取，則在政策的[條件元素](reference_policies_elements_condition.md)中提供標籤資訊。

例如，若要[控制對 AWS 資源的存取](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html#access_tags_control-resources)，請包含 `aws:ResourceTag` 條件金鑰。此鍵需要格式 `aws:ResourceTag/tag-key`。如需指定條件中的標籤鍵 `owner` 和標籤值 `JaneDoe`，請使用下列格式。

```
"Condition": {
    "StringEquals": {"aws:ResourceTag/owner": "JaneDoe"}
}
```

**相關用語**
+ [使用標籤控制存取權限](access_iam-tags.md)
+ [條件](reference_policies_elements_condition.md)
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [AWS 服務條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 - vpc 格式無效
<a name="access-analyzer-reference-policy-checks-error-invalid-vpc-format"></a>

**問題代碼：**INVALID\$1VPC\$1FORMAT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid vpc format: The VPC identifier in the condition key value is not valid. Use the prefix 'vpc-' followed by 8 or 17 alphanumeric characters.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The VPC identifier in the condition key value is not valid. Use the prefix 'vpc-' followed by 8 or 17 alphanumeric characters."
```

**解決錯誤**

此 `aws:SourceVpc` 條件鍵必須使用字首 `vpc-`，後跟 8 或 17 個英數字元，例如 `vpc-11223344556677889` 或 `vpc-12345678`。

**相關用語**
+ [AWS 全域條件索引鍵：aws：SourceVpc](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcevpc)

## 錯誤 - vpce 格式無效
<a name="access-analyzer-reference-policy-checks-error-invalid-vpce-format"></a>

**問題代碼：**INVALID\$1VPCE\$1FORMAT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid vpce format: The VPCE identifier in the condition key value is not valid.  Use the prefix 'vpce-' followed by 8 or 17 alphanumeric characters.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The VPCE identifier in the condition key value is not valid.  Use the prefix 'vpce-' followed by 8 or 17 alphanumeric characters."
```

**解決錯誤**

此 `aws:SourceVpce` 條件鍵必須使用字首 `vpce-`，後跟 8 或 17 個英數字元，例如 `vpce-11223344556677889` 或 `vpce-12345678`。

**相關用語**
+ [AWS 全域條件索引鍵：aws：SourceVpce](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcevpce)

## 錯誤 - 不支援聯合身分主體
<a name="access-analyzer-reference-policy-checks-error-federated-principal-not-supported"></a>

**問題代碼：**FEDERATED\$1PRINCIPAL\$1NOT\$1SUPPORTED

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Federated principal not supported: The policy type does not support a federated identity provider in the principal element. Use a supported principal.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The policy type does not support a federated identity provider in the principal element. Use a supported principal."
```

**解決錯誤**

此 `Principal` 元素將聯合身分主體用於連接至 IAM 角色的信任政策，以透過聯合身分提供存取權。身分政策和其他資源型曾策不支援 `Principal` 元素中的聯合身分提供者。例如，您無法在 Amazon S3 儲存貯體政策中使用 SAML 主體。將 `Principal` 元素變更為支援的主體類型。

**相關用語**
+ [為聯合身分建立角色](id_roles_create_for-idp.md)
+ [JSON 政策元素：主體](reference_policies_elements_principal.md)

## 錯誤 - 條件鍵不支援的動作
<a name="access-analyzer-reference-policy-checks-error-unsupported-action-for-condition-key"></a>

**問題代碼：**UNSUPPORTED\$1ACTION\$1FOR\$1CONDITION\$1KEY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported action for condition key: The following actions: {{actions}} are not supported by the condition key {{key}}. The condition will not be evaluated for these actions. We recommend that you move these actions to a different statement without this condition key.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The following actions: {{actions}} are not supported by the condition key {{key}}. The condition will not be evaluated for these actions. We recommend that you move these actions to a different statement without this condition key."
```

**解決錯誤**

請確保政策陳述式的 `Condition` 元素中的條件鍵會套用至 `Action` 元素中的每個動作。若要確保政策有效地允許或拒絕您指定的動作，您應該將不支援的動作移至不同的陳述式，而不使用條件鍵。

**注意**  
如果 `Action` 元素具有包含萬用字元的動作，則 IAM Access Analyzer 不會評估這些動作是否存在此錯誤。

**相關用語**
+ [JSON 政策元素：動作](reference_policies_elements_action.md)

## 錯誤 - 政策中不支援的動作
<a name="access-analyzer-reference-policy-checks-error-unsupported-action-in-policy"></a>

**問題代碼：**UNSUPPORTED\$1ACTION\$1IN\$1POLICY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported action in policy: The action {{action}} is not supported for the resource-based policy attached to the resource type {{resourceType}}.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The action {{action}} is not supported for the resource-based policy attached to the resource type {{resourceType}}."
```

**解決錯誤**

在連接至不同資源類型的資源型政策中，部分動作在其 `Action` 元素中不受支援。例如，Amazon S3 儲存貯體政策不支援 AWS Key Management Service 動作。指定連接至資源型政策的資源類型支援的動作。

**相關用語**
+ [JSON 政策元素：動作](reference_policies_elements_action.md)

## 錯誤 – 政策中不支援的資源 ARN
<a name="access-analyzer-reference-policy-checks-error-unsupported-resource-arn-in-policy"></a>

**問題代碼：**UNSUPPORTED\$1RESOURCE\$1ARN\$1IN\$1POLICY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported resource ARN in policy: The resource ARN is not supported for the resource-based policy attached to the resource type {{resourceType}}.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The resource ARN is not supported for the resource-based policy attached to the resource type {{resourceType}}."
```

**解決錯誤**

當資源型政策連接至不同的資源類型時，部分資源 ARN 在此政策的 `Resource` 元素中不受支援。例如，Amazon S3 儲存貯體政策的 `Resource`元素不支援 AWS KMS ARNs。指定連接至資源型政策的資源類型支援的資源 ARN。

**相關用語**
+ [JSON 政策元素：動作](reference_policies_elements_action.md)

## 錯誤 - 服務主體不支援的條件鍵
<a name="access-analyzer-reference-policy-checks-error-unsupported-condition-key-for-service-principal"></a>

**問題代碼：**UNSUPPORTED\$1CONDITION\$1KEY\$1FOR\$1SERVICE\$1PRINCIPAL

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unsupported condition key for service principal: The following condition keys are not supported when used with the service principal: {{conditionKeys}}.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The following condition keys are not supported when used with the service principal: {{conditionKeys}}."
```

**解決錯誤**

您可以使用*服務委託*人在資源型政策的 `Principal`元素 AWS 服務 中指定 ，這是服務的識別符。您無法將某些條件鍵與特定服務主體搭配使用。例如，您無法將 `aws:PrincipalOrgID` 條件鍵與服務主體 `cloudfront.amazonaws.com` 搭配使用。您應該移除不適用於 `Principal` 元素中服務主體的條件鍵。

**相關用語**
+ [服務主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services)
+ [JSON 政策元素：主體](reference_policies_elements_principal.md)

## 錯誤 – 角色信任政策語法錯誤：NotPrincipal
<a name="access-analyzer-reference-policy-checks-error-role-trust-policy-syntax-error-notprincipal"></a>

**問題代碼：**ROLE\$1TRUST\$1POLICY\$1SYNTAX\$1ERROR\$1NOTPRINCIPAL

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Role trust policy syntax error notprincipal: Role trust policies do not support NotPrincipal. Update the policy to use a Principal element instead.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Role trust policies do not support NotPrincipal. Update the policy to use a Principal element instead."
```

**解決錯誤**

角色信任政策是連接至 IAM 角色的以資源為基礎的政策。信任政策會定義哪些主體實體 (帳戶、使用者、角色和聯合身分使用者) 可擔任該角色。角色信任原則不支援 `NotPrincipal`。更新政策以改為使用 `Principal` 元素。

**相關用語**
+ [JSON 政策元素：主體](reference_policies_elements_principal.md)
+ [JSON 政策元素：NotPrincipal](reference_policies_elements_notprincipal.md)

## 錯誤 – 角色信任政策不支援在主體中使用萬用字元
<a name="access-analyzer-reference-policy-checks-error-role-trust-policy-unsupported-wildcard-in-principal"></a>

**問題代碼：**ROLE\$1TRUST\$1POLICY\$1UNSUPPORTED\$1WILDCARD\$1IN\$1PRINCIPAL

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Role trust policy unsupported wildcard in principal: "Principal:" "*" is not supported in the principal element of a role trust policy. Replace the wildcard with a valid principal value.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": ""Principal:" "*" is not supported in the principal element of a role trust policy. Replace the wildcard with a valid principal value."
```

**解決錯誤**

角色信任政策是連接至 IAM 角色的以資源為基礎的政策。信任政策會定義哪些主體實體 (帳戶、使用者、角色和聯合身分使用者) 可擔任該角色。在角色信任政策的 `Principal` 元素中不支援 `"Principal:" "*"`。以有效的主體值取代萬用字元。

**相關用語**
+ [JSON 政策元素：主體](reference_policies_elements_principal.md)

## 錯誤 – 角色信任政策語法錯誤：Resource
<a name="access-analyzer-reference-policy-checks-error-role-trust-policy-syntax-error-resource"></a>

**問題代碼：**ROLE\$1TRUST\$1POLICY\$1SYNTAX\$1ERROR\$1RESOURCE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Role trust policy syntax error resource: Role trust policies apply to the role that they are attached to. You cannot specify a resource. Remove the Resource or NotResource element.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Role trust policies apply to the role that they are attached to. You cannot specify a resource. Remove the Resource or NotResource element."
```

**解決錯誤**

角色信任政策是連接至 IAM 角色的以資源為基礎的政策。信任政策會定義哪些主體實體 (帳戶、使用者、角色和聯合身分使用者) 可擔任該角色。角色信任政策會套用至它們所連接的角色。您不能在角色信任政策中指定 `Resource` 或 `NotResource` 元素。移除 `Resource` 或 `NotResource` 元素。
+ [JSON 政策元素：Resource](reference_policies_elements_resource.md)
+ [JSON 政策元素：NotResource](reference_policies_elements_notresource.md)

## 錯誤 – 類型與 IP 範圍不符
<a name="access-analyzer-reference-policy-checks-error-type-mismatch-ip-range"></a>

**問題代碼：**TYPE\$1MISMATCH\$1IP\$1RANGE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Type mismatch IP range: The condition operator {{operator}} is used with an invalid IP range value. Specify the IP range in standard CIDR format.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition operator {{operator}} is used with an invalid IP range value. Specify the IP range in standard CIDR format."
```

**解決錯誤**

更新文字以使用 CIDR 格式的 IP 地址條件運算子資料類型。

**相關用語**
+ [IP 地址條件運算子](reference_policies_elements_condition_operators.md#Conditions_IPAddress)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)

## 錯誤 – 缺少條件鍵動作
<a name="access-analyzer-reference-policy-checks-error-missing-action-for-condition-key"></a>

**問題代碼：**MISING\$1ACTION\$1FOR\$1CONDITION\$1KEY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing action for condition key: The {{actionName}} action must be in the action block to allow setting values for the condition key {{keyName}}. Add {{actionName}} to the action block.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The {{actionName}} action must be in the action block to allow setting values for the condition key {{keyName}}. Add {{actionName}} to the action block."
```

**解決錯誤**

除非指定的動作位於 `Action` 元素中，否則不會評估政策陳述式的 `Condition` 元素中的條件鍵。若要確保政策有效地允許或拒絕您指定的條件鍵，請將動作新增至 `Action` 元素。

**相關用語**
+ [JSON 政策元素：動作](reference_policies_elements_action.md)

## 錯誤 – 角色信任政策中的聯合主體語法無效
<a name="access-analyzer-reference-policy-checks-error-invalid-federated-principal-syntax-in-role-trust-policy"></a>

**問題代碼：**INVALID\$1FEDERATED\$1PRINCIPAL\$1SYNTAX\$1IN\$1ROLE\$1TRUST\$1POLICY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid federated principal syntax in role trust policy: The principal value specifies a federated principal that does not match the expected format. Update the federated principal to a domain name or a SAML metadata ARN.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The principal value specifies a federated principal that does not match the expected format. Update the federated principal to a domain name or a SAML metadata ARN."
```

**解決錯誤**

主體值指定與預期格式不相符的聯合主體。將聯合主體的格式更新為有效的網域名稱或 SAML 中繼資料 ARN。

**相關用語**
+ [聯合身分使用者和角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction_access-management.html#intro-access-roles)

## 錯誤 – 主體的不相符動作
<a name="access-analyzer-reference-policy-checks-error-mismatched-action-for-principal"></a>

**問題代碼：**MISMATCHED\$1ACTION\$1FOR\$1PRINCIPAL

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Mismatched action for principal: The {{actionName}} action is invalid with the following principal(s): {{principalNames}}. Use a SAML provider principal with the sts:AssumeRoleWithSAML action or use an OIDC provider principal with the sts:AssumeRoleWithWebIdentity action. Ensure the provider is Federated if you use either of the two options.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The {{actionName}} action is invalid with the following principal(s): {{principalNames}}. Use a SAML provider principal with the sts:AssumeRoleWithSAML action or use an OIDC provider principal with the sts:AssumeRoleWithWebIdentity action. Ensure the provider is Federated if you use either of the two options."
```

**解決錯誤**

對於 `Principal` 元素中指定的主體，政策陳述式的 `Action` 元素中指定的動作無效。例如，您無法將 SAML 提供者主體與 `sts:AssumeRoleWithWebIdentity` 動作結合使用。您應該將 SAML 提供者主體與 `sts:AssumeRoleWithSAML` 動作結合使用，或者將 OIDC 提供者主體與 `sts:AssumeRoleWithWebIdentity` 動作結合使用。

**相關用語**
+ [AssumeRoleWithSAML](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithSAML.html)
+ [AssumeRoleWithWebIdentity](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html)

## 錯誤 – 缺少 Roles Anywhere 信任政策的動作
<a name="access-analyzer-reference-policy-checks-error-missing-action-for-roles-anywhere-trust-policy"></a>

**問題代碼：**MISSING\$1ACTION\$1FOR\$1ROLES\$1ANYWHERE\$1TRUST\$1POLICY

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing action for roles anywhere trust policy: The rolesanywhere.amazonaws.com service principal requires the sts:AssumeRole, sts:SetSourceIdentity, and sts:TagSession permissions to assume a role. Add the missing permissions to the policy.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The rolesanywhere.amazonaws.com service principal requires the sts:AssumeRole, sts:SetSourceIdentity, and sts:TagSession permissions to assume a role. Add the missing permissions to the policy."
```

**解決錯誤**

為了讓 IAM Roles Anywhere 能夠擔任角色並提供臨時的 AWS 憑證，角色必須信任 IAM Roles Anywhere 服務主體。IAM Roles Anywhere 服務主體需要 `sts:AssumeRole`、`sts:SetSourceIdentity` 和 `sts:TagSession` 許可來擔任角色。如果缺少這些許可中的任何一個，您必須將它們新增至政策。

**相關用語**
+ [AWS Identity and Access Management Roles Anywhere 中的信任模型](https://docs.aws.amazon.com/rolesanywhere/latest/userguide/trust-model.html)

## 錯誤 – 政策大小超過 RCP 配額
<a name="access-analyzer-reference-policy-checks-error-policy-size-exceeds-rcp-quota"></a>

**問題代碼：**POLICY\$1SIZE\$1EXCEEDS\$1RCP\$1QUOTA

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Policy size exceeds RCP quota: The {{policySize}} characters in the resource control policy (RCP) exceed the {{policySizeQuota}} character maximum for RCPs. We recommend that you use multiple granular policies.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The {{policySize}} characters in the resource control policy (RCP) exceed the {{policySizeQuota}} character maximum for RCPs. We recommend that you use multiple granular policies."
```

**解決錯誤**

AWS Organizations 資源控制政策 RCPs) 支援在 `Action`元素中指定值。不過，這些值只能在字串結尾包含萬用字元 (\$1)。這表示您可指定 `s3:Get*` 而不是 `s3:*Object`。

若要指定多個動作， AWS 建議您個別列出這些動作。

**相關用語**
+ [的配額 AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_limits.html)
+ [AWS Organizations 資源控制政策](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html)

## 錯誤 – RCP 語法錯誤主體
<a name="access-analyzer-reference-policy-checks-error-rcp-syntax-error-principal"></a>

**問題代碼：**RCP\$1SYNTAX\$1ERROR\$1PRINCIPAL

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
RCP syntax error principal: The Principal element contents are not valid. RCPs only support specifying all principals ("*") in the Principal element. The NotPrincipal element is not supported for RCPs.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The Principal element contents are not valid. RCPs only support specifying all principals ("*") in the Principal element. The NotPrincipal element is not supported for RCPs."
```

**解決錯誤**

AWS Organizations 資源控制政策 RCPs) 僅支援指定 `Principal`元素中的所有主體 ("`*`")。RCP 不支援 `NotPrincipal` 元素。

**相關用語**
+ [RCP 語法](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps_syntax.html)
+ [主體的屬性](reference_policies_condition-keys.md#condition-keys-principal-properties)

## 錯誤 – RCP 語法錯誤允許
<a name="access-analyzer-reference-policy-checks-error-rcp-syntax-error-allow"></a>

**問題代碼：**RCP\$1SYNTAX\$1ERROR\$1ALLOW

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
RCP syntax error allow: RCPs only support specifying all principals ("*") in the Principal element, all resources ("*") in the Resource element, and no Condition element with an effect of Allow.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "RCPs only support specifying all principals ("*") in the Principal element, all resources ("*") in the Resource element, and no Condition element with an effect of Allow."
```

**解決錯誤**

AWS Organizations 資源控制政策 RCPs) 僅支援指定 `Principal`元素中的所有主體 ("`*`") 和 `Resource`元素中的所有資源 ("`*`")。RCP 不支援具有 `Allow` 效果的 `Condition` 元素。

**相關用語**
+ [RCP 語法](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps_syntax.html)
+ [主體的屬性](reference_policies_condition-keys.md#condition-keys-principal-properties)
+ [資源的屬性](reference_policies_condition-keys.md#condition-keys-resource-properties)

## 錯誤 – RCP 語法錯誤 NotAction
<a name="access-analyzer-reference-policy-checks-error-rcp-syntax-error-notaction"></a>

**問題代碼：**RCP\$1SYNTAX\$1ERROR\$1NOTACTION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
RCP syntax error NotAction: RCPs do not support the NotAction element. Update to use the Action element.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "RCPs do not support the NotAction element. Update to use the Action element."
```

**解決錯誤**

AWS Organizations 資源控制政策 RCPs) 不支援 `NotAction`元素。請使用 `Action` 元素。

**相關用語**
+ [RCP 語法](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps_syntax.html)
+ [IAM JSON 政策元素：動作](reference_policies_elements_action.md)
+ [IAM JSON 政策元素：NotAction](reference_policies_elements_notaction.md)

## 錯誤 – RCP 語法錯誤動作
<a name="access-analyzer-reference-policy-checks-error-rcp-syntax-error-action"></a>

**問題代碼：**RCP\$1SYNTAX\$1ERROR\$1ACTION

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
RCP syntax error action: RCPs only support specifying select service prefixes in the Action element. Learn more here.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "RCPs only support specifying select service prefixes in the Action element. Learn more here."
```

**解決錯誤**

AWS Organizations 資源控制政策 RCPs) 僅支援在 `Action`元素中指定選取服務字首。

**相關用語**
+ [RCP 語法](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps_syntax.html)
+ [AWS 服務 支援 RCPs 清單](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html#rcp-supported-services)

## 錯誤 – Missing ARN account
<a name="access-analyzer-reference-policy-checks-error-missing-arn-account"></a>

**問題代碼：**MISSING\$1ARN\$1ACCOUNT

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing ARN account: The resource {{resourceName}} in the arn is missing an account id. Please provide a 12 digit account id.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The resource {{resourceName}} in the arn is missing an account id. Please provide a 12 digit account id."
```

**解決錯誤**

在資源 ARN 中加入帳戶 ID。帳戶 ID 是 12 位數的整數。若要了解如何檢視您的帳戶 ID，請參閱[尋找 AWS 您的帳戶 ID](https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html#FindingYourAccountIdentifiers)。

**相關用語**
+ [政策資源](reference_policies_elements_resource.md)
+ [帳戶識別符](https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html)
+ [資源 ARN](reference_identifiers.md#identifiers-arns)
+ [AWS 具有 ARN 格式的服務資源](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 錯誤 – Invalid kms key value
<a name="access-analyzer-reference-policy-checks-error-invalid-kms-key-value"></a>

**問題代碼：**INVALID\$1KMS\$1KEY\$1VALUE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid kms key value: The {{key}} condition key value must be valid a KMS key ARN.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The {{key}} condition key value must be valid a KMS key ARN."
```

**解決錯誤**

 AWS KMS key ARN (Amazon Resource Name) 是 KMS 金鑰的唯一完整識別符。金鑰 ARN 包含 AWS 帳戶、 區域和金鑰 ID。金鑰 ARN 遵循以下格式：

`arn:aws:kms:region:account-id:key/key-id`

**相關用語**
+ [尋找金鑰 ID 和金鑰 ARN](https://docs.aws.amazon.com/kms/latest/developerguide/find-cmk-id-arn.html)
+ [金鑰 ARN](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-key-ARN)
+ [AWS 全域條件內容索引鍵](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)

## 錯誤 – Variable usage too permissive
<a name="access-analyzer-reference-policy-checks-error-variable-usage-too-permissive"></a>

**問題代碼：**VARIABLE\$1USAGE\$1TOO\$1PERMISSIVE

**調查結果類型：**ERROR

**尋找詳細資訊** 

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Variable usage too permissive: Overly permissive use of policy variable for the {{key}} condition key. Use the policy variable preceded by 6 consecutive characters.
```

```
The policy variable is not allowed in the condition key {{key}}. We consider the key to be sensitive and policy variables can be evaluated as effective wildcards. Therefore policy variables are not allowed to be used with sensitive keys. Refer to https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html for the list of sensitive keys.
```

```
Overly permissive use of policy variable with aws:userID. Use the policy variable on the right side of colon or as the only character on the left side of a colon.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Overly permissive use of policy variable for the {{key}} condition key. Use the policy variable preceded by 6 consecutive characters."
```

```
"findingDetails": "The policy variable is not allowed in the condition key {{key}}. We consider the key to be sensitive and policy variables can be evaluated as effective wildcards. Therefore policy variables are not allowed to be used with sensitive keys. Refer to https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html for the list of sensitive keys."
```

```
"findingDetails": "Overly permissive use of policy variable with aws:userID. Use the policy variable on the right side of colon or as the only character on the left side of a colon."
```

**解決錯誤**

此錯誤有三種可能的調查結果訊息。
+ 對於第一種錯誤訊息，請修改政策變數用途，使變數用途更加具體。在政策變數之前新增至少 6 個連續字元，以縮小許可範圍。例如，不使用 `${aws:username}`，而是改用 `prefix-${aws:username}` 或 `myapp-${aws:username}`。這樣可以確保政策變數不會授予過於廣泛的存取權。
+ 對於第二種錯誤訊息，請從指定的條件索引鍵中移除政策變數。政策變數可以充當有效的萬用字元，但基於安全考量，不允許將其與敏感條件索引鍵一起使用。請改用特定的靜態值，或考慮重組政策，以使用支援政策變數的非敏感條件索引鍵。
+ 對於第三種錯誤訊息，請修改 `aws:userID` 政策變數用途，更加嚴格地限制其用途。將政策變數放在冒號的右側 (在帳戶 ID 之後)，或使其作為冒號左側的唯一字元。例如，使用 `AIDACKCEVSQ6C2EXAMPLE:${aws:userid}` 或 `${aws:userid}:*`，而不使用 `${aws:userid}`。

**相關用語**
+ [IAM 政策元素：變數和標籤](reference_policies_variables.md)
+ [IAM 政策元素：Condition](reference_policies_elements_condition.md)
+ [具有多個內容索引鍵或值的條件](reference_policies_condition-logic-multiple-context-keys-or-values.md)
+ [AWS 全域條件內容索引鍵](reference_policies_condition-keys.md)

## 錯誤 – Wildcard usage too permissive
<a name="access-analyzer-reference-policy-checks-error-wildcard-usage-too-permissive"></a>

**問題代碼：**WILDCARD\$1USAGE\$1TOO\$1PERMISSIVE

**調查結果類型：**ERROR

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Wildcard usage too permissive: Overly permissive use of wildcard for the {{key}} condition key. Use the wildcard preceded by 6 consecutive characters.
```

```
The wildcard is not allowed in the condition key {{key}}. We consider the key to be sensitive and wildcards are not allowed to be used with sensitive keys. Refer to https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html for the list of sensitive keys.
```

```
Overly permissive use of wildcard with aws:userID. Use the wildcard on the right side of colon or as the only character on the left side of a colon.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Overly permissive use of wildcard for the {{key}} condition key. Use the wildcard preceded by 6 consecutive characters."
```

```
"findingDetails": "The wildcard is not allowed in the condition key {{key}}. We consider the key to be sensitive and wildcards are not allowed to be used with sensitive keys. Refer to https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html for the list of sensitive keys."
```

```
"findingDetails": "Overly permissive use of wildcard with aws:userID. Use the wildcard on the right side of colon or as the only character on the left side of a colon."
```

**解決錯誤**

此錯誤有三種可能的調查結果訊息。
+ 對於第一種錯誤訊息，請在萬用字元之前新增至少 6 個連續字元，使萬用字元用途更加具體。例如，不使用 `*`，而是改用 `prefix-*` 或 `prefix-*-suffix`。這樣可以縮小條件的範圍，並遵循最低權限原則。
+ 對於第二種錯誤訊息，請從指定的條件索引鍵中移除萬用字元。基於安全考量，不允許將萬用字元與敏感條件索引鍵一起使用。將萬用字元取代為符合預期存取模式的特定值，或考慮使用支援萬用字元的其他非敏感條件索引鍵。
+ 對於第三種錯誤訊息，請修改 `aws:userID` 萬用字元用途，更加嚴格地限制其用途。將萬用字元放在冒號的右側 (在帳戶 ID 之後)，或使其作為冒號左側的唯一字元。例如，使用 `AIDACKCEVSQ6C2EXAMPLE:*` 或 `*:*`，而不使用 `*`。

**相關用語**
+ [IAM 政策元素：Condition](reference_policies_elements_condition.md)
+ [具有多個內容索引鍵或值的條件](reference_policies_condition-logic-multiple-context-keys-or-values.md)
+ [AWS 全域條件內容索引鍵](reference_policies_condition-keys.md)
+ [IAM 識別符](reference_identifiers.md)

## 一般警告 – 使用 NotResource 建立 SLR
<a name="access-analyzer-reference-policy-checks-general-warning-create-slr-with-not-resource"></a>

**問題代碼：**CREATE\$1SLR\$1WITH\$1NOT\$1RESOURCE

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Create SLR with NotResource: Using the iam:CreateServiceLinkedRole action with NotResource can allow creation of unintended service-linked roles for multiple resources. We recommend that you specify resource ARNs instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using the iam:CreateServiceLinkedRole action with NotResource can allow creation of unintended service-linked roles for multiple resources. We recommend that you specify resource ARNs instead."
```

**解決一般警告**

動作會`iam:CreateServiceLinkedRole`授予許可，以建立允許 AWS 服務代表您執行動作的 IAM 角色。在政策中使用 `iam:CreateServiceLinkedRole` 與 `NotResource` 元素可允許為多個資源建立非預期的服務連結角色。 AWS 建議您改為在 `Resource` 元素中指定允許的 ARN。
+ [CreateServiceLinkedRole 操作](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateServiceLinkedRole.html)
+ [IAM JSON 政策元素：NotResource](reference_policies_elements_notresource.md)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

## 一般警告 – 使用動作中的星號和 NotResource 建立 SLR
<a name="access-analyzer-reference-policy-checks-general-warning-create-slr-with-star-in-action-and-not-resource"></a>

**問題代碼：**CREATE\$1SLR\$1WITH\$1STAR\$1IN\$1ACTION\$1AND\$1NOT\$1RESOURCE

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Create SLR with star in action and NotResource: Using an action with a wildcard(*) and NotResource can allow creation of unintended service-linked roles because it can allow iam:CreateServiceLinkedRole permissions on multiple resources. We recommend that you specify resource ARNs instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using an action with a wildcard(*) and NotResource can allow creation of unintended service-linked roles because it can allow iam:CreateServiceLinkedRole permissions on multiple resources. We recommend that you specify resource ARNs instead."
```

**解決一般警告**

動作會`iam:CreateServiceLinkedRole`授予許可，以建立允許 AWS 服務代表您執行動作的 IAM 角色。`Action` 中包含萬用字元 (\$1) 與包含 `NotResource` 元素的政策可允許為多個資源建立非預期的服務連結角色。 AWS 建議您改為在 `Resource` 元素中指定允許的 ARN。
+ [CreateServiceLinkedRole 操作](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateServiceLinkedRole.html)
+ [IAM JSON 政策元素：NotResource](reference_policies_elements_notresource.md)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

## 一般警告 – 使用 NotAction 和 NotResource 建立 SLR
<a name="access-analyzer-reference-policy-checks-general-warning-create-slr-with-not-action-and-not-resource"></a>

**問題代碼：**CREATE\$1SLR\$1WITH\$1NOT\$1ACTION\$1AND\$1NOT\$1RESOURCE

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Create SLR with NotAction and NotResource: Using NotAction with NotResource can allow creation of unintended service-linked roles because it allows iam:CreateServiceLinkedRole permissions on multiple resources. We recommend that you specify resource ARNs instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using NotAction with NotResource can allow creation of unintended service-linked roles because it allows iam:CreateServiceLinkedRole permissions on multiple resources. We recommend that you specify resource ARNs instead."
```

**解決一般警告**

動作會`iam:CreateServiceLinkedRole`授予許可，以建立允許 AWS 服務代表您執行動作的 IAM 角色。使用 `NotAction` 元素與 `NotResource` 元素可允許為多個資源建立非預期的服務連結角色。 AWS 建議您重寫政策，以改為在 `Resource` 元素中允許有限 ARN 清單上的 `iam:CreateServiceLinkedRole`。您也可以將 `iam:CreateServiceLinkedRole` 新增到 `NotAction` 元素。
+ [CreateServiceLinkedRole 操作](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateServiceLinkedRole.html)
+ [IAM JSON 政策元素：NotAction](reference_policies_elements_notaction.md)
+ [IAM JSON 政策元素：動作](reference_policies_elements_action.md)
+ [IAM JSON 政策元素：NotResource](reference_policies_elements_notresource.md)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

## 一般警告 – 使用資源中的星號建立 SLR
<a name="access-analyzer-reference-policy-checks-general-warning-create-slr-with-star-in-resource"></a>

**問題代碼：**CREATE\$1SLR\$1WITH\$1STAR\$1IN\$1RESOURCE

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Create SLR with star in resource: Using the iam:CreateServiceLinkedRole action with wildcards (*) in the resource can allow creation of unintended service-linked roles. We recommend that you specify resource ARNs instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using the iam:CreateServiceLinkedRole action with wildcards (*) in the resource can allow creation of unintended service-linked roles. We recommend that you specify resource ARNs instead."
```

**解決一般警告**

動作會`iam:CreateServiceLinkedRole`授予許可，以建立允許 AWS 服務代表您執行動作的 IAM 角色。在政策中使用 `iam:CreateServiceLinkedRole` 與 `Resource` 元素中的萬用字元 (\$1) 可允許為多個資源建立非預期的服務連結角色。 AWS 建議您改為在 `Resource` 元素中指定允許的 ARN。
+ [CreateServiceLinkedRole 操作](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateServiceLinkedRole.html)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

### AWS 具有此一般警告的 受管政策
<a name="accan-ref-policy-check-message-fix-general-warning-create-slr-with-star-in-resource-awsmanpol"></a>

[AWS 受管政策](access_policies_managed-vs-inline.md#aws-managed-policies)可讓您根據一般 AWS 使用案例指派許可 AWS ，以開始使用 。

其中一些使用案例適用於您帳戶中的進階使用者。下列 AWS 受管政策提供進階使用者存取權，並授予許可，為任何 [服務建立服務連結角色](id_roles_create-service-linked-role.md)。 AWS 建議您僅將下列 AWS 受管政策連接到您認為進階使用者的 IAM 身分。 AWS 
+ [PowerUserAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/PowerUserAccess)
+ [AlexaForBusinessFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AlexaForBusinessFullAccess)
+ [AWSOrganizationsServiceTrustPolicy](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AWSOrganizationsServiceTrustPolicy) – 此 AWS 受管政策提供由 AWS Organizations 服務連結角色使用的許可。此角色可讓 Organizations 為 AWS 組織中的其他 服務建立額外的服務連結角色。

## 一般警告 – 使用動作中的星號和資源建立 SLR
<a name="access-analyzer-reference-policy-checks-general-warning-create-slr-with-star-in-action-and-resource"></a>

**問題代碼：**CREATE\$1SLR\$1WITH\$1STAR\$1IN\$1ACTION\$1AND\$1RESOURCE

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Create SLR with star in action and resource: Using wildcards (*) in the action and the resource can allow creation of unintended service-linked roles because it allows iam:CreateServiceLinkedRole permissions on all resources. We recommend that you specify resource ARNs instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using wildcards (*) in the action and the resource can allow creation of unintended service-linked roles because it allows iam:CreateServiceLinkedRole permissions on all resources. We recommend that you specify resource ARNs instead."
```

**解決一般警告**

動作會`iam:CreateServiceLinkedRole`授予許可，以建立允許 AWS 服務代表您執行動作的 IAM 角色。`Action` 和 `Resource` 元素中包含萬用字元 (\$1) 的政策可允許為多個資源建立非預期的服務連結角色。這可讓您在指定 `"Action": "*"`、 `"Action": "iam:*"`或 時建立服務連結角色`"Action": "iam:Create*"`。 AWS 建議您改為在 `Resource`元素中指定允許的 ARNs。
+ [CreateServiceLinkedRole 操作](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateServiceLinkedRole.html)
+ [IAM JSON 政策元素：動作](reference_policies_elements_action.md)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

### AWS 具有此一般警告的 受管政策
<a name="accan-ref-policy-check-message-fix-general-warning-create-slr-with-star-in-action-and-resource-awsmanpol"></a>

[AWS 受管政策](access_policies_managed-vs-inline.md#aws-managed-policies)可讓您根據一般 AWS 使用案例指派許可 AWS ，以開始使用 。

其中一些使用案例適用於您帳戶中的系統管理員。下列 AWS 受管政策提供管理員存取權，並授予許可，為任何 [服務建立服務連結角色](id_roles_create-service-linked-role.md)。 AWS 建議您僅將下列 AWS 受管政策連接到您認為是管理員的 IAM 身分。 AWS 
+ [AdministratorAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AdministratorAccess)
+ [IAMFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/IAMFullAccess)

## 一般警告 – 使用資源中的星號和 NotAction 建立 SLR
<a name="access-analyzer-reference-policy-checks-general-warning-create-slr-with-star-in-resource-and-not-action"></a>

**問題代碼：**CREATE\$1SLR\$1WITH\$1STAR\$1IN\$1RESOURCE\$1AND\$1NOT\$1ACTION

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Create SLR with star in resource and NotAction: Using a resource with wildcards (*) and NotAction can allow creation of unintended service-linked roles because it allows iam:CreateServiceLinkedRole permissions on all resources. We recommend that you specify resource ARNs instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using a resource with wildcards (*) and NotAction can allow creation of unintended service-linked roles because it allows iam:CreateServiceLinkedRole permissions on all resources. We recommend that you specify resource ARNs instead."
```

**解決一般警告**

動作會`iam:CreateServiceLinkedRole`授予許可，以建立允許 AWS 服務代表您執行動作的 IAM 角色。在 `Resource` 元素中包含萬用字元 (\$1) 的政策中使用 `NotAction` 元素可允許為多個資源建立非預期的服務連結角色。 AWS 建議您改為在 `Resource` 元素中指定允許的 ARN。您也可以將 `iam:CreateServiceLinkedRole` 新增到 `NotAction` 元素。
+ [CreateServiceLinkedRole 操作](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateServiceLinkedRole.html)
+ [IAM JSON 政策元素：NotAction](reference_policies_elements_notaction.md)
+ [IAM JSON 政策元素：動作](reference_policies_elements_action.md)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

## 一般警告 — 已取代的全域條件鍵
<a name="access-analyzer-reference-policy-checks-general-warning-deprecated-global-condition-key"></a>

**問題代碼：**DEPRECATED\$1GLOBAL\$1CONDITION\$1KEY

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Deprecated global condition key: We recommend that you update aws:ARN to use the newer condition key aws:PrincipalArn.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "We recommend that you update aws:ARN to use the newer condition key aws:PrincipalArn."
```

**解決一般警告**

政策包含已取代的全域條件鍵。更新條件鍵值組中的條件鍵，以使用支援的全域條件鍵。
+ [全域條件鍵](reference_policies_condition-keys.md)

## 一般警告 – 無效的日期值
<a name="access-analyzer-reference-policy-checks-general-warning-invalid-date-value"></a>

**問題代碼：**INVALID\$1DATE\$1VALUE

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid date value: The date {{date}} might not resolve as expected. We recommend that you use the YYYY-MM-DD format.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The date {{date}} might not resolve as expected. We recommend that you use the YYYY-MM-DD format."
```

**解決一般警告**

Unix Epoch 時間描述了自 1970 年 1 月 1 日以來經過的時間點，減去閏秒。Epoch 時間可能無法解析為您預期的精確時間。 AWS 建議您針對日期和時間格式使用 W3C 標準。例如，您可以指定完整的日期，例如 YYYY-MM-DD (1997-07-16)，或者您也可以將時間附加到秒，例如 YYYY-MM-DDThh:mm:ssTZD (1997-07-16T19:20:30\$101:00)。
+ [W3C 日期和時間格式](https://www.w3.org/TR/NOTE-datetime)
+ [IAM JSON 政策元素：版本](reference_policies_elements_version.md)
+ [aws:CurrentTime 全域條件鍵](reference_policies_condition-keys.md#condition-keys-currenttime)

## 一般警告 – 角色參考無效
<a name="access-analyzer-reference-policy-checks-general-warning-invalid-role-reference"></a>

**問題代碼：**INVALID\$1ROLE\$1REFERENCE

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid role reference: The Principal element includes the IAM role ID {{roleid}}. We recommend that you use a role ARN instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The Principal element includes the IAM role ID {{roleid}}. We recommend that you use a role ARN instead."
```

**解決一般警告**

AWS 建議您為 IAM 角色指定 Amazon Resource Name (ARN)，而不是其主體 ID。當 IAM 儲存政策時，它會將 ARN 轉換為現有角色的委託人 ID。 AWS 包含安全預防措施。如果有人刪除並重新建立角色，則會有新的 ID，且政策不會符合新角色的 ID。
+ [指定主體：IAM 角色](reference_policies_elements_principal.md#principal-roles)
+ [IAM ARN](reference_identifiers.md#identifiers-arns)
+ [IAM 唯一 ID](reference_identifiers.md#identifiers-unique-ids)

## 一般警告 – 無效的使用者參考
<a name="access-analyzer-reference-policy-checks-general-warning-invalid-user-reference"></a>

**問題代碼：**INVALID\$1USER\$1REFERENCE

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Invalid user reference: The Principal element includes the IAM user ID {{userid}}. We recommend that you use a user ARN instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The Principal element includes the IAM user ID {{userid}}. We recommend that you use a user ARN instead."
```

**解決一般警告**

AWS 建議您為 IAM 使用者指定 Amazon Resource Name (ARN)，而不是其主體 ID。當 IAM 儲存政策時，它會將 ARN 轉換為現有使用者的委託人 ID。 AWS 包含安全預防措施。如果有人刪除並重新建立使用者，則會有新的 ID，且政策不會符合新使用者的 ID。
+ [指定主體：IAM 使用者](reference_policies_elements_principal.md#principal-users)
+ [IAM ARN](reference_identifiers.md#identifiers-arns)
+ [IAM 唯一 ID](reference_identifiers.md#identifiers-unique-ids)

## 一般警告 – 遺失版本
<a name="access-analyzer-reference-policy-checks-general-warning-missing-version"></a>

**問題代碼：**MISING\$1VERSION

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing version: We recommend that you specify the Version element to help you with debugging permission issues.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "We recommend that you specify the Version element to help you with debugging permission issues."
```

**解決一般警告**

AWS 建議您在政策中包含選用`Version`參數。如果您未包含 Version 元素，則值預設為 `2012-10-17`，但較新功能 (例如政策變數) 將無法使用您的政策。例如，`${aws:username}` 這類變數無法辨識為變數，而是視為政策中的文字字串。
+ [IAM JSON 政策元素：版本](reference_policies_elements_version.md)

## 一般警告 – 建議使用獨特 Sid
<a name="access-analyzer-reference-policy-checks-general-warning-unique-sids-recommended"></a>

**問題代碼：**UNIQUE\$1SIDS\$1RECOMMENDED

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Unique Sids recommended: We recommend that you use statement IDs that are unique to your policy. Update the Sid value.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "We recommend that you use statement IDs that are unique to your policy. Update the Sid value."
```

**解決一般警告**

AWS 建議您使用唯一的陳述式 IDs。`Sid` (陳述式 ID) 元素允許您輸入您為政策陳述式提供的可選識別符。您可以使用 `SID` 元素將陳述式 ID 值指派給陳述式陣列中的每個陳述式。

**相關用語**
+ [IAM JSON 政策元素：Sid](reference_policies_elements_sid.md)

## 一般警告 – 沒有類似運算子的萬用字元
<a name="access-analyzer-reference-policy-checks-general-warning-wildcard-without-like-operator"></a>

**問題代碼：**WILDCARD\$1WITHOUT\$1LIKE\$1OPERATOR

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Wildcard without like operator: Your condition value includes a * or ? character. If you meant to use a wildcard (*, ?), update the condition operator to include Like.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Your condition value includes a * or ? character. If you meant to use a wildcard (*, ?), update the condition operator to include Like."
```

**解決一般警告**

`Condition` 元素結構會要求您使用條件運算子和鍵值組。當您指定使用萬用字元 (\$1、?) 的條件值時，必須使用 `Like` 版本的條件運算子。例如，並非使用 `StringEquals` 字串條件運算子,而是使用 `StringLike`。

```
"Condition": {"StringLike": {"aws:PrincipalTag/job-category": "admin-*"}}
```
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

### AWS 具有此一般警告的 受管政策
<a name="accan-ref-policy-check-message-fix-general-warning-wildcard-without-like-operator-awsmanpol"></a>

[AWS 受管政策](access_policies_managed-vs-inline.md#aws-managed-policies)可讓您根據一般 AWS 使用案例指派許可 AWS ，以開始使用 。

下列 AWS 受管政策在其條件值中包含萬用字元，而沒有包含 `Like` 用於模式比對的條件運算子。使用 AWS 受管政策做為建立客戶受管政策的參考時， AWS 建議您使用支援與萬用字元 (\$1、？) 進行模式比對的條件運算子，例如 `StringLike`。
+ [AWSGlueConsoleSageMakerNotebookFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AWSGlueConsoleSageMakerNotebookFullAccess)

## 一般警告 – 政策大小超過身分政策配額
<a name="access-analyzer-reference-policy-checks-general-warning-policy-size-exceeds-identity-policy-quota"></a>

**問題代碼：**POLICY\$1SIZE\$1EXCEEDS\$1IDENTITY\$1POLICY\$1QUOTA

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Policy size exceeds identity policy quota: The {{policySize}} characters in the identity policy, excluding whitespace, exceed the {{policySizeQuota}} character maximum for inline and managed policies. We recommend that you use multiple granular policies.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The {{policySize}} characters in the identity policy, excluding whitespace, exceed the {{policySizeQuota}} character maximum for inline and managed policies. We recommend that you use multiple granular policies."
```

**解決一般警告**

您最多可以將 10 個受管政策連接到 IAM 身分 (使用者、使用者群組或角色)。但是，每個受管政策的大小不可超過 6,144 個字元的預設配額。在對此配額計算政策的大小時，IAM 不會計算空格數。配額也稱為 中的限制 AWS，是帳戶中 AWS 資源、動作和項目的最大值。

此外，您可以新增任意數量的內嵌政策到 IAM 身分。不過，每個身分的所有內嵌政策大小總計不能超過指定的配額。

如果您的政策大於配額，您可以將政策組織成多個陳述式，並將這些陳述式群組成多個政策。

**相關用語**
+ [IAM 和 AWS STS 字元配額](reference_iam-quotas.md)
+ [多項陳述式和多個政策](access_policies.md#policies-syntax-multiples)
+ [IAM 客戶受管政策](access_policies_managed-vs-inline.md#customer-managed-policies)
+ [JSON 政策概觀](access_policies.md#access_policies-json)
+ [IAM JSON 政策文法](reference_policies_grammar.md)

### AWS 具有此一般警告的 受管政策
<a name="accan-ref-policy-check-message-fix-general-warning-policy-size-exceeds-identity-policy-quota-awsmanpol"></a>

[AWS 受管政策](access_policies_managed-vs-inline.md#aws-managed-policies)可讓您根據一般 AWS 使用案例指派許可 AWS ，以開始使用 。

下列 AWS 受管政策會將許可授予許多 AWS 服務的動作，並超過政策大小上限。當您使用 AWS 受管政策做為建立受管政策的參考時，必須將政策分割為多個政策。
+ [ReadOnlyAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/ReadOnlyAccess)
+ [AWSSupportServiceRolePolicy](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AWSSupportServiceRolePolicy)

## 一般警告 – 政策大小超過資源政策配額
<a name="access-analyzer-reference-policy-checks-general-warning-policy-size-exceeds-resource-policy-quota"></a>

**問題代碼：**POLICY\$1SIZE\$1EXCEEDS\$1RESOURCE\$1POLICY\$1QUOTA

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Policy size exceeds resource policy quota: The {{policySize}} characters in the resource policy exceed the {{policySizeQuota}} character maximum for resource policies. We recommend that you use multiple granular policies.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The {{policySize}} characters in the resource policy exceed the {{policySizeQuota}} character maximum for resource policies. We recommend that you use multiple granular policies."
```

**解決一般警告**

資源型政策是連接到資源 (如 Amazon S3 儲存貯體) 的 JSON 政策文件。這些政策會授予指定的主體許可，允許在該資源上執行特定的動作，並且定義資源所適用的條件。資源型政策的大小不能超過為該資源設定的配額。配額也稱為 中的限制 AWS，是 AWS 帳戶中資源、動作和項目的最大值。

如果您的政策大於配額，您可以將政策組織成多個陳述式，並將這些陳述式群組成多個政策。

**相關用語**
+ [資源型政策](access_policies.md#policies_resource-based)
+ [使用 Amazon S3 儲存貯體政策](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html)
+ [多項陳述式和多個政策](access_policies.md#policies-syntax-multiples)
+ [JSON 政策概觀](access_policies.md#access_policies-json)
+ [IAM JSON 政策文法](reference_policies_grammar.md)

## 一般警告 – 類型不符
<a name="access-analyzer-reference-policy-checks-general-warning-type-mismatch"></a>

**問題代碼：**TYPE\$1MISMATCH

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Type mismatch: Use the operator type {{allowed}} instead of operator {{operator}} for the condition key {{key}}.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Use the operator type {{allowed}} instead of operator {{operator}} for the condition key {{key}}."
```

**解決一般警告**

更新文字以使用支援的條件運算子資料類型。

例如，`aws:MultiFactorAuthPresent` 全域條件鍵需要資料類型為 `Boolean` 的條件運算子。如果您提供日期或整數，則資料類型將不相符。

**相關用語**
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)

## 一般警告 – 類型不符布林值
<a name="access-analyzer-reference-policy-checks-general-warning-type-mismatch-boolean"></a>

**問題代碼：**TYPE\$1MISMATCH\$1BOOLEAN

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Type mismatch Boolean: Add a valid Boolean value (true or false) for the condition operator {{operator}}.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add a valid Boolean value (true or false) for the condition operator {{operator}}."
```

**解決一般警告**

更新文字以使用布林值條件運算子資料類型，例如 `true` 或 `false`。

例如，`aws:MultiFactorAuthPresent` 全域條件鍵需要資料類型為 `Boolean` 的條件運算子。如果您提供日期或整數，則資料類型將不相符。

**相關用語**
+ [布林值條件運算子](reference_policies_elements_condition_operators.md#Conditions_Boolean)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)

## 一般警告 – 類型不符日期
<a name="access-analyzer-reference-policy-checks-general-warning-type-mismatch-date"></a>

**問題代碼：**TYPE\$1MISMATCH\$1DATE

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Type mismatch date: The date condition operator is used with an invalid value. Specify a valid date using YYYY-MM-DD or other ISO 8601 date/time format.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The date condition operator is used with an invalid value. Specify a valid date using YYYY-MM-DD or other ISO 8601 date/time format."
```

**解決一般警告**

更新文字以使用 `YYYY-MM-DD` 或其他 ISO 8601 日期時間格式的日期條件運算子資料類型。

**相關用語**
+ [日期條件運算子](reference_policies_elements_condition_operators.md#Conditions_Date)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)

## 一般警告 – 類型不符號碼
<a name="access-analyzer-reference-policy-checks-general-warning-type-mismatch-number"></a>

**問題代碼：**TYPE\$1MISMATCH\$1NUMBER

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Type mismatch number: Add a valid numeric value for the condition operator {{operator}}.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add a valid numeric value for the condition operator {{operator}}."
```

**解決一般警告**

更新文字以使用數字條件運算子資料類型。

**相關用語**
+ [數位條件運算子](reference_policies_elements_condition_operators.md#Conditions_Numeric)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)

## 一般警告 – 類型不符字串
<a name="access-analyzer-reference-policy-checks-general-warning-type-mismatch-string"></a>

**問題代碼：**TYPE\$1MISMATCH\$1STRING

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Type mismatch string: Add a valid base64-encoded string value for the condition operator {{operator}}.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add a valid base64-encoded string value for the condition operator {{operator}}."
```

**解決一般警告**

更新文字以使用字串條件運算子資料類型。

**相關用語**
+ [字串條件運算子](reference_policies_elements_condition_operators.md#Conditions_String)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)

## 一般警告 – 建議使用特定的 github 儲存庫和分支
<a name="access-analyzer-reference-policy-checks-general-warning-specific-github-repo-and-branch-recommended"></a>

**問題代碼：**SPECIFIC\$1GITHUB\$1REPO\$1AND\$1BRANCH\$1RECOMMENDED

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Specific github repo and branch recommended: Using a wildcard (*) in token.actions.githubusercontent.com:sub can allow requests from more sources than you intended. Specify the value of token.actions.githubusercontent.com:sub with the repository and branch name.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using a wildcard (*) in token.actions.githubusercontent.com:sub can allow requests from more sources than you intended. Specify the value of token.actions.githubusercontent.com:sub with the repository and branch name."
```

**解決一般警告**

如果您使用 GitHub 做為 OIDC IdP，最佳實務是限制可擔任與 IAM IdP 相關聯角色的實體。當您在角色信任政策中包含 `Condition` 陳述式時，可以將角色限制到特定 GitHub 組織、儲存庫或分支。您可以使用條件鍵 `token.actions.githubusercontent.com:sub` 來限制存取。建議您將條件限制為一組特定的儲存庫或分支。如果您在 中使用萬用字元 (`*`)`token.actions.githubusercontent.com:sub`，則來自您控制範圍之外的組織或儲存庫的 GitHub 動作可以擔任與您 AWS 帳戶中的 GitHub IAM IdP 相關聯的角色。

**相關用語**
+ [設定 GitHub OIDC 身分提供者的角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html#idp_oidc_Create_GitHub)

## 一般警告 – 政策大小超過角色信任政策配額
<a name="access-analyzer-reference-policy-checks-general-warning-policy-size-exceeds-role-trust-policy-quota"></a>

**問題代碼：**POLICY\$1SIZE\$1EXCEEDS\$1ROLE\$1TRUST\$1POLICY\$1QUOTA

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Policy size exceeds role trust policy quota: The characters in the role trust policy, excluding whitespace, exceed the character maximum. We recommend that you request a role trust policy length quota increase using Service Quotas and AWS Support Center. If the quotas have already been increased, then you can ignore this warning.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The characters in the role trust policy, excluding whitespace, exceed the character maximum. We recommend that you request a role trust policy length quota increase using Service Quotas and AWS Support Center. If the quotas have already been increased, then you can ignore this warning."
```

**解決一般警告**

IAM 和 AWS STS 具有限制角色信任政策大小的配額。角色信任政策中的字元 (不包括空白) 超過字元上限。我們建議您使用 Service Quotas 和 AWS Support Center Console要求增加角色信任政策長度配額。

**相關用語**
+ [IAM AWS STS 和配額、名稱要求和字元限制](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html)

## 一般警告 – RCP 缺少相關主體條件索引鍵
<a name="access-analyzer-reference-policy-checks-general-warning-rcp-missing-related-principal-condition-key"></a>

**問題代碼：**RCP\$1MISSING\$1RELATED\$1PRINCIPAL\$1CONDITION\$1KEY

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
RCP missing related principal condition key: RCPs impact IAM roles, users, and AWS service principals. To prevent unintended impact to services acting on your behalf using a service principal, an additional statement should be added to the Condition block "BoolIfExists": { "aws:PrincipalIsAWSService": "false"} whenever a principal key {{conditionKeyName}} is used.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "RCPs impact IAM roles, users, and AWS service principals. To prevent unintended impact to services acting on your behalf using a service principal, an additional statement should be added to the Condition block "BoolIfExists": { "aws:PrincipalIsAWSService": "false"} whenever a principal key {{conditionKeyName}} is used."
```

**解決一般警告**

AWS Organizations 資源控制政策 RCPs) 可能會影響 IAM 角色、使用者和 AWS 服務 主體。若要防止使用服務主體代表您執行的服務受到意外影響，請將下列陳述式新增至您的 `Condition` 元素：

```
"BoolIfExists": { "aws:PrincipalIsAWSService": "false"}
```

**相關用語**
+ [RCP 語法](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps_syntax.html)
+ [主體的屬性](reference_policies_condition-keys.md#condition-keys-principal-properties)

## 一般警告 – RCP 缺少相關服務主體條件索引鍵
<a name="access-analyzer-reference-policy-checks-general-warning-rcp-missing-related-service-principal-condition-key"></a>

**問題代碼：**RCP\$1MISSING\$1RELATED\$1SERVICE\$1PRINCIPAL\$1CONDITION\$1KEY

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
RCP missing related service principal condition key: RCPs impact IAM roles, users, and AWS service principals. To prevent unintended impact to your principals, an additional statement should be added to the Condition block "BoolIfExists": { "aws:PrincipalIsAWSService": "true"} whenever the key {{conditionKeyName}} is used.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "RCPs impact IAM roles, users, and AWS service principals. To prevent unintended impact to your principals, an additional statement should be added to the Condition block "BoolIfExists": { "aws:PrincipalIsAWSService": "true"} whenever the key {{conditionKeyName}} is used."
```

**解決一般警告**

AWS Organizations 資源控制政策 RCPs) 可能會影響 IAM 角色、使用者和 AWS 服務 主體。若要避免您的主體受到意外影響，請將下列陳述式新增至您的 `Condition` 元素：

```
"BoolIfExists": { "aws:PrincipalIsAWSService": "true"}
```

**相關用語**
+ [RCP 語法](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps_syntax.html)
+ [主體的屬性](reference_policies_condition-keys.md#condition-keys-principal-properties)

## 一般警告 – RCP 缺少服務條件索引鍵 Null 檢查
<a name="access-analyzer-reference-policy-checks-general-warning-rcp-missing-service-condition-key-null-check"></a>

**問題代碼：**RCP\$1MISSING\$1SERVICE\$1CONDITION\$1KEY\$1NULL\$1CHECK

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
RCP missing service condition key null check: The specified service may have a service integration that does not require the use of the the {{conditionKeyName}} condition key. To prevent unintended impact to services acting on your behalf using a service principal, an additional statement should be added to the Condition block "Null": { "aws:SourceAccount": "false"} or "Null": { "aws:SourceArn": "false"} whenever the key {{conditionKeyName}} is used.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The specified service may have a service integration that does not require the use of the the {{conditionKeyName}} condition key. To prevent unintended impact to services acting on your behalf using a service principal, an additional statement should be added to the Condition block "Null": { "aws:SourceAccount": "false"} or "Null": { "aws:SourceArn": "false"} whenever the key {{conditionKeyName}} is used."
```

**解決一般警告**

AWS Organizations 資源控制政策 RCPs) 可能會影響 IAM 角色、使用者和 AWS 服務 主體。若要防止使用服務主體代表您執行的服務受到意外影響，每當使用指定索引鍵時，請將下列陳述式之一新增至您的 `Condition` 元素：

```
"Null": { "aws:SourceAccount": "false"}
```

或

```
"Null": { "aws:SourceArn": "false"}
```

**相關用語**
+ [RCP 語法](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps_syntax.html)
+ [主體的屬性](reference_policies_condition-keys.md#condition-keys-principal-properties)

## 一般警告 – 僅搭配支援的服務使用條件索引鍵
<a name="access-analyzer-reference-policy-checks-general-warning-use-condition-key-only-with-supported-services"></a>

**問題代碼：**USE\$1CONDITION\$1KEY\$1ONLY\$1WITH\$1SUPPORTED\$1SERVICES

**調查結果類型：**GENERAL\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Use condition key only with supported services: The condition key {{key}} works only with specific AWS services and must be scoped to supported services in your policies.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition key {{key}} works only with specific AWS services and must be scoped to supported services in your policies.
```

**解決一般警告**

檢閱 AWS 文件以識別 AWS 服務 支援此條件金鑰的 。如果政策中的任何服務不支援 條件金鑰，請修改您的政策，將條件金鑰範圍限定為僅 AWS 服務 支援它的 。

**相關用語**
+ [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-vpceaccount](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-vpceaccount)
+ [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-vpceorgid](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-vpceorgid)
+ [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-vpceorgpaths](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-vpceorgpaths)
+ [的動作、資源和條件索引鍵 AWS 服務](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)

## 安全警告 – 不可信任的條件索引鍵
<a name="access-analyzer-reference-policy-checks-security-warning-untrustworthy-condition-key"></a>

**問題代碼：**UNTRUSTWORTHY\$1CONDITION\$1KEY

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Untrustworthy condition key: The {{key}} condition key is not recommended for access control as it can be spoofed/manipulated by the caller.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The {{key}} condition key is not recommended for access control as it can be spoofed/manipulated by the caller."
```

**解決安全警告**

請勿將此條件索引鍵用於存取控制。呼叫者可能會篡改或偽造索引鍵值，從而帶來安全風險。

**相關用語**
+ [AWS 全域條件內容索引鍵](reference_policies_condition-keys.md)

## 安全性警告 – 允許使用 NotPrincipal
<a name="access-analyzer-reference-policy-checks-security-warning-allow-with-not-principal"></a>

**問題代碼：**ALLOW\$1WITH\$1NOT\$1PRINCIPAL

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Allow with NotPrincipal: Using Allow with NotPrincipal can be overly permissive. We recommend that you use Principal instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using Allow with NotPrincipal can be overly permissive. We recommend that you use Principal instead."
```

**解決安全警告**

使用 `"Effect": "Allow"` 與 `NotPrincipal` 可能太過寬鬆。例如，這可以將許可授予匿名 principals. AWS recommends，以便您使用 `Principal`元素指定需要存取的主體。或者，您可以允許廣泛存取，然後新增另一個使用 `NotPrincipal` 元素與 `“Effect”: “Deny”` 的陳述式。
+ [AWS JSON 政策元素：主體](reference_policies_elements_principal.md)
+ [AWS JSON 政策元素：NotPrincipal](reference_policies_elements_notprincipal.md)

## 安全性警告 – ForAllValues 具有單一數值金鑰
<a name="access-analyzer-reference-policy-checks-security-warning-forallvalues-with-single-valued-key"></a>

**問題代碼：**FORALLVALUES\$1WITH\$1SINGLE\$1VALUED\$1KEY

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
ForAllValues with single valued key: Using ForAllValues qualifier with the single-valued condition key {{key}} can be overly permissive. We recommend that you remove ForAllValues:.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using ForAllValues qualifier with the single-valued condition key {{key}} can be overly permissive. We recommend that you remove ForAllValues:."
```

**解決安全警告**

AWS 建議您`ForAllValues`僅將 與多值條件搭配使用。`ForAllValues` 集合運算子會測試請求集每個成員的值是否為條件鍵集的子集。如果請求中每個鍵值至少符合政策中的一個值，則條件會傳回 true。如果請求中沒有鍵，或鍵值解析為 null 資料集 (例如空白字串)，則也會傳回 true。

若要了解條件是支援單一值還是多個值，請檢閱服務的[動作、資源及條件鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)頁面。具有 `ArrayOf` 資料類型字首的條件鍵是多重值條件鍵。例如，Amazon SES 支援具有單一值 (`String`) 和 `ArrayOfString` 多重值資料類型的鍵。
+ [多值內容鍵](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)

## 安全性警告 – 使用 NotResource 傳遞角色
<a name="access-analyzer-reference-policy-checks-security-warning-pass-role-with-not-resource"></a>

**問題代碼：**PASS\$1ROLE\$1WITH\$1NOT\$1RESOURCE

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Pass role with NotResource: Using the iam:PassRole action with NotResource can be overly permissive because it can allow iam:PassRole permissions on multiple resources. We recommend that you specify resource ARNs instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using the iam:PassRole action with NotResource can be overly permissive because it can allow iam:PassRole permissions on multiple resources. We recommend that you specify resource ARNs instead."
```

**解決安全警告**

若要設定許多 AWS 服務，您必須將 IAM 角色傳遞給服務。若要允許這樣做，您必須授與 `iam:PassRole` 許可給身分 (使用者、使用者群組或角色)。在具有 `NotResource`元素的政策`iam:PassRole`中使用 可以讓您的委託人存取比您預期更多的服務或功能。 AWS 建議您改為在 `Resource`元素中指定允許的 ARNs。此外，您可以使用 `iam:PassedToService` 條件鍵將許可降低為單一服務。
+ [將角色傳遞到服務](id_roles_use_passrole.md)
+ [iam:PassedToService](reference_policies_iam-condition-keys.md#ck_PassedToService)
+ [IAM JSON 政策元素：NotResource](reference_policies_elements_notresource.md)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

## 安全性警告 – 使用動作中的星號和 NotResource 傳遞角色
<a name="access-analyzer-reference-policy-checks-security-warning-pass-role-with-star-in-action-and-not-resource"></a>

**問題代碼：**PASS\$1ROLE\$1WITH\$1STAR\$1IN\$1ACTION\$1AND\$1NOT\$1RESOURCE

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Pass role with star in action and NotResource: Using an action with a wildcard (*) and NotResource can be overly permissive because it can allow iam:PassRole permissions on multiple resources. We recommend that you specify resource ARNs instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using an action with a wildcard (*) and NotResource can be overly permissive because it can allow iam:PassRole permissions on multiple resources. We recommend that you specify resource ARNs instead."
```

**解決安全警告**

若要設定許多 AWS 服務，您必須將 IAM 角色傳遞給服務。若要允許這樣做，您必須授與 `iam:PassRole` 許可給身分 (使用者、使用者群組或角色)。在 中包含萬用字元 (\$1) `Action`且包含 `NotResource`元素的政策，可讓您的委託人存取比您預期更多的服務或功能。 AWS 建議您改為在 `Resource`元素中指定允許的 ARNs。此外，您可以使用 `iam:PassedToService` 條件鍵將許可降低為單一服務。
+ [將角色傳遞到服務](id_roles_use_passrole.md)
+ [iam:PassedToService](reference_policies_iam-condition-keys.md#ck_PassedToService)
+ [IAM JSON 政策元素：NotResource](reference_policies_elements_notresource.md)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

## 安全性警告 – 使用 NotAction 和 NotResource 傳遞角色
<a name="access-analyzer-reference-policy-checks-security-warning-pass-role-with-not-action-and-not-resource"></a>

**問題代碼：**PASS\$1ROLE\$1WITH\$1NOT\$1ACTION\$1AND\$1NOT\$1RESOURCE

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Pass role with NotAction and NotResource: Using NotAction with NotResource can be overly permissive because it can allow iam:PassRole permissions on multiple resources.. We recommend that you specify resource ARNs instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using NotAction with NotResource can be overly permissive because it can allow iam:PassRole permissions on multiple resources.. We recommend that you specify resource ARNs instead."
```

**解決安全警告**

若要設定許多 AWS 服務，您必須將 IAM 角色傳遞給服務。若要允許這樣做，您必須授與 `iam:PassRole` 許可給身分 (使用者、使用者群組或角色)。使用 `NotAction`元素並在 `NotResource`元素中列出一些資源，可讓您的委託人存取比您預期更多的服務或功能。 AWS 建議您改為在 `Resource`元素中指定允許的 ARNs。此外，您可以使用 `iam:PassedToService` 條件鍵將許可降低為單一服務。
+ [將角色傳遞到服務](id_roles_use_passrole.md)
+ [iam:PassedToService](reference_policies_iam-condition-keys.md#ck_PassedToService)
+ [IAM JSON 政策元素：NotAction](reference_policies_elements_notaction.md)
+ [IAM JSON 政策元素：動作](reference_policies_elements_action.md)
+ [IAM JSON 政策元素：NotResource](reference_policies_elements_notresource.md)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

## 安全性警告 – 使用資源中的星號傳遞角色
<a name="access-analyzer-reference-policy-checks-security-warning-pass-role-with-star-in-resource"></a>

**問題代碼：**PASS\$1ROLE\$1WITH\$1STAR\$1IN\$1RESOURCE

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Pass role with star in resource: Using the iam:PassRole action with wildcards (*) in the resource can be overly permissive because it allows iam:PassRole permissions on multiple resources. We recommend that you specify resource ARNs or add the iam:PassedToService condition key to your statement.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using the iam:PassRole action with wildcards (*) in the resource can be overly permissive because it allows iam:PassRole permissions on multiple resources. We recommend that you specify resource ARNs or add the iam:PassedToService condition key to your statement."
```

**解決安全警告**

若要設定許多 AWS 服務，您必須將 IAM 角色傳遞給服務。若要允許這樣做，您必須授與 `iam:PassRole` 許可給身分 (使用者、使用者群組或角色)。允許 `iam:PassRole` 和 在 `Resource`元素中包含萬用字元 (\$1) 的政策，可讓您的委託人存取比您預期更多的服務或功能。 AWS 建議您改為在 `Resource`元素中指定允許的 ARNs。此外，您可以使用 `iam:PassedToService` 條件鍵將許可降低為單一服務。

有些 AWS 服務會在其角色的名稱中包含其服務命名空間。此政策檢查會在分析政策以產生問題清單時，將這些慣例納入考量。例如，下列資源 ARN 可能不會產生問題清單：

```
arn:aws:iam::*:role/Service*
```
+ [將角色傳遞到服務](id_roles_use_passrole.md)
+ [iam:PassedToService](reference_policies_iam-condition-keys.md#ck_PassedToService)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

### AWS 具有此安全性警告的 受管政策
<a name="accan-ref-policy-check-message-fix-security-warning-pass-role-with-star-in-resource-awsmanpol"></a>

[AWS 受管政策](access_policies_managed-vs-inline.md#aws-managed-policies)可讓您根據一般 AWS 使用案例指派許可 AWS ，以開始使用 。

這些使用案例其中一個適用於您帳戶中的系統管理員。下列 AWS 受管政策提供管理員存取權，並授予許可，以將任何 IAM 角色傳遞至任何 服務。 AWS 建議您僅將下列 AWS 受管政策連接到您認為是管理員的 IAM 身分。
+ [AdministratorAccess-Amplify](https://console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/AdministratorAccess-Amplify)

下列 AWS 受管政策包含 資源中`iam:PassRole`具有萬用字元 (\$1) 且位於[棄用路徑](access_policies_managed-deprecated.md)的 許可。對於每個政策，我們更新了許可指導，例如建議支援使用案例的新 AWS 受管政策。若要檢視這些政策的替代方案，請參閱指南以瞭解[每個服務](reference_aws-services-that-work-with-iam.md)。
+ AWSElasticBeanstalkFullAccess
+ AWSElasticBeanstalkService
+ AWSLambdaFullAccess
+ AWSLambdaReadOnlyAccess
+ AWSOpsWorksFullAccess
+ AWSOpsWorksRole
+ AWSDataPipelineRole
+ AmazonDynamoDBFullAccesswithDataPipeline
+ AmazonElasticMapReduceFullAccess
+ AmazonDynamoDBFullAccesswithDataPipeline
+ AmazonEC2ContainerServiceFullAccess

下列 AWS 受管政策僅提供[服務連結角色](id_roles_create-service-linked-role.md)的許可，允許 AWS 服務代表您執行動作。您可以將這些政策連接到 IAM 身分。
+ [AWSServiceRoleForAmazonEKSNodegroup](https://console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/aws-service-role/AWSServiceRoleForAmazonEKSNodegroup)

## 安全性警告 – 使用動作中的星號和資源傳遞角色
<a name="access-analyzer-reference-policy-checks-security-warning-pass-role-with-star-in-action-and-resource"></a>

**問題代碼：**PASS\$1ROLE\$1WITH\$1STAR\$1IN\$1ACTION\$1AND\$1RESOURCE

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Pass role with star in action and resource: Using wildcards (*) in the action and the resource can be overly permissive because it allows iam:PassRole permissions on all resources. We recommend that you specify resource ARNs or add the iam:PassedToService condition key to your statement.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using wildcards (*) in the action and the resource can be overly permissive because it allows iam:PassRole permissions on all resources. We recommend that you specify resource ARNs or add the iam:PassedToService condition key to your statement."
```

**解決安全警告**

若要設定許多 AWS 服務，您必須將 IAM 角色傳遞給服務。若要允許這樣做，您必須授與 `iam:PassRole` 許可給身分 (使用者、使用者群組或角色)。在 `Action`和 `Resource`元素中使用萬用字元 (\$1) 的政策，可讓您的委託人存取比您預期更多的服務或功能。 AWS 建議您改為在 `Resource`元素中指定允許的 ARNs。此外，您可以使用 `iam:PassedToService` 條件鍵將許可降低為單一服務。
+ [將角色傳遞到服務](id_roles_use_passrole.md)
+ [iam:PassedToService](reference_policies_iam-condition-keys.md#ck_PassedToService)
+ [IAM JSON 政策元素：動作](reference_policies_elements_action.md)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

### AWS 具有此安全性警告的 受管政策
<a name="accan-ref-policy-check-message-fix-security-warning-pass-role-with-star-in-action-and-resource-awsmanpol"></a>

[AWS 受管政策](access_policies_managed-vs-inline.md#aws-managed-policies)可讓您根據一般 AWS 使用案例 AWS 指派許可，以開始使用 。

其中一些使用案例適用於您帳戶中的系統管理員。下列 AWS 受管政策提供管理員存取權，並授予許可，以將任何 IAM 角色傳遞至任何 AWS 服務。 AWS 建議您僅將下列 AWS 受管政策連接到您認為是管理員的 IAM 身分。
+ [AdministratorAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AdministratorAccess)
+ [IAMFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/IAMFullAccess)

## 安全性警告 – 使用資源中的星號和 NotAction 傳遞角色
<a name="access-analyzer-reference-policy-checks-security-warning-pass-role-with-star-in-resource-and-not-action"></a>

**問題代碼：**PASS\$1ROLE\$1WITH\$1STAR\$1IN\$1RESOURCE\$1AND\$1NOT\$1ACTION

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Pass role with star in resource and NotAction: Using a resource with wildcards (*) and NotAction can be overly permissive because it allows iam:PassRole permissions on all resources. We recommend that you specify resource ARNs or add the iam:PassedToService condition key to your statement.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using a resource with wildcards (*) and NotAction can be overly permissive because it allows iam:PassRole permissions on all resources. We recommend that you specify resource ARNs or add the iam:PassedToService condition key to your statement."
```

**解決安全警告**

若要設定許多 AWS 服務，您必須將 IAM 角色傳遞給服務。若要允許這樣做，您必須授與 `iam:PassRole` 許可給身分 (使用者、使用者群組或角色)。在政策中使用 `NotAction`元素搭配 `Resource`元素中的萬用字元 (\$1)，可讓您的委託人存取比您預期更多的服務或功能。 AWS 建議您改為在 `Resource`元素中指定允許的 ARNs。此外，您可以使用 `iam:PassedToService` 條件鍵將許可降低為單一服務。
+ [將角色傳遞到服務](id_roles_use_passrole.md)
+ [iam:PassedToService](reference_policies_iam-condition-keys.md#ck_PassedToService)
+ [IAM JSON 政策元素：NotAction](reference_policies_elements_notaction.md)
+ [IAM JSON 政策元素：動作](reference_policies_elements_action.md)
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

## 安全性警告 – 遺失配對的條件鍵
<a name="access-analyzer-reference-policy-checks-security-warning-missing-paired-condition-keys"></a>

**問題代碼：**MISSING\$1PAIRED\$1CONDITION\$1KEYS

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing paired condition keys: Using the condition key {{conditionKeyName}} can be overly permissive without also using the following condition keys: {{recommendedKeys}}. Condition keys like this one are more secure when paired with a related key. We recommend that you add the related condition keys to the same condition block.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using the condition key {{conditionKeyName}} can be overly permissive without also using the following condition keys: {{recommendedKeys}}. Condition keys like this one are more secure when paired with a related key. We recommend that you add the related condition keys to the same condition block."
```

**解決安全警告**

當與其他相關條件鍵配對時，某些條件鍵會更安全。 AWS 建議您在與現有條件鍵相同的條件區塊中包含相關的條件鍵。這會使透過政策授與的許可更安全。

例如，您可以使用 `aws:VpcSourceIp` 條件鍵，將從中提出請求的 IP 地址與您在政策中指定的 IP 地址進行比較。 AWS 建議您新增相關的 `aws:SourceVPC` 條件鍵。這會檢查請求是否來自您在政策中指定的 VPC *和*您指定的 IP 地址。

**相關用語**
+ [`aws:VpcSourceIp` 全域條件鍵](reference_policies_condition-keys.md#condition-keys-vpcsourceip)
+ [`aws:SourceVPC` 全域條件鍵](reference_policies_condition-keys.md#condition-keys-sourcevpc)
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [條件元素](reference_policies_elements_condition.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 安全性警告 – 拒絕使用不支援的服務標籤條件鍵
<a name="access-analyzer-reference-policy-checks-security-warning-deny-with-unsupported-tag-condition-key-for-service"></a>

**問題代碼：**DENY\$1WITH\$1UNSUPPORTED\$1TAG\$1CONDITION\$1KEY\$1FOR\$1SERVICE

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Deny with unsupported tag condition key for service: Using the effect Deny with the tag condition key {{conditionKeyName}} and actions for services with the following prefixes can be overly permissive: {{serviceNames}}. Actions for the listed services are not denied by this statement. We recommend that you move these actions to a different statement without this condition key.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using the effect Deny with the tag condition key {{conditionKeyName}} and actions for services with the following prefixes can be overly permissive: {{serviceNames}}. Actions for the listed services are not denied by this statement. We recommend that you move these actions to a different statement without this condition key."
```

**解決安全警告**

在政策的 `Condition`元素中使用不支援的標籤條件索引鍵`"Effect": "Deny"`可能會過度寬鬆，因為該服務的條件會被忽略。 AWS 建議您移除不支援條件索引鍵的服務動作，並建立另一個陳述式來拒絕存取這些動作的特定資源。

如果您使用 `aws:ResourceTag` 條件鍵，且其不受服務動作支援，則該鍵不會包含在要求內容中。在此案例中，`Deny` 陳述式中的條件一律會傳回 `false`，且絕不會拒絕該動作。即使已正確標記資源，也會發生這種情況。

當服務支援 `aws:ResourceTag` 條件鍵時，您可以使用標籤來控制對該服務之資源的存取。這稱為[以屬性為基礎的存取控制 (ABAC)](introduction_attribute-based-access-control.md)。不支援這些鍵的服務需要您使用[以資源為基礎的存取控制 (RBAC)](introduction_attribute-based-access-control.md#introduction_attribute-based-access-control_compare-rbac) 來控制對資源的存取權。

**注意**  
某些服務允許支援其資源和動作子集的 `aws:ResourceTag` 條件鍵。IAM Access Analyzer 會傳回不支援服務動作的問題清單。例如，Amazon S3 支援 `aws:ResourceTag` 以取得其資源的子集。若要檢視 Amazon S3 中可用且支援 `aws:ResourceTag` 條件鍵的所有資源類型，請參閱服務授權參考中的 [Amazon S3 定義的資源類型](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html#amazons3-resources-for-iam-policies)。

例如，假設您想要拒絕存取取消標記刪除標記為鍵值組 `status=Confidential` 的特定資源。也假設 AWS Lambda 允許您標記和取消標記資源，但不支援 `aws:ResourceTag`條件金鑰。若要拒絕 的刪除動作 AWS App Mesh ， AWS Backup 如果此標籤存在，請使用 `aws:ResourceTag`條件索引鍵。對於 Lambda，請使用資源命名慣例，其中包含 `"Confidential"` 字首。然後包含一個單獨的陳述式，以防止刪除具有該命名慣例的資源。

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "DenyDeleteSupported",
            "Effect": "Deny",
            "Action": [
                "appmesh:DeleteMesh", 
                "backup:DeleteBackupPlan"
                ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/status": "Confidential"
                }
            }
        },
        {
            "Sid": "DenyDeleteUnsupported",
            "Effect": "Deny",
            "Action": "lambda:DeleteFunction",
            "Resource": "arn:aws:lambda:*:123456789012:function:status-Confidential*"
        }
    ]
}
```

**警告**  
請勿使用 …[IfExists](reference_policies_elements_condition_operators.md#Conditions_IfExists) 版本的條件運算子做為此問題清單的解決方法。這表示「如果鍵存在於請求內容中，且值相符，則拒絕動作。否則，請拒絕動作。」 在上述範例中，在 `DenyDeleteSupported` 陳述式中包含 `lambda:DeleteFunction` 動作與 `StringEqualsIfExists` 運算子一律會拒絕該動作。對於該動作，鍵不存在於內容中，且每次嘗試刪除該資源類型都會遭到拒絕，無論該資源是否已加上標籤。

**相關用語**
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [比較 ABAC 與 RBAC](introduction_attribute-based-access-control.md#introduction_attribute-based-access-control_compare-rbac)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)
+ [條件元素](reference_policies_elements_condition.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 安全性警告 - 拒絕不支援的服務標籤條件鍵的 NotAction
<a name="access-analyzer-reference-policy-checks-security-warning-deny-notaction-with-unsupported-tag-condition-key-for-service"></a>

**問題代碼：**DENY\$1NOTACTION\$1WITH\$1UNSUPPORTED\$1TAG\$1CONDITION\$1KEY\$1FOR\$1SERVICE

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Deny NotAction with unsupported tag condition key for service: Using the effect Deny with NotAction and the tag condition key {{conditionKeyName}} can be overly permissive because some service actions are not denied by this statement. This is because the condition key doesn't apply to some service actions. We recommend that you use Action instead of NotAction.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using the effect Deny with NotAction and the tag condition key {{conditionKeyName}} can be overly permissive because some service actions are not denied by this statement. This is because the condition key doesn't apply to some service actions. We recommend that you use Action instead of NotAction."
```

**解決安全警告**

在政策的 `Condition` 元素中使用標籤條件鍵與元素 `NotAction` 和 `"Effect": "Deny"` 可能太過寬鬆。對於不支援 condition key. AWS recommends 的服務動作，系統會忽略條件。建議您重寫邏輯以拒絕動作清單。

如果您使用 `aws:ResourceTag` 條件鍵與 `NotAction`，則不會拒絕任何不支援鍵的新或現有服務動作。 AWS 建議您明確列出您要拒絕的動作。IAM Access Analyzer 會針對所列出不支援 `aws:ResourceTag` 條件鍵的動作傳回個別的問題清單。如需詳細資訊，請參閱 [安全性警告 – 拒絕使用不支援的服務標籤條件鍵](#access-analyzer-reference-policy-checks-security-warning-deny-with-unsupported-tag-condition-key-for-service)。

當服務支援 `aws:ResourceTag` 條件鍵時，您可以使用標籤來控制對該服務之資源的存取。這稱為[以屬性為基礎的存取控制 (ABAC)](introduction_attribute-based-access-control.md)。不支援這些鍵的服務需要您使用[以資源為基礎的存取控制 (RBAC)](introduction_attribute-based-access-control.md#introduction_attribute-based-access-control_compare-rbac) 來控制對資源的存取權。

**相關用語**
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [比較 ABAC 與 RBAC](introduction_attribute-based-access-control.md#introduction_attribute-based-access-control_compare-rbac)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)
+ [條件元素](reference_policies_elements_condition.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 安全性警告 - 限制存取服務主體
<a name="access-analyzer-reference-policy-checks-security-warning-restrict-access-to-service-principal"></a>

**問題代碼：**RESTRICT\$1ACCESS\$1TO\$1SERVICE\$1PRINCIPAL

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Restrict access to service principal: Granting access to a service principal without specifying a source is overly permissive. Use aws:SourceArn, aws:SourceAccount, aws:SourceOrgID, or aws:SourceOrgPaths condition key to grant fine-grained access.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Granting access to a service principal without specifying a source is overly permissive. Use aws:SourceArn, aws:SourceAccount, aws:SourceOrgID, or aws:SourceOrgPaths condition key to grant fine-grained access."
```

**解決安全警告**

您可以使用服務主體在資源型政策的 `Principal`元素 AWS 服務 中指定 ，該主體是服務的識別符。授予服務主體代表您採取行動的存取權時，會限制存取。您可以使用 `aws:SourceArn`、`aws:SourceOrgID`、 `aws:SourceAccount`或 `aws:SourceOrgPaths`條件金鑰來限制對特定來源的存取，例如特定資源 ARN、組織 ID 或組織路徑 AWS 帳戶，以防止過度寬鬆的政策。限制存取可協助您避免名為*混淆代理人問題*的安全問題。

**相關用語**
+ [AWS 服務 主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services)
+ [AWS 全域條件索引鍵：aws：SourceAccount](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceaccount)
+ [AWS 全域條件索引鍵：aws：SourceArn](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcearn)
+ [AWS 全域條件索引鍵：aws：SourceOrgId](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceorgid)
+ [AWS 全域條件索引鍵：aws：SourceOrgPaths](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceorgpaths)
+ [混淆代理人問題](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html)

## 安全性警告 – 缺少 OIDC 主體的條件鍵
<a name="access-analyzer-reference-policy-checks-security-warning-missing-condition-key-for-oidc-principal"></a>

**問題代碼：**MISSING\$1CONDITION\$1KEY\$1FOR\$1OIDC\$1PRINCIPAL

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing condition key for oidc principal: Using an Open ID Connect principal without a condition can be overly permissive. Add condition keys with a prefix that matches your federated OIDC principals to ensure that only the intended identity provider assumes the role.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using an Open ID Connect principal without a condition can be overly permissive. Add condition keys with a prefix that matches your federated OIDC principals to ensure that only the intended identity provider assumes the role."
```

**解決安全警告**

在沒有條件的情況下使用 Open ID Connect 主體可能會過於寬鬆。新增其字首與您的聯合 OIDC 主體相符的條件鍵，以確保只有預定的身分提供者擔任該角色。

**相關用語**
+ [建立 Web 身分的角色或 OpenID Connect 聯合身分 (主控台)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html)

## 安全性警告 – 缺少 github 儲存庫條件鍵
<a name="access-analyzer-reference-policy-checks-security-warning-missing-github-repo-condition-key"></a>

**問題代碼：**MISING\$1GITHUB\$1REPO\$1CONDITION\$1KEY

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Missing github repo condition key: Granting a federated GitHub principal permissions without a condition key can allow more sources to assume the role than you intended. Add the token.actions.githubusercontent.com:sub condition key and specify the branch and repository name in the value.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Granting a federated GitHub principal permissions without a condition key can allow more sources to assume the role than you intended. Add the token.actions.githubusercontent.com:sub condition key and specify the branch and repository name in the value."
```

**解決安全警告**

如果您使用 GitHub 做為 OIDC IdP，最佳實務是限制可擔任與 IAM IdP 相關聯角色的實體。當您在角色信任政策中包含 `Condition` 陳述式時，可以將角色限制到特定 GitHub 組織、儲存庫或分支。您可以使用條件鍵 `token.actions.githubusercontent.com:sub` 來限制存取。建議您將條件限制為一組特定的儲存庫或分支。如果您不包含此條件，則來自您控制範圍之外的組織或儲存庫的 GitHub 動作可以擔任與您 AWS 帳戶中的 GitHub IAM IdP 相關聯的角色。

**相關用語**
+ [設定 GitHub OIDC 身分提供者的角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html#idp_oidc_Create_GitHub)

## 安全警告 – 類似具有 ARN 條件索引鍵的運算子的字串
<a name="access-analyzer-reference-policy-checks-security-warning-string-like-operator-with-arn-condition-keys"></a>

**問題代碼：**STRING\$1LIKE\$1OPERATOR\$1WITH\$1ARN\$1CONDITION\$1KEYS

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
String like operator with ARN condition keys: Use the operator type {{allowed}} instead of operator {{operator}} for the condition key {{key}}.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Use the operator type {{allowed}} instead of operator {{operator}} for the condition key {{key}}."
```

**解決安全警告**

AWS 建議您在比較 ARN 時使用 ARNs 運算子而非字串運算子，以確保根據 ARN 條件值進行適當的存取限制。每當使用指定的索引鍵時，將 `StringLike` 運算子更新為 `Condition` 元素中的 `ArnLike` 運算子。

這些 AWS 受管政策是此安全性警告的例外狀況：
+ [AmazonSecurityLakeAdministrator](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonSecurityLakeAdministrator.html)
+ [AWSCodePipeline\$1FullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSCodePipeline_FullAccess.html)
+ [AWSCodePipeline\$1ReadOnlyAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSCodePipeline_ReadOnlyAccess.html)
+ [S3UnlockBucketPolicy](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/S3UnlockBucketPolicy.html)
+ [SQSUnlockQueuePolicy](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/SQSUnlockQueuePolicy.html)

**相關用語**
+ [Amazon Resource Name (ARN) 條件運算子](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html#Conditions_ARN)
+ [字串條件運算子](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html#Conditions_String)
+ [AWS 受管政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies)

## 安全警告 – 具有對象宣告類型的 ForAnyValue
<a name="access-analyzer-reference-policy-checks-security-warning-foranyvalue-with-audience-claim-type"></a>

**問題代碼：**FORANYVALUE\$1WITH\$1AUDIENCE\$1CLAIM\$1TYPE

**調查結果類型：**SECURITY\$1WARNING

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
ForAnyValue with audience claim type: Using ForAnyValue qualifier with the single-valued condition key {{key}} can be overly permissive. We recommend that you remove ForAnyValue:.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using ForAnyValue qualifier with the single-valued condition key {{key}} can be overly permissive. We recommend that you remove ForAnyValue:."
```

**解決安全警告**

AWS 建議您不要將`ForAnyValue`集合運算子與單值條件索引鍵搭配使用。只能將集合運算子與多值條件鍵搭配使用。請移除 `ForAnyValue` 集運算子。

**相關用語**
+ [單一值與多值內容索引鍵](reference_policies_condition-single-vs-multi-valued-context-keys.md)
+ [單一值內容金鑰政策範例](reference_policies_condition_examples-single-valued-context-keys.md)

## 建議 – 空陣列動作
<a name="access-analyzer-reference-policy-checks-suggestion-empty-array-action"></a>

**問題代碼：**EMPTY\$1ARRAY\$1ACTION

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty array action: This statement includes no actions and does not affect the policy. Specify actions.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "This statement includes no actions and does not affect the policy. Specify actions."
```

**解決建議**

陳述式必須包含一個 `Action` 或 `NotAction` 元素，其中包括一組動作。當元素為空時，政策陳述式不會提供任何許可。指定 `Action` 元素中的動作。
+ [IAM JSON 政策元素：動作](reference_policies_elements_action.md)

## 建議 – 空陣列條件
<a name="access-analyzer-reference-policy-checks-suggestion-empty-array-condition"></a>

**問題代碼：**EMPTY\$1ARRAY\$1CONDITION

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty array condition: There are no values for the condition key {{key}} and it does not affect the policy. Specify conditions.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "There are no values for the condition key {{key}} and it does not affect the policy. Specify conditions."
```

**解決建議**

選擇性的 `Condition` 元素結構會要求您使用條件運算子和鍵值組。當條件值為空時，條件會傳回 `true`，且政策陳述式不會提供任何許可。指定條件值。
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 建議 – 空陣列條件 ForAllValues
<a name="access-analyzer-reference-policy-checks-suggestion-empty-array-condition-forallvalues"></a>

**問題代碼：**EMPTY\$1ARRAY\$1CONDITION\$1FORALLVALUES

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty array condition ForAllValues: The ForAllValues prefix with an empty condition key matches only if the key {{key}} is missing from the request context. To determine if the request context is empty, we recommend that you use the Null condition operator with the value of true instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The ForAllValues prefix with an empty condition key matches only if the key {{key}} is missing from the request context. To determine if the request context is empty, we recommend that you use the Null condition operator with the value of true instead."
```

**解決建議**

`Condition` 元素結構會要求您使用條件運算子和鍵值組。`ForAllValues` 集合運算子會測試請求集每個成員的值是否為條件鍵集的子集。

當您使用 `ForAllValues` 與空條件鍵時，只有在請求中沒有鍵時才會符合條件。 AWS 建議如果您想要測試請求內容是否為空，請改用 `Null` 條件運算子。
+ [多值內容鍵](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)
+ [Null 條件運算子](reference_policies_elements_condition_operators.md#Conditions_Null)
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 建議 – 空陣列條件 ForAnyValue
<a name="access-analyzer-reference-policy-checks-suggestion-empty-array-condition-foranyvalue"></a>

**問題代碼：**EMPTY\$1ARRAY\$1CONDITION\$1FORANYVALUE

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty array condition ForAnyValue: The ForAnyValue prefix with an empty condition key {{key}} never matches the request context and it does not affect the policy. Specify conditions.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The ForAnyValue prefix with an empty condition key {{key}} never matches the request context and it does not affect the policy. Specify conditions."
```

**解決建議**

`Condition` 元素結構會要求您使用條件運算子和鍵值組。`ForAnyValues` 集合運算子會測試這組請求值是否至少有一個成員符合這組條件鍵值的至少一個成員。

當您使用 `ForAnyValues` 與空條件鍵時，條件一律不會相符。這表示陳述式不會影響 policy. AWS recommends 您重寫條件。
+ [多值內容鍵](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 建議 – 空陣列條件 IfExists
<a name="access-analyzer-reference-policy-checks-suggestion-empty-array-condition-ifexists"></a>

**問題代碼：**EMPTY\$1ARRAY\$1CONDITION\$1IFEXISTS

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty array condition IfExists: The IfExists suffix with an empty condition key matches only if the key {{key}} is missing from the request context. To determine if the request context is empty, we recommend that you use the Null condition operator with the value of true instead.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The IfExists suffix with an empty condition key matches only if the key {{key}} is missing from the request context. To determine if the request context is empty, we recommend that you use the Null condition operator with the value of true instead."
```

**解決建議**

`...IfExists` 後置詞會編輯條件運算子。這表示如果政策鍵中存在於請求的內容中，則依照政策所述來處理鍵。如果該鍵不存在，則評估條件元素為 true。

當您使用 `...IfExists` 與空條件鍵時，只有在請求中沒有鍵時才會符合條件。 AWS 建議如果您想要測試請求內容是否為空，請改用 `Null` 條件運算子。
+ [...IfExists 條件運算子](reference_policies_elements_condition_operators.md#Conditions_IfExists)
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 建議 – 空陣列主體
<a name="access-analyzer-reference-policy-checks-suggestion-empty-array-principal"></a>

**問題代碼：**EMPTY\$1ARRAY\$1PRINCIPAL

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty array principal: This statement includes no principals and does not affect the policy. Specify principals.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "This statement includes no principals and does not affect the policy. Specify principals."
```

**解決建議**

您必須在 IAM 角色和以資源為基礎的政策中使用 `Principal` 或 `NotPrincipal` 元素。資源型政策是您直接內嵌在資源中的政策。

當您在陳述式的 `Principal`元素中提供空陣列時，陳述式不會影響 policy. AWS recommends，建議您指定應可存取資源的主體。
+ [IAM JSON 政策元素：主體](reference_policies_elements_principal.md)
+ [IAM JSON 政策元素：NotPrincipal](reference_policies_elements_notprincipal.md)

## 建議 – 空陣列資源
<a name="access-analyzer-reference-policy-checks-suggestion-empty-array-resource"></a>

**問題代碼：**EMPTY\$1ARRAY\$1RESOURCE

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty array resource: This statement includes no resources and does not affect the policy. Specify resources.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "This statement includes no resources and does not affect the policy. Specify resources."
```

**解決建議**

陳述式必須包含 `Resource` 或 `NotResource` 元素。

當您在陳述式的資源元素中提供空陣列時，陳述式不會影響 policy. AWS recommends，您會為資源指定 Amazon Resource Name (ARNs)。
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)
+ [IAM JSON 政策元素：NotResource](reference_policies_elements_notresource.md)

## 建議 – 空物件條件
<a name="access-analyzer-reference-policy-checks-suggestion-empty-object-condition"></a>

**問題代碼：**EMPTY\$1OBJECT\$1CONDITION

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty object condition: This condition block is empty and it does not affect the policy. Specify conditions.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "This condition block is empty and it does not affect the policy. Specify conditions."
```

**解決建議**

`Condition` 元素結構會要求您使用條件運算子和鍵值組。

當您在陳述式的條件元素中提供空物件時，陳述式對政策沒有任何影響。移除可選元素或指定條件。
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 建議 – 空物件主體
<a name="access-analyzer-reference-policy-checks-suggestion-empty-object-principal"></a>

**問題代碼：**EMPTY\$1OBJECT\$1PRINCIPAL

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty object principal: This statement includes no principals and does not affect the policy. Specify principals.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "This statement includes no principals and does not affect the policy. Specify principals."
```

**解決建議**

您必須在 IAM 角色和以資源為基礎的政策中使用 `Principal` 或 `NotPrincipal` 元素。資源型政策是您直接內嵌在資源中的政策。

當您在陳述式的 `Principal`元素中提供空物件時，陳述式不會影響 policy. AWS recommends，建議您指定應可存取資源的主體。
+ [IAM JSON 政策元素：主體](reference_policies_elements_principal.md)
+ [IAM JSON 政策元素：NotPrincipal](reference_policies_elements_notprincipal.md)

## 建議 – 空 Sid 值
<a name="access-analyzer-reference-policy-checks-suggestion-empty-sid-value"></a>

**問題代碼：**EMPTY\$1SID\$1VALUE

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Empty Sid value: Add a value to the empty string in the Sid element.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Add a value to the empty string in the Sid element."
```

**解決建議**

選擇性的 `Sid` (陳述式 ID) 元素允許您輸入您為政策陳述式提供的識別碼。您可以將 `Sid` 值指派給陳述式陣列中的每個陳述式。如果您選擇使用 `Sid` 元素，您必須提供字串值。

**相關用語**
+ [IAM JSON 政策元素：Sid](reference_policies_elements_sid.md)

## 建議 – 等同於 null false
<a name="access-analyzer-reference-policy-checks-suggestion-equivalent-to-null-false"></a>

**問題代碼：**EQUIVALENT\$1TO\$1NULL\$1FALSE

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Equivalent to null false: We recommend replacing the key {{key}} in the condition block of {{operator}} with {{{recommendedKey}}: false} to ensure better enforcement of the condition.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "We recommend replacing the key {{key}} in the condition block of {{operator}} with {{{recommendedKey}}: false} to ensure better enforcement of the condition."
```

**解決建議**

將目前條件索引鍵取代為建議的索引鍵，並將索引鍵設為 `false`。此變更可改善政策清晰度，並確保條件評估更加可靠。更新條件區塊以使用 `{recommendedKey}: false`，而不使用目前的索引鍵-運算子組合。

**相關用語**
+ [IAM 政策元素：Condition](reference_policies_elements_condition.md)
+ [具有多個內容索引鍵或值的條件](reference_policies_condition-logic-multiple-context-keys-or-values.md)
+ [AWS 全域條件內容索引鍵](reference_policies_condition-keys.md)

## 建議 – 等同於 null true
<a name="access-analyzer-reference-policy-checks-suggestion-equivalent-to-null-true"></a>

**問題代碼：**EQUIVALENT\$1TO\$1NULL\$1TRUE

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Equivalent to null true: We recommend replacing the key {{key}} in the condition block of {{operator}} with {{{recommendedKey}}: true} to ensure better enforcement of the condition.
```

在對 AWS CLI 或 AWS API 的程式設計呼叫中，此檢查的問題清單包含下列訊息：

```
"findingDetails": "We recommend replacing the key {{key}} in the condition block of {{operator}} with {{{recommendedKey}}: true} to ensure better enforcement of the condition."
```

**解決建議**

將目前條件索引鍵取代為建議的索引鍵，並將索引鍵設為 `true`。此變更可改善政策清晰度，並確保條件評估更加可靠。更新條件區塊以使用 `{recommendedKey}: true`，而不使用目前的索引鍵-運算子組合。

**相關用語**
+ [IAM 政策元素：Condition](reference_policies_elements_condition.md)
+ [具有多個內容索引鍵或值的條件](reference_policies_condition-logic-multiple-context-keys-or-values.md)
+ [AWS 全域條件內容索引鍵](reference_policies_condition-keys.md)

## 建議 – 改善 IP 範圍
<a name="access-analyzer-reference-policy-checks-suggestion-improve-ip-range"></a>

**問題代碼：**IMPROVE\$1IP\$1RANGE

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Improve IP range: The non-zero bits in the IP address after the masked bits are ignored. Replace address with {{addr}}.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The non-zero bits in the IP address after the masked bits are ignored. Replace address with {{addr}}."
```

**解決建議**

IP 地址條件必須採用標準 CIDR 格式，例如 203.0.113.0/24 或 2001:DB8:1234:5678::/64。當您在遮罩位元之後包含非零位元時，不會考慮使用 condition. AWS recommends 您使用訊息中包含的新地址。
+ [IP 地址條件運算子](reference_policies_elements_condition_operators.md#Conditions_IPAddress)
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 建議 – Null 具有限定詞
<a name="access-analyzer-reference-policy-checks-suggestion-null-with-qualifier"></a>

**問題代碼：**NULL\$1WITH\$1QUALIFIER

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Null with qualifier: Avoid using the Null condition operator with the ForAllValues or ForAnyValue qualifiers because they always return a true or false respectively.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Avoid using the Null condition operator with the ForAllValues or ForAnyValue qualifiers because they always return a true or false respectively."
```

**解決建議**

在 `Condition` 元素中，您所建置的表達式使用條件運算子 (例如等於或小於) 來比較政策中的條件鍵與值，以及請求內容中的鍵與值。針對包含多個值的單一條件鍵請求，您必須使用 `ForAllValues` 或 `ForAnyValue` 集合運算子。

當您使用 `Null` 條件運算子與 `ForAllValues` 時，陳述式一律會傳回 `true`。當您搭配 使用 `Null` 條件運算子時`ForAnyValue`， 陳述式一律會傳回 `false`. AWS recommends，告知您搭配這些集合運算子使用 `StringLike`條件運算子。

**相關用語**
+ [多值內容鍵](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)
+ [Null 條件運算子](reference_policies_elements_condition_operators.md#Conditions_Null)
+ [條件元素](reference_policies_elements_condition.md)

## 建議 – 私有 IP 地址子集
<a name="access-analyzer-reference-policy-checks-suggestion-private-ip-address-subset"></a>

**問題代碼：**PRIVATE\$1IP\$1ADDRESS\$1SUBSET

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Private IP address subset: The values for condition key aws:SourceIp include a mix of private and public IP addresses. The private addresses will not have the desired effect. aws:SourceIp works only for public IP address ranges. To define permissions for private IP ranges, use aws:VpcSourceIp.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The values for condition key aws:SourceIp include a mix of private and public IP addresses. The private addresses will not have the desired effect. aws:SourceIp works only for public IP address ranges. To define permissions for private IP ranges, use aws:VpcSourceIp."
```

**解決建議**

全域條件鍵 `aws:SourceIp` 僅適用於公有 IP 地址範圍。

當您的 `Condition` 元素包含私有和公有 IP 地址的混合時，陳述式可能沒有預期的效果。您可以使用 `aws:VpcSourceIP` 來指定私有 IP 地址。

**注意**  
只有在請求來自指定 IP 地址並且透過 VPC 端點時，全域條件鍵 `aws:VpcSourceIP` 才會相符。
+ [aws:SourceIp 全域條件鍵](reference_policies_condition-keys.md#condition-keys-sourceip)
+ [aws:VpcSourceIp 全域條件鍵](reference_policies_condition-keys.md#condition-keys-vpcsourceip)
+ [IP 地址條件運算子](reference_policies_elements_condition_operators.md#Conditions_IPAddress)
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 建議 – 私有 NotIpAddress 子集
<a name="access-analyzer-reference-policy-checks-suggestion-private-not-ip-address-subset"></a>

**問題代碼：**PRIVATE\$1NOT\$1IP\$1ADDRESS\$1SUBSET

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Private NotIpAddress subset: The values for condition key aws:SourceIp include a mix of private and public IP addresses. The private addresses have no effect. aws:SourceIp works only for public IP address ranges. To define permissions for private IP ranges, use aws:VpcSourceIp.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The values for condition key aws:SourceIp include a mix of private and public IP addresses. The private addresses have no effect. aws:SourceIp works only for public IP address ranges. To define permissions for private IP ranges, use aws:VpcSourceIp."
```

**解決建議**

全域條件鍵 `aws:SourceIp` 僅適用於公有 IP 地址範圍。

當您的 `Condition` 元素包含 `NotIpAddress` 條件運算子與私有和公有 IP 地址的混合時，陳述式可能沒有預期的效果。每個未在政策中指定的公有 IP 地址都會相符。沒有任何私有 IP 地址會相符。為了達到這個效果，您可以使用 `NotIpAddress` 與 `aws:VpcSourceIP`，然後指定不應相符的私有 IP 地址。
+ [aws:SourceIp 全域條件鍵](reference_policies_condition-keys.md#condition-keys-sourceip)
+ [aws:VpcSourceIp 全域條件鍵](reference_policies_condition-keys.md#condition-keys-vpcsourceip)
+ [IP 地址條件運算子](reference_policies_elements_condition_operators.md#Conditions_IPAddress)
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 建議 – 冗餘動作
<a name="access-analyzer-reference-policy-checks-suggestion-redundant-action"></a>

**問題代碼：**REDUNDANT\$1ACTION

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Redundant action: The {{redundantActionCount}} action(s) are redundant because they provide similar permissions. Update the policy to remove the redundant action such as: {{redundantAction}}.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The {{redundantActionCount}} action(s) are redundant because they provide similar permissions. Update the policy to remove the redundant action such as: {{redundantAction}}."
```

**解決建議**

當您在 `Action`元素中使用萬用字元 (\$1) 時，您可以包含備援 permissions. AWS recommends，以檢閱您的政策，並僅包含您需要的許可。這可協助您移除冗餘動作。

例如，下列動作包含 `iam:GetCredentialReport` 動作兩次。

```
"Action": [
        "iam:Get*",
        "iam:List*",
        "iam:GetCredentialReport"
    ],
```

在此範例中，會針對以 `Get` 或 `List` 為開頭的每個 IAM 動作定義許可。當 IAM 新增其他取得或清單操作時，此政策將允許這些操作。您可能想要允許這全部的唯讀動作。`iam:GetCredentialReport` 動作已包含在內做為 `iam:Get*`。若要移除重複的許可，您可以移除 `iam:GetCredentialReport`。

當動作的所有內容都是冗餘時，您會收到此政策檢查的問題清單。在此範例中，如果元素包含 `iam:*CredentialReport`，其不被認為是冗餘。其中包括 `iam:GetCredentialReport` (此為冗餘) 以及 `iam:GenerateCredentialReport` (此非為冗餘)。移除 `iam:Get*` 或 `iam:*CredentialReport` 會變更政策的許可。
+ [IAM JSON 政策元素：動作](reference_policies_elements_action.md)

### AWS 具有此建議的 受管政策
<a name="accan-ref-policy-check-message-fix-suggestion-redundant-action-awsmanpol"></a>

[AWS 受管政策](access_policies_managed-vs-inline.md#aws-managed-policies)可讓您根據一般 AWS 使用案例 AWS 指派許可，以開始使用 。

冗餘動作並不會影響政策所授與的許可。使用 AWS 受管政策做為建立客戶受管政策的參考時， AWS 建議您從政策中移除備援動作。

## 建議 – 冗餘條件值編號
<a name="access-analyzer-reference-policy-checks-suggestion-redundant-condition-value-num"></a>

**問題代碼：**REDUNDANT\$1CONDITION\$1VALUE\$1NUM

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Redundant condition value num: Multiple values in {{operator}} are redundant. Replace with the {{greatest/least}} single value for {{key}}.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Multiple values in {{operator}} are redundant. Replace with the {{greatest/least}} single value for {{key}}."
```

**解決建議**

當您針對條件鍵中的類似值使用數值條件運算子時，您可以建立導致冗餘許可的重疊。

例如，下列 `Condition` 元素包含多個 `aws:MultiFactorAuthAge` 條件，具有 1200 秒的年齡重疊。

```
"Condition": {
        "NumericLessThan": {
          "aws:MultiFactorAuthAge": [
            "2700",
            "3600"
          ]
        }
      }
```

在此範例中，如果多重要素驗證 (MFA) 完成時少於 3600 秒 (1 小時) 以前，就會定義許可。您可以移除冗餘 `2700` 值。
+ [數位條件運算子](reference_policies_elements_condition_operators.md#Conditions_Numeric)
+ [IAM JSON 政策元素：條件](reference_policies_elements_condition.md)

## 建議 – 冗餘資源
<a name="access-analyzer-reference-policy-checks-suggestion-redundant-resource"></a>

**問題代碼：**REDUNDANT\$1RESOURCE

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Redundant resource: The {{redundantResourceCount}} resource ARN(s) are redundant because they reference the same resource. Review the use of wildcards (*)
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The {{redundantResourceCount}} resource ARN(s) are redundant because they reference the same resource. Review the use of wildcards (*)"
```

**解決建議**

在 Amazon 資源名稱 (ARN) 中使用萬用字元 (\$1) 時，您可以建立冗餘資源許可。

例如，下列 `Resource` 元素包含多個 ARN 與冗餘許可。

```
"Resource": [
            "arn:aws:iam::111122223333:role/jane-admin",
            "arn:aws:iam::111122223333:role/jane-s3only",
            "arn:aws:iam::111122223333:role/jane*"
        ],
```

在此範例中，會針對任何名稱開頭為 `jane` 的角色定義許可。您可以移除冗餘 `jane-admin` 和 `jane-s3only` ARN 而不變更結果許可。這確實會使政策為動態。其將定義任何未來角色開頭為 `jane` 的許可。如果政策的目的是允許存取靜態數量的角色，則移除最後一個 ARN，並僅列出應定義的 ARN。
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

### AWS 具有此建議的 受管政策
<a name="accan-ref-policy-check-message-fix-suggestion-redundant-resource-awsmanpol"></a>

[AWS 受管政策](access_policies_managed-vs-inline.md#aws-managed-policies)可讓您根據一般 AWS 使用案例 AWS 指派許可，以開始使用 。

冗餘資源並不會影響政策所授與的許可。使用 AWS 受管政策做為建立客戶受管政策的參考時， AWS 建議您從政策中移除備援資源。

## 建議 – 冗餘陳述式
<a name="access-analyzer-reference-policy-checks-suggestion-redundant-statement"></a>

**問題代碼：**REDUNDANT\$1STATEMENT

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Redundant statement: The statements are redundant because they provide identical permissions. Update the policy to remove the redundant statement.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The statements are redundant because they provide identical permissions. Update the policy to remove the redundant statement."
```

**解決建議**

`Statement` 元素是政策的主要元素。此元素為必要。`Statement` 元素可包含單一陳述式，或是個別陳述式的陣列。

當您在長政策中多次包含相同的陳述式時，陳述式為冗餘。您可以移除其中一個陳述式，而不會影響政策授與的許可。當有人編輯政策時，他們可能會變更其中一個陳述式，而不會更新複本。這可能會導致超過預期的許可。
+ [IAM JSON 政策元素：陳述式](reference_policies_elements_statement.md)

## 建議 – 服務名稱中的萬用字元
<a name="access-analyzer-reference-policy-checks-suggestion-wildcard-in-service-name"></a>

**問題代碼：**WILDCARD\$1IN\$1SERVICE\$1NAME

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Wildcard in service name: Avoid using wildcards (*, ?) in the service name because it might grant unintended access to other AWS services with similar names.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Avoid using wildcards (*, ?) in the service name because it might grant unintended access to other AWS services with similar names."
```

**解決建議**

當您在政策中包含 AWS 服務的名稱時， AWS 建議您不要包含萬用字元 (\$1、？)。這可能會為您不想要的未來服務新增許可。例如，有十幾個 AWS 服務在名稱`*code*`中包含 單字。

```
"Resource": "arn:aws:*code*::111122223333:*"
```
+ [IAM JSON 政策元素：資源](reference_policies_elements_resource.md)

## 建議 - 使用服務不支援的標籤條件鍵允許
<a name="access-analyzer-reference-policy-checks-suggestion-allow-with-unsupported-tag-condition-key-for-service"></a>

**問題代碼：**ALLOW\$1WITH\$1UNSUPPORTED\$1TAG\$1CONDITION\$1KEY\$1FOR\$1SERVICE

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Allow with unsupported tag condition key for service: Using the effect Allow with the tag condition key {{conditionKeyName}} and actions for services with the following prefixes does not affect the policy: {{serviceNames}}. Actions for the listed service are not allowed by this statement. We recommend that you move these actions to a different statement without this condition key.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using the effect Allow with the tag condition key {{conditionKeyName}} and actions for services with the following prefixes does not affect the policy: {{serviceNames}}. Actions for the listed service are not allowed by this statement. We recommend that you move these actions to a different statement without this condition key."
```

**解決建議**

在政策的 `Condition`元素中使用不支援的標籤條件金鑰，`"Effect": "Allow"`不會影響政策授予的許可，因為該服務動作會忽略該條件。 AWS 建議您移除不支援條件金鑰之服務的動作，並建立另一個陳述式，以允許存取該服務中的特定資源。

如果您使用 `aws:ResourceTag` 條件鍵，且其不受服務動作支援，則該鍵不會包含在要求內容中。在此案例中，`Allow` 陳述式中的條件一律會傳回 `false`，且絕不會允許該動作。即使已正確標記資源，也會發生這種情況。

當服務支援 `aws:ResourceTag` 條件鍵時，您可以使用標籤來控制對該服務之資源的存取。這稱為[以屬性為基礎的存取控制 (ABAC)](introduction_attribute-based-access-control.md)。不支援這些鍵的服務需要您使用[以資源為基礎的存取控制 (RBAC)](introduction_attribute-based-access-control.md#introduction_attribute-based-access-control_compare-rbac) 來控制對資源的存取權。

**注意**  
某些服務允許支援其資源和動作子集的 `aws:ResourceTag` 條件鍵。IAM Access Analyzer 會傳回不支援服務動作的問題清單。例如，Amazon S3 支援 `aws:ResourceTag` 以取得其資源的子集。若要檢視 Amazon S3 中可用且支援 `aws:ResourceTag` 條件鍵的所有資源類型，請參閱服務授權參考中的 [Amazon S3 定義的資源類型](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html#amazons3-resources-for-iam-policies)。

例如，假設您想要允許團隊成員檢視標記為鍵值組 `team=BumbleBee` 的特定資源詳細資訊。也假設 AWS Lambda 允許您標記資源，但不支援 `aws:ResourceTag`條件金鑰。若要允許 AWS App Mesh 和 的檢視動作， AWS Backup 如果此標籤存在，請使用 `aws:ResourceTag`條件索引鍵。對於 Lambda，請使用資源命名慣例，其中包含團隊名稱做為字首。接著納入一個單獨的陳述式，以允許檢視採用該命名慣例的資源。

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowViewSupported",
            "Effect": "Allow",
            "Action": [
                "appmesh:DescribeMesh", 
                "backup:GetBackupPlan"
                ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/team": "BumbleBee"
                }
            }
        },
        {
            "Sid": "AllowViewUnsupported",
            "Effect": "Allow",
            "Action": "lambda:GetFunction",
            "Resource": "arn:aws:lambda:*:123456789012:function:team-BumbleBee*"
        }
    ]
}
```

**警告**  
請勿使用 `Not` [版的條件運算子](reference_policies_elements_condition_operators.md)搭配 `"Effect": "Allow"` 做為此問題清單的解決方法。這些條件運算子提供否定相符。這表示評估條件後，結果受到否定。在上述範例中，在 `AllowViewSupported` 陳述式中包含 `lambda:GetFunction` 動作與 `StringNotEquals` 運算子一律允許動作，無論該資源是否已加上標籤。  
請勿使用 …[IfExists](reference_policies_elements_condition_operators.md#Conditions_IfExists) 版本的條件運算子做為此問題清單的解決方法。這表示「如果鍵存在於請求內容中，且值相符，則允許動作。否則，允許動作。」 在上述範例中，在 `AllowViewSupported` 陳述式中包含 `lambda:GetFunction` 動作與 `StringEqualsIfExists` 運算子一律會允許該動作。對於該動作，鍵不存在於內容中，且每次嘗試檢視該資源類型都會允許，無論該資源是否已加上標籤。

**相關用語**
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)
+ [條件元素](reference_policies_elements_condition.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 建議 - 使用服務不支援的標籤條件鍵允許 NotAction
<a name="access-analyzer-reference-policy-checks-suggestion-allow-notaction-with-unsupported-tag-condition-key-for-service"></a>

**問題代碼：**ALLOW\$1NOTACTION\$1WITH\$1UNSUPPORTED\$1TAG\$1CONDITION\$1KEY\$1FOR\$1SERVICE

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Allow NotAction with unsupported tag condition key for service: Using the effect Allow with NotAction and the tag condition key {{conditionKeyName}} allows only service actions that support the condition key. The condition key doesn't apply to some service actions. We recommend that you use Action instead of NotAction.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "Using the effect Allow with NotAction and the tag condition key {{conditionKeyName}} allows only service actions that support the condition key. The condition key doesn't apply to some service actions. We recommend that you use Action instead of NotAction."
```

**解決建議**

在政策的 `Condition` 元素中使用不受支援的標籤條件鍵與元素 `NotAction` 和 `"Effect": "Allow"` 並不會影響政策所授與的許可。對於不支援 condition key. AWS recommends 的服務動作，系統會忽略條件。建議您重寫邏輯，以允許動作清單。

如果您使用 `aws:ResourceTag` 條件鍵與 `NotAction`，則不會允許任何不支援鍵的新或現有服務動作。 AWS 建議您明確列出您要允許的動作。IAM Access Analyzer 會針對所列出不支援 `aws:ResourceTag` 條件鍵的動作傳回個別的問題清單。如需詳細資訊，請參閱 [建議 - 使用服務不支援的標籤條件鍵允許](#access-analyzer-reference-policy-checks-suggestion-allow-with-unsupported-tag-condition-key-for-service)。

當服務支援 `aws:ResourceTag` 條件鍵時，您可以使用標籤來控制對該服務之資源的存取。這稱為[以屬性為基礎的存取控制 (ABAC)](introduction_attribute-based-access-control.md)。不支援這些鍵的服務需要您使用[以資源為基礎的存取控制 (RBAC)](introduction_attribute-based-access-control.md#introduction_attribute-based-access-control_compare-rbac) 來控制對資源的存取權。

**相關用語**
+ [全域條件鍵](reference_policies_condition-keys.md)
+ [比較 ABAC 與 RBAC](introduction_attribute-based-access-control.md#introduction_attribute-based-access-control_compare-rbac)
+ [IAM JSON 政策元素：條件運算子](reference_policies_elements_condition_operators.md)
+ [條件元素](reference_policies_elements_condition.md)
+ [JSON 政策概觀](access_policies.md#access_policies-json)

## 建議 – 服務主體的建議條件鍵
<a name="access-analyzer-reference-policy-checks-suggestion-recommended-condition-key-for-service-principal"></a>

**問題代碼：**RECOMMENDED\$1CONDITION\$1KEY\$1FOR\$1SERVICE\$1PRINCIPAL

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Recommended condition key for service principal: To restrict access to the service principal {{servicePrincipalPrefix}} operating on your behalf, we recommend aws:SourceArn, aws:SourceAccount, aws:SourceOrgID, or aws:SourceOrgPaths instead of {{key}}.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "To restrict access to the service principal {{servicePrincipalPrefix}} operating on your behalf, we recommend aws:SourceArn, aws:SourceAccount, aws:SourceOrgID, or aws:SourceOrgPaths instead of {{key}}."
```

**解決建議**

您可以使用*服務委託*人在資源型政策的 `Principal`元素 AWS 服務 中指定 ，這是服務的識別符。在授予對服務主體的存取權時，您應該使用 `aws:SourceArn`、`aws:SourceAccount`、`aws:SourceOrgID` 或 `aws:SourceOrgPaths` 條件鍵，而不是其他條件鍵 (例如 `aws:Referer`)。這可協助您避免名為*混淆代理人問題*的安全問題。

**相關用語**
+ [AWS 服務 主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services)
+ [AWS 全域條件索引鍵：aws：SourceAccount](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceaccount)
+ [AWS 全域條件索引鍵：aws：SourceArn](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcearn)
+ [AWS 全域條件索引鍵：aws：SourceOrgId](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceorgid)
+ [AWS 全域條件索引鍵：aws：SourceOrgPaths](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceorgpaths)
+ [混淆代理人問題](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html)

## 建議 - 政策中的不相關條件鍵
<a name="access-analyzer-reference-policy-checks-suggestion-irrelevant-condition-key-in-policy"></a>

**問題代碼：**IRRELEVANT\$1CONDITION\$1KEY\$1IN\$1POLICY

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Irrelevant condition key in policy: The condition key {{condition-key}} is not relevant for the {{resource-type}} policy.  Use this key in an identity-based policy to govern access to this resource.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The condition key {{condition-key}} is not relevant for the {{resource-type}} policy.  Use this key in an identity-based policy to govern access to this resource."
```

**解決建議**

部分條件鍵與資源型政策無關。例如，`s3:ResourceAccount` 條件鍵與連接至 Amazon S3 儲存貯體或 Amazon S3 存取點資源類型的資源型政策無關。

您應在身分型政策中使用條件鍵，以控制存取資源。

**相關用語**
+ [以身分為基礎的政策和以資源為基礎的政策](access_policies_identity-vs-resource.md)

## 建議 – 因條件中的萬用字元而導致冗餘索引鍵
<a name="access-analyzer-reference-policy-checks-suggestion-redundant-key-due-to-wildcard-in-condition"></a>

**問題代碼：**REDUNDANT\$1KEY\$1DUE\$1TO\$1WILDCARD\$1IN\$1CONDITION

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Redundant key due to wildcard in condition: The key {{key}} in the condition block of {{operator}} is redundant because it is always matched. Remove this key to simplify the condition.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The key {{key}} in the condition block of {{operator}} is redundant because it is always matched. Remove this key to simplify the condition."
```

**解決建議**

從政策中移除冗餘的條件索引鍵。由於萬用字元模式，索引鍵一律相符，因此不需要此索引鍵。移除此索引鍵可以簡化條件區塊，同時保持相同的有效許可。

**相關用語**
+ [IAM 政策元素：Condition](reference_policies_elements_condition.md)
+ [具有多個內容索引鍵或值的條件](reference_policies_condition-logic-multiple-context-keys-or-values.md)
+ [AWS 全域條件內容索引鍵](reference_policies_condition-keys.md)

## 建議 – 角色信任政策中的冗餘主體
<a name="access-analyzer-reference-policy-checks-suggestion-redundant-principal-in-role-trust-policy"></a>

**問題代碼：**REDUNDANT\$1PRINCIPAL\$1IN\$1ROLE\$1TRUST\$1POLICY

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Redundant principal in role trust policy: The assumed-role principal {{redundant_principal}} is redundant with its parent role {{parent_role}}. Remove the assumed-role principal.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The assumed-role principal {{redundant_principal}} is redundant with its parent role {{parent_role}}. Remove the assumed-role principal."
```

**解決建議**

如果您在政策的 `Principal` 元素中同時指定擔任角色的主體及其父角色，則它會不允許或拒絕任何不同的許可。例如，如果您使用下列格式指定 `Principal` 元素，則其為冗餘主體：

```
"Principal": {
            "AWS": [
            "arn:aws:iam::AWS-account-ID:role/rolename",
            "arn:aws:iam::AWS-account-ID:assumed-role/rolename/rolesessionname"
        ]
```

我們建議移除擔任角色的主體。

**相關用語**
+ [角色工作階段主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-role-session)

## 建議 – 因條件中的萬用字元而導致冗餘陳述式
<a name="access-analyzer-reference-policy-checks-suggestion-redundant-statement-due-to-wildcard-in-condition"></a>

**問題代碼：**REDUNDANT\$1STATEMENT\$1DUE\$1TO\$1WILDCARD\$1IN\$1CONDITION

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Redundant statement due to wildcard in condition: The key {{key}} in the condition block of {{operator}} does not match any values. Remove this key to simplify the condition.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The key {{key}} in the condition block of {{operator}} does not match any values. Remove this key to simplify the condition."
```

**解決建議**

移除與任何值均不相符的條件索引鍵。此索引鍵建立了一個永遠無法滿足的不可達條件，因此它是多餘的。透過移除此索引鍵來清理政策，從而改善可讀性和效能。

**相關用語**
+ [IAM 政策元素：Condition](reference_policies_elements_condition.md)
+ [具有多個內容索引鍵或值的條件](reference_policies_condition-logic-multiple-context-keys-or-values.md)
+ [AWS 全域條件內容索引鍵](reference_policies_condition-keys.md)

## 建議 – 確認對象要求類型
<a name="access-analyzer-reference-policy-checks-suggestion-confirm-audience-claim-type"></a>

**問題代碼：**CONFIRM\$1AUDIENCE\$1CLAIM\$1TYPE

**調查結果類型：**SUGGESTION

**尋找詳細資訊**

在 中 AWS 管理主控台，此檢查的調查結果包含下列訊息：

```
Confirm audience claim type: The "{{key}}" ({{audienceType}}) claim key identifies the recipients that the JSON web token is intended for. Because this claim is single-valued, do not use a qualifier.
```

在以程式設計方式呼叫 AWS CLI 或 AWS API 時，此檢查的問題清單包含下列訊息：

```
"findingDetails": "The "{{key}}" ({{audienceType}}) claim key identifies the recipients that the JSON web token is intended for. Because this claim is single-valued, do not use a qualifier."
```

**解決建議**

`aud` (對象) 要求鍵是您在向 IdP 註冊應用程式時向您發佈的應用程式的唯一識別符，可識別 JSON Web 符記適用的收件人。對象要求可以是多重值或單一值。如果要求是多重值，請使用 `ForAllValues` 或 `ForAnyValue` 條件集運算子。如果要求是單一值，請勿使用條件集運算子。

**相關用語**
+ [建立 Web 身分的角色或 OpenID Connect 聯合身分 (主控台)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html)
+ [多值內容鍵](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-single-vs-multi-valued-context-keys.html#reference_policies_condition-multi-valued-context-keys)
+ [單一值與多重值的條件鍵](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_single-vs-multi-valued-condition-keys.html)

# 使用 IAM Access Analyzer 自訂政策檢查來驗證政策
<a name="access-analyzer-custom-policy-checks"></a>

您可以使用自訂政策檢查，根據您的安全標準來檢查是否有新的存取權。每次檢查新存取權都會收取費用。如需定價的詳細資訊，請參閱 [IAM Access Analyzer 定價](https://aws.amazon.com/iam/access-analyzer/pricing)。

## 使用自訂政策檢查驗證政策 (主控台)
<a name="access-analyzer-custom-policy-checks-console"></a>

在 IAM 主控台中使用 JSON 政策編輯器編輯政策時，您可以執行自訂政策檢查，此為選用步驟。您可以檢查與現有版本相比，更新版政策是否授予新的存取權。

**在編輯 IAM JSON 政策時檢查是否有新的存取權**

1. 登入 AWS 管理主控台 ，並在 https：//[https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/) 開啟 IAM 主控台。

1. 在左側的導覽窗格中，選擇 **Policies (政策)**。

1. 在政策清單中，選擇您要編輯的政策之名稱。您可以使用搜尋方塊來篩選政策清單。

1. 選擇**許可**索引標籤，然後選擇**編輯**。

1. 選擇 **JSON** 選項並更新政策。

1. 在政策下方的政策驗證窗格中，選擇**檢查新的存取權**索引標籤，然後選擇**檢查政策**。如果修改後的許可會授予新存取權，該陳述式會在政策驗證窗格中反白顯示。

1. 如果您不打算授予新的存取權，請更新政策陳述式並選擇**檢查政策**，直到沒有偵測到新的存取權為止。
**注意**  
每次檢查新存取權都會收取費用。如需定價的詳細資訊，請參閱 [IAM Access Analyzer 定價](https://aws.amazon.com/iam/access-analyzer/pricing)。

1. 選擇**下一步**。

1. 在**檢視與儲存**頁面上，檢視**此政策中定義的許可**，然後選擇**儲存變更**。

## 使用自訂政策檢查 (AWS CLI 或 API) 驗證政策
<a name="access-analyzer-custom-policy-checks-cli-api"></a>

您可以從 AWS CLI 或 IAM Access Analyzer API 執行 IAM Access Analyzer 自訂政策檢查。

### 執行 IAM Access Analyzer 自訂政策檢查 (AWS CLI)
<a name="access-analyzer-custom-policy-checks-cli"></a>
+ 若要在與現有政策進行比較時，檢查更新版政策是否允許新存取權，請執行下列命令：[https://docs.aws.amazon.com/cli/latest/reference/accessanalyzer/check-no-new-access.html](https://docs.aws.amazon.com/cli/latest/reference/accessanalyzer/check-no-new-access.html)
+ 若要檢查政策是否不允許指定的存取權，請執行下列命令：[https://docs.aws.amazon.com/cli/latest/reference/accessanalyzer/check-access-not-granted.html](https://docs.aws.amazon.com/cli/latest/reference/accessanalyzer/check-access-not-granted.html)
+ 若要檢查資源政策是否可以授予指定資源類型的公開存取權，請執行下列命令：[https://docs.aws.amazon.com/cli/latest/reference/accessanalyzer/check-no-public-access.html](https://docs.aws.amazon.com/cli/latest/reference/accessanalyzer/check-no-public-access.html)

### 執行 IAM Access Analyzer 自訂政策檢查 (API)
<a name="access-analyzer-custom-policy-checks-api"></a>
+ 若要在與現有政策進行比較時，檢查更新版政策是否允許新存取權，請使用 [https://docs.aws.amazon.com/access-analyzer/latest/APIReference/API_CheckNoNewAccess.html](https://docs.aws.amazon.com/access-analyzer/latest/APIReference/API_CheckNoNewAccess.html) API 操作。
+ 若要檢查政策是否不允許指定的存取權，請使用 [https://docs.aws.amazon.com/access-analyzer/latest/APIReference/API_CheckAccessNotGranted.html](https://docs.aws.amazon.com/access-analyzer/latest/APIReference/API_CheckAccessNotGranted.html) API 操作。
+ 若要檢查資源政策是否可以授予指定資源類型的公開存取權，請使用 [https://docs.aws.amazon.com/access-analyzer/latest/APIReference/API_CheckNoPublicAccess.html](https://docs.aws.amazon.com/access-analyzer/latest/APIReference/API_CheckNoPublicAccess.html) API 操作。