跳至內容

如何針對 AWS Organizations 中的 SCP 明確拒絕錯誤進行疑難排解?

2 分的閱讀內容
0

我的 AWS Organizations 會員帳戶收到類似以下明確拒絕錯誤訊息: "The IAM Entity is not authorized to perform API action on resource: arn:aws:iam::123456789012:role/Admin with an explicit deny in a service control policy".

簡短描述

您可以使用 Organizations 服務控制政策 (SCP) 來管理組織中會員帳戶的許可。然而,SCP 不會授予許可給貴組織中的 AWS Identity and Access Management (IAM) 身分。

若要允許存取某個 API 動作,SCP 與 IAM 身分型政策都必須同時允許該會員帳戶進行存取。

解決方法

若要確認該明確拒絕錯誤是否因 SCP 拒絕請求而引起,請使用 AWS CloudTrail 事件歷史記錄來搜尋該事件名稱。接著,從 AWS Organizations 管理帳戶使用 Organizations 主控台,選擇移除或修改政策,以允許該 API 動作請求。

注意: 如果您在執行 AWS Command Line Interface (AWS CLI) 命令時收到錯誤訊息,請參閱 Troubleshoot AWS CLI errors (對 AWS CLI 錯誤進行疑難排解)。此外,請務必使用最新版 AWS CLI。

檢視 CloudTrail 事件歷史記錄

使用 CloudTrail 主控台

您可以檢視過去 90 天內所有支援的服務與整合以及事件類型,例如建立、修改、刪除及不可變更的活動。您不需要設定追蹤,即可使用 CloudTrail 事件歷史記錄。

如需相關指示,請參閱 Viewing recent CloudTrail events in the CloudTrail console (在 CloudTrail 主控台中檢視近期 CloudTrail 事件)。

使用 AWS CLI

執行 lookup-events AWS CLI 命令,查詢過去 90 天內的管理事件或 CloudTrail Insights 事件。

使用 filter-log-events 命令套用指標篩選器,以搜尋日誌事件中的特定詞彙、詞組和值。隨後您可以將其轉換為 CloudWatch 指標與警示。

如需更多資訊,請參閱指標篩選器、訂閱篩選器、篩選日誌事件和 Live Tail 的篩選模式語法。

使用 AWS Organizations 主控台移除或修改 SCP

請完成下列步驟:

  1. 使用您的 AWS Organization 管理帳戶開啟 AWS Organizations 主控台。
  2. 在導覽窗格中,選擇 AWS accounts (AWS 帳戶),然後選擇受影響的會員帳戶。
  3. 選擇 Policies (政策) 索引標籤,然後檢視所有已套用且限制存取 API 動作的 SCP。
  4. 若要編輯政策,請選擇 SCP,然後選擇 Edit policy (編輯政策)。編輯完成後,請選擇 Save changes (儲存變更)。
    -或-
    若要刪除政策,請選取 SCP,然後選擇 Delete (刪除)。
    -或-
    若要卸離政策,請選取 SCP,然後選擇 Detach (卸離)。

使用 AWS CLI 管理服務控制政策

擷取政策詳細資訊

若要描述政策並檢視政策目前的組態與內容,請執行下列 describe-policy AWS CLI 命令:

aws organizations describe-policy --policy-id policy-id

注意: 請將 policy-id 替換成您的政策 ID。

上述命令會傳回該政策的中繼資料,包含名稱、說明、類型以及完整的 JSON 政策文件。

識別已連接的目標

若要確定哪些組織單位或帳戶受該政策影響,請執行下列 list-targets-for-policy AWS CLI 命令:

aws organizations list-targets-for-policy --policy-id policy-id

注意: 請將 policy-id 替換成您的政策 ID。

上述命令會列出該政策目前已連接的所有目標,這有助於在進行變更前評估影響範圍。

更新政策

若要修改政策,請使用更新後的 JSON 政策文件執行下列 update-policy AWS CLI 命令:

aws organizations update-policy --policy-id policy-id --content "Updated JSON"

注意: 請將 policy-id 替換成您的政策 ID,並將 Updated JSON 替換成您更新後的政策文件。

請確認 JSON 內容已正確轉義,且格式正確無誤。對於複雜的政策,請將 JSON 儲存於檔案中並使用 file:// 前綴:

aws organizations update-policy --policy-id policy-id --content file://updated-policy.json

注意: 請將 policy-id 替換成您的政策 ID,並將 updated-policy.json 替換成您的政策文件檔。

卸離或刪除政策

若您需要完全移除政策而非進行修改,請完成下列步驟:

  1. 若要從特定目標卸離政策,請執行下列 detach-policy 命令:

    aws organizations detach-policy --policy-id policy-id --target-id target-id

    注意: 請將 policy-id 替換成您的政策 ID,並將 target-id 替換成您的目標 ID。

  2. 若要在從所有目標卸離政策後將其刪除,請執行下列 delete-policy 命令:

    aws organizations delete-policy --policy-id policy-id

    注意: 請將 policy-id 替換成您的政策 ID。

確認明確拒絕錯誤已解決

請從會員帳戶再次執行 API 動作,確認明確拒絕錯誤已順利解決。

相關資訊

服務控制政策 (SCP)

Enhanced access denied error messages with policy ARNs (帶有政策 ARN 的增強版拒絕存取錯誤訊息)

Viewing details of an organization from the management account (從管理帳戶檢視組織的詳細資訊)