How to set the origin path on an Custom origin using CloudFormation?

不羁岁月 提交于 2019-12-08 07:12:35

问题


I have tried this

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

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

But I am getting the below error

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

回答1:


I have found the answer we just need to add OriginPath attribute. Here it is

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


来源:https://stackoverflow.com/questions/48946936/how-to-set-the-origin-path-on-an-custom-origin-using-cloudformation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!