gpt4 book ai didi

templates - 为 APIGateway 方法设置缓存

转载 作者:行者123 更新时间:2023-12-03 07:29:57 27 4
gpt4 key购买 nike

我有以下 CF 模板

{
"Conditions":{
"CreatedProdStage" : {...}
}
...
"Resources":{
"GetMethod": {
...
},
"ApiDeployement":{
...
},
"ProdStage":{
"Type":"AWS::ApiGateway::Stage",
"Condition":"CreatedProdStage",
"Properties": {
"DeploymentId":"...",
"RestApiId":"...",
"MethodSettings":[{
"CachingEnabled":true,
"HttpMethod":{"Ref":"GetMethod"},
"ResourcePath":"/"
}]
}
}
}
}

我收到错误

Invalid method setting path: /~1/st-GetMetho-xxxAUMMRWxxx/caching/enabled. Must be one of: [/deploymentId, /description, /cacheClusterEnabled/cacheClusterSize/clientCertificateId/{resourcePath}/{httpMethod}/metrics/enabled, /{resourcePath}/{httpMethod}/logging/dataTrace, /{resourcePath}/{httpMethod}/logging/loglevel, /{resourcePath}/{httpMethod}/throttling/burstLimit/{resourcePath}/{httpMethod}/throttling/rateLimit/{resourcePath}/{httpMethod}/caching/ttlInSeconds, /{resourcePath}/{httpMethod}/caching/enabled, /{resourcePath}/{httpMethod}/caching/dataEncrypted, /{resourcePath}/{httpMethod}/caching/requireAuthorizationForCacheControl, /{resourcePath}/{httpMethod}/caching/unauthorizedCacheControlHeaderStrategy, ///metrics/enabled, ///logging/dataTrace, ///logging/loglevel, ///throttling/burstLimit ///throttling/rateLimit ///caching/ttlInSeconds, ///caching/enabled, ///caching/dataEncrypted, ///caching/requireAuthorizationForCacheControl, ///caching/unauthorizedCacheControlHeaderStrategy, /va

我错过了什么吗?我认为 ResourcePathHttpMethod 是唯一必需的属性

最佳答案

您首先需要使用 CacheClusterEnabled 属性在舞台上启用缓存。这将允许您为方法设置缓存,就像您在 MethodSettings 中所做的那样:

...
"ProdStage":{
"Type":"AWS::ApiGateway::Stage",
"Condition":"CreatedProdStage",
"Properties": {
"DeploymentId":"...",
"RestApiId":"...",
"CacheClusterEnabled": true
"MethodSettings":[{
"CachingEnabled":true,
"HttpMethod":{"Ref":"GetMethod"},
"ResourcePath":"/"
}]
}
}

然后您将需要修复给定的错误。您的 ResourcePath 与错误输出中列出的其中之一相匹配。这些没有在文档中列出,因此您需要使用的内容有点令人困惑。您当前所拥有的只是为根路径设置的。如果您想要所有路径,请使用 "/*"

APIGateWay::MethodSettings(请参阅资源路径)文档: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-stage-methodsetting.html

关于templates - 为 APIGateway 方法设置缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42477892/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com