[英]Multiple API Gateways from different regions with the same Custom Name and different base path
I have 10 different APIs across two AWS regions (us-east-1, ca-central-1).我在两个 AWS 区域(us-east-1、ca-central-1)有 10 个不同的 API。 Using base path mapping, us-east-1.example.com is serving 5 APIs in US and ca-central-1.example.com is serving the other 5 APIs (API Gateway).
使用基本路径映射,us-east-1.example.com 为美国的 5 个 API 提供服务,ca-central-1.example.com 为其他 5 个 API(API 网关)提供服务。 Although the backend is running the same code, it was part of the requirement from clients.
尽管后端运行相同的代码,但这是客户要求的一部分。 Our clients are public universities and they want to have their own servers in their own country.
我们的客户是公立大学,他们希望在自己的国家拥有自己的服务器。 For example, the current setup is using Custom Name & base path from API Gateway.
例如,当前设置使用来自 API 网关的自定义名称和基本路径。
American universities:美国大学:
us-east-1.example.com/harvard
us-east-1.example.com/stanford
us-east-1.example.com/mit
Canadian universities:加拿大大学:
ca-central-1.example.com/ubc
ca-central-1.example.com/bcit
ca-central-1.example.com/waterloo
Is there a way to combine them into a single custom domain using Route 53 like the following?有没有办法像下面这样使用 Route 53 将它们组合成一个自定义域?
api.example.com/harvard
api.example.com/ubc
I just talked to an AWS Professional and was told this is not a possible architecture.我刚刚与 AWS 专业人士交谈,被告知这不是一种可能的架构。
You can definitely use CloudFront for this and you can use Route53 to make it available under your custom domain.您绝对可以为此使用 CloudFront,并且可以使用 Route53 使其在您的自定义域下可用。 Add each university as an origin and add a cache behavior for each of them with the path pattern of the university's name and the target the corresponding origin.
添加每所大学作为原点,并使用大学名称的路径模式为每个大学添加缓存行为,并以相应的原点为目标。
You'll have origins:你会有起源:
and cache behaviors:和缓存行为:
When a request comes in, CloudFront checks the path pattern and routes the response to the correct API Gateway endpoint.当收到请求时,CloudFront 检查路径模式并将响应路由到正确的 API 网关端点。 The downside is that you need to modify the CloudFront distribution when there is a new university you want to route to.
不利之处在于,当您想要路由到一所新大学时,您需要修改 CloudFront 分配。 I've written some articles about how routing in CloudFront works.
我写了一些关于 CloudFront 中的路由如何工作的文章。
To host it under your own domain name, you need to use ACM to request a certificate for that domain, then add an Alternate Domain Name to the CloudFront distribution, and finally add an A (and AAAA) record to the Route53 hosted zone pointing to the distribution.要在您自己的域名下托管它,您需要使用 ACM 为该域申请证书,然后将备用域名添加到 CloudFront 分配,最后将 A(和 AAAA)记录添加到 Route53 托管区域指向分布。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.