如何使用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/2014/12/16/amazon-cloudfront-now-allow-alow-alow-directory-directory-path-as-origin-name/.

但是我得到以下错误

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

我找到了答案,我们只需要添加OriginPath属性即可。在这里是

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

最新更新