amazon-web-services - 如何在 AWS API Gateway 中禁用 "Require authorization"的 "Per-key cache invalidation"

标签 amazon-web-services aws-cloudformation aws-api-gateway api-gateway

使用 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/

相关文章:

python - 如何从 AWS Lambda Python 函数中检索 URL 查询字符串参数?

php - 在本地数据库中存储 Amazon API 数据

ruby - 使用 Ruby 2.3.3 的最佳 Amazon linux AMI

java - 错误 : A JNI error has occurred, 请检查您的安装并在 Eclipse EE 的 Maven 项目中重试

amazon-web-services - 如何根据 CloudFormation 上的条件更改属性?

amazon-web-services - 如何为 AWS API Gateway 设置缓存 key ?

amazon-web-services - 如何使用 Cloudformation 安全地将代码从 aws s3 存储桶提取到 Codecommit 存储库?

amazon-web-services - 获取导入的 Kinesis 流的 ARN

aws-cloudformation - AWS cloudformation:Fn:Base64::无法处理特殊字符

visual-studio - 立即部署多个 aws netcore lambda 函数