【发布时间】:2020-10-19 08:07:25
【问题描述】:
有人可以提供有关如何在 cloudformation 模板中使用 greedy path sub-resource ('{proxy+}') 指定缓存策略的建议。
我已经通过 CloudFormation 使用 apigateway 设置了一个 REST API。网关配置了一个通用的cache policy on the stage deployment。但是,对于特定的贪婪路径子资源,我想指定自定义缓存策略。当路径名是标准字符串(例如“/~1abcde~1fghijk”)时,我能够通过模板成功实现这一点,但对于下面的 sn-p 的“{proxy+}”则不行。
Stage:
Type: AWS::ApiGateway::Stage
Properties:
RestApiId: xxxx
StageName: xxxx
Description: 'Api stage for deployment'
DeploymentId: xxxx
TracingEnabled: True
CacheClusterEnabled: True
CacheClusterSize: 0.5
MethodSettings:
- ResourcePath: "/~1abcde~1fghijk"
HttpMethod: "*"
CacheTtlInSeconds: 0
CachingEnabled: false
- ResourcePath: "/~1abcde~1{proxy+}"
HttpMethod: "*"
CacheTtlInSeconds: 0
CachingEnabled: false
【问题讨论】:
-
你能澄清什么问题吗?模板不部署?有什么错误吗?
-
没有错误,模板部署正常。问题是策略没有生效,因为资源仍然从阶段继承而不是覆盖。
-
如果你这样做,但使用控制台,它是否按预期工作?因此,问题是如何在 CFN 中复制它?
-
正确。通过控制台覆盖时没有问题。
-
@Marcin 感谢您的帮助,已确定并解决了我的问题。
标签: amazon-web-services amazon-cloudformation aws-api-gateway api-gateway