如何在 cloudformation yaml 中配置路由规则?

How do I configure the routing rules in a cloudformation yaml?

我正在尝试使用使用 cloudformation 的无服务器 yaml 为我的静态 s3 存储桶网站配置此网站路由规则。

<RoutingRules>
  <RoutingRule>
    <Condition>
      <KeyPrefixEquals/>
      <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
    </Condition>
    <Redirect>
      <Protocol>https</Protocol>
      <HostName>foo.amazonaws.com</HostName>
      <ReplaceKeyPrefixWith>prod/photos/resize?key=</ReplaceKeyPrefixWith>
      <HttpRedirectCode>307</HttpRedirectCode>
    </Redirect>
  </RoutingRule>
</RoutingRules>

如何将其翻译成下面的 yaml?

resources:
  Resources:
    UploadBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${file(./serverless.env.yml):${opt:stage}.BucketName}
        AccessControl: PublicRead
        WebsiteConfiguration:
          IndexDocument: index.html
          RoutingRule: //What's the format that goes here?
w=15=shw=12=sh.w=13=sh w=15=WILL.y.w=13=w w=10=sh

如果有人感兴趣,这里是相同设置的 JSON 表示

"WebsiteConfiguration" : {
 "IndexDocument": "index.html",
 "ErrorDocument": "error.html",
 "RoutingRules": [{
   "RedirectRule": {
      "HostName": {
        "foo.amazonaws.com"
      },
      "HttpRedirectCode": "307",
      "ReplaceKeyPrefixWith": "prod/photos/resize?key="
    },
    "RoutingRuleCondition": {
      "HttpErrorCodeReturnedEquals": "404"
    }
  }]
}