使用 CloudFormation 部署 API 阶段时是否可以禁用需要授权
值?
由于我使用 OAuth 和 Cognito 来保护 API,因此无法添加 InvalidateCache
策略,如下所述:
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html#invalidate-method-caching
最佳答案
事实证明,CloudFormation 不支持此功能,如下所述:https://github.com/aws/aws-cdk/issues/18794
我想出的最好办法是在部署阶段后使用 AWS CLI 作为 CI/CD 管道的一部分禁用需要授权
:
aws apigateway update-stage --rest-api-id [api-id] --stage-name [stage_name] --patch-operations \
op="replace",path="'the_resource_path/GET/caching/requireAuthorizationForCacheControl'",value="false"
请注意,资源路径必须根据此处描述的规则进行转义:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/apigateway/client/update_stage.html
关于amazon-web-services - 如何在 AWS API Gateway 中禁用 "Require authorization"的 "Per-key cache invalidation",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76520741/