如何使用CloudFormation在自定义源上设置原始路径?

时间:2018-02-23 11:34:20

标签: amazon-web-services amazon-cloudformation

我试过这个

{
   "DomainName": "myapi.execute-api.us-east-1.amazonaws.com/dev,
   "Id": "APIEndPoint",
   "CustomOriginConfig": {
   "OriginProtocolPolicy": "https-only",
   "OriginSSLProtocols":["TLSv1", "TLSv1.1", "TLSv1.2"]
}

参考:https://aws.amazon.com/about-aws/whats-new/2014/12/16/amazon-cloudfront-now-allows-directory-path-as-origin-name/

但我收到以下错误

The parameter origin name must be a domain name.
(Service: AmazonCloudFront; 
Status Code: 400; 
Error Code: InvalidArgument; Request ID:

1 个答案:

答案 0 :(得分:4)

我找到了我们只需要添加OriginPath属性的答案。这是

{
  "DomainName": {
    "Ref": "APIGatewayEndpoint"
  },
  "Id": "APIEndPoint",
  "CustomOriginConfig": {
    "OriginProtocolPolicy": "https-only",
    "OriginSSLProtocols": [
      "TLSv1",
      "TLSv1.1",
      "TLSv1.2"
    ]
  },
  "OriginPath": {
    "Fn::Join": [
      "",
      [
        "/",
        {
          "Ref": "APIStage"
        }
      ]
    ]
  }
}