

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

# 疑難排解 API 連結政策存放區
<a name="policy-stores-api-userpool-considerations-troubleshooting"></a>

當您建置 Amazon Verified Permissions API 連結政策存放區時，請使用此處的資訊來協助您診斷和修正常見問題。

**Topics**
+ [我已更新我的政策，但授權決策未變更](#policy-stores-api-userpool-considerations-troubleshooting-update-didnt-change)
+ [我將 Lambda 授權方連接到我的 API，但它不會產生授權請求](#policy-stores-api-userpool-considerations-troubleshooting-attached-not-deployed)
+ [我收到非預期的授權決策，並想要檢閱授權邏輯](#policy-stores-api-userpool-considerations-troubleshooting-review-code)
+ [我想要從我的 Lambda 授權方尋找日誌](#policy-stores-api-userpool-considerations-troubleshooting-find-logs)
+ [我的 Lambda 授權方不存在](#policy-stores-api-userpool-considerations-troubleshooting-didnt-deploy)
+ [我的 API 位於私有 VPC 中，無法叫用授權方](#policy-stores-api-userpool-considerations-troubleshooting-in-a-vpc)
+ [我想要在授權模型中處理其他使用者屬性](#policy-stores-api-userpool-considerations-troubleshooting-fgac)
+ [我想要新增動作、動作內容屬性或資源屬性](#policy-stores-api-userpool-considerations-troubleshooting-action-resource-attributes)

## 我已更新我的政策，但授權決策未變更
<a name="policy-stores-api-userpool-considerations-troubleshooting-update-didnt-change"></a>

根據預設，Verified Permissions 會將 Lambda 授權方設定為快取授權決策 120 秒。兩分鐘後再試一次，或停用授權方上的快取。如需詳細資訊，請參閱《*Amazon API Gateway * [API Gateway 開發人員指南》中的啟用 API 快取以增強回應能力](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html)。

## 我將 Lambda 授權方連接到我的 API，但它不會產生授權請求
<a name="policy-stores-api-userpool-considerations-troubleshooting-attached-not-deployed"></a>

若要開始處理請求，您必須部署您連接授權方的 API 階段。如需詳細資訊，請參閱[《Amazon API Gateway 開發人員指南》中的部署 REST](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-deploy-api.html) *Amazon API Gateway*。

## 我收到非預期的授權決策，並想要檢閱授權邏輯
<a name="policy-stores-api-userpool-considerations-troubleshooting-review-code"></a>

API 連結政策存放區程序會為您的授權方建立 Lambda 函數。Verified Permissions 會自動將授權決策的邏輯建置到授權方函數中。您可以在建立政策存放區後返回，以檢閱和更新函數中的邏輯。

若要從 AWS CloudFormation 主控台尋找 Lambda 函數，請選擇新政策存放區**概觀**頁面上的**檢查部署**按鈕。

您也可以在 AWS Lambda 主控台中找到您的 函數。導覽至政策存放 AWS 區域 區 中的 主控台，並搜尋字首為 的函數名稱`AVPAuthorizerLambda`。如果您已建立多個 API 連結政策存放區，請使用函數的**上次修改**時間，將它們與政策存放區建立關聯。

## 我想要從我的 Lambda 授權方尋找日誌
<a name="policy-stores-api-userpool-considerations-troubleshooting-find-logs"></a>

Lambda 函數會收集指標，並在 Amazon CloudWatch 中記錄其調用結果。若要檢閱您的日誌，請在 Lambda 主控台中[尋找您的函數](#policy-stores-api-userpool-considerations-troubleshooting-review-code)，然後選擇**監控**索引標籤。選取**檢視 CloudWatch 日誌**並檢閱日誌群組中的項目。

如需 Lambda 函數日誌的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配 使用 Amazon CloudWatch Logs AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html)。

## 我的 Lambda 授權方不存在
<a name="policy-stores-api-userpool-considerations-troubleshooting-didnt-deploy"></a>

完成 API 連結政策存放區的設定後，您必須將 Lambda 授權方連接至您的 API。如果您在 API 閘道 主控台中找不到授權方，則政策存放區的其他資源可能已失敗或尚未部署。API 連結政策會將這些資源部署在 CloudFormation 堆疊中。

Verified Permissions 會在建立程序結束時顯示具有標籤 **檢查部署** 的連結。如果您已離開此畫面，請前往 CloudFormation 主控台並搜尋最近堆疊中字首為 的名稱`AVPAuthorizer-<policy store ID>`。CloudFormation 在堆疊部署的輸出中提供寶貴的疑難排解資訊。

如需 CloudFormation 堆疊疑難排解的說明，請參閱*AWS CloudFormation 《 使用者指南*》中的 [ CloudFormation 疑難排解](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html)。

## 我的 API 位於私有 VPC 中，無法叫用授權方
<a name="policy-stores-api-userpool-considerations-troubleshooting-in-a-vpc"></a>

Verified Permissions 不支援透過 VPC 端點存取 Lambda 授權方。您必須在 API 和做為授權方的 Lambda 函數之間開啟網路路徑。

## 我想要在授權模型中處理其他使用者屬性
<a name="policy-stores-api-userpool-considerations-troubleshooting-fgac"></a>

API 連結政策存放區程序會從使用者字符中的群組宣告衍生 Verified Permissions 政策。若要更新您的授權模型以考慮其他使用者屬性，請在政策中整合這些屬性。

您可以將 ID 和存取權杖中的許多宣告從 Amazon Cognito 使用者集區映射至 Verified Permissions 政策陳述式。例如，大多數使用者在其 ID 字符中都有 `email`宣告。如需有關將宣告從身分來源新增至政策的詳細資訊，請參閱將[Amazon Cognito 權杖映射至結構描述](cognito-map-token-to-schema.md)，以及將 [OIDC 權杖映射至結構描述](oidc-map-token-to-schema.md)。

## 我想要新增動作、動作內容屬性或資源屬性
<a name="policy-stores-api-userpool-considerations-troubleshooting-action-resource-attributes"></a>

API 連結的政策存放區及其建立的 Lambda 授權方是point-in-time資源。它們會在建立時反映 API 的狀態。政策存放區結構描述不會將任何內容屬性指派給動作，也不會將任何屬性或父項指派給預設`Application`資源。

當您新增動作 — 路徑和方法到您的 API 時，您必須更新您的政策存放區，以注意新的動作。您還必須更新 Lambda 授權方，以處理新動作的授權請求。您可以[重新開始新的政策存放](policy-stores-create.md)區，也可以更新現有的政策存放區。

若要更新現有的政策存放區，請[尋找您的 函數](#policy-stores-api-userpool-considerations-troubleshooting-review-code)。檢查自動產生的函數中的邏輯，並加以更新以處理新的動作、屬性或內容。然後[，編輯您的結構描述](schema-edit.md)以包含新的動作和屬性。