简体   繁体   English

如何将AWS API Gateway定制域创建到已经在CloudFront分发中已使用且具有任何停机时间的域?

[英]How can I create an AWS API Gateway custom domain to a domain which is already used in a CloudFront distibution with any downtime?

I'm trying to switch my site, which is currently CloudFront and Elastic Beanstalk, to API Gateway. 我正在尝试将我的站点(当前为CloudFront和Elastic Beanstalk)切换到API网关。

When I try to create the Custom Domain in API Gateway I get a message that there is already a CloudFront distribution for that domain, which is true. 当我尝试在API网关中创建自定义域时,我收到一条消息,即该域已经存在CloudFront发行版,这是事实。 But if I remove that distribution my site will be down until the new distribution (for the API Gateway) will be up. 但是,如果我删除该发行版,则我的网站将关闭,直到新发行版(用于API网关)启动为止。

Is there anyway I can swap these or something ? 无论如何,我可以交换这些东西吗?

I do have control over the DNS records. 我确实可以控制DNS记录。

You can register your API-Gateway as cloudfront origin and then assign a separate behavior for you API calls. 您可以将API网关注册为Cloudfront来源,然后为API调用分配单独的行为。

If you need a step-by-step guide, you can use the following link: 如果您需要逐步指南,则可以使用以下链接:

Processing A Contact Form Using AWS Cloudfront, API Gateway, Lambda and SES 使用AWS Cloudfront,API Gateway,Lambda和SES处理联系表单

For a cloudformation setup you can use this description: 对于cloudformation设置,您可以使用以下描述:

hosting a Cloudfront site with S3 and API Gateway 使用S3和API网关托管Cloudfront网站

The solution that worked in the end : 最后起作用的解决方案:

  1. Change the DNS to point directly at Elastic Beanstalk 更改DNS以直接指向Elastic Beanstalk
  2. Disable & Delete the original CloudFront distribution 禁用并删除原始CloudFront发行版
  3. Create a 'Custom Domain' in APIG (this also creates a CloudFront dist.) 在APIG中创建“自定义域”(这还会创建一个CloudFront分区。)
  4. Change the DNS to point at the new CloudFront dist. 将DNS更改为指向新的CloudFront dist。 (you get the URL in the APIG console under Custom Domains) (您可以在APIG控制台的“自定义域”下获得该网址)

Each of these steps takes a little time ... but there is no downtime. 这些步骤中的每一个都需要一点时间...但是没有停机时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM