使用 CloudFormation 在缓存行为中设置 "允许的 HTTP 方法"。

问题描述 投票:0回答:2

是否有任何方法可以使用 CloudFormation 将 "允许的 HTTP 方法 "设置为 "GET、HEAD、PUT、POST、PATCH、DELETE、OPTIONS"?我的堆栈中描述了一个缓存行为,但默认情况下它只接受GET和HEAD,但我需要它接受POST方法。我如何使用CloudFormation做到这一点?

amazon-web-services amazon-cloudfront amazon-cloudformation
2个回答
0
投票

由于这个属性在 缓存行为类型我相信它无法通过CloudFormation进行设置。您可以使用 API 和 自定义资源但这可能很复杂。见 这些例子 对于这种方法如何进行。


0
投票

是可以这样做的。

CacheBehavior:
  TargetOriginId: ***-***-***
  ViewerProtocolPolicy: redirect-to-https
  MinTTL: 0
  AllowedMethods: [DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT]
  CachedMethods: [HEAD, GET]
  Compress: true
  ForwardedValues:
    Headers: ['*']
    QueryString: true
    Cookies:
      Forward: all
© www.soinside.com 2019 - 2024. All rights reserved.