如何使用amazon api网关创建自定义端点?

问题描述 投票:1回答:1

因此,我在EC2实例上托管的RESTFUL Flask API前面设置了一个AWS API网关,并使用了gunicorn,但它给了我一个非常难看的端点,有没有办法让它可以使用自定义URL?

我得到了这个网址https://123x123x.execute-api.eu-west-2.amazonaws.com/myendpoint/

我想要像https://myurl.net/myendpoint一样

amazon-web-services aws-api-gateway api-gateway
1个回答
1
投票

简短的回答是:

  1. 将Cloudfront权限分配给帐户中的IAM用户/角色:
{
    "Version": "2012-10-17",
    "Statement": [
         {
            "Sid": "AllowCloudFrontUpdateDistribution",
            "Effect": "Allow",
            "Action": [
                "cloudfront:updateDistribution"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}
  1. 定义映射到当前URL https://123x123x.execute-api.eu-west-2.amazonaws.com/myendpoint/的边缘优化API端点
  2. 通过AWS ACM注册证书(或者如果您有自己的CA,请创建一个并导入它)
  3. 在Route 53中为您想要的myurl.net域创建自定义DNS名称
  4. 将新的自定义DNS名称分配给边缘优化对象的A记录别名,例如a1b2c3d4e5f6.cloudfront.net

AWS的更长答案详述如下:https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html

注意:这也可以在很大程度上使用AWS API Gateway REST API进行管理:https://docs.aws.amazon.com/apigateway/api-reference/link-relation/domainname-create/

© www.soinside.com 2019 - 2024. All rights reserved.