amazon-web-services - AWS API Gateway 在私有 VPC 中调用 api
问题描述
我在私有子网和 privateSG 的 ec2 上部署了一项服务。我可以从公共子网和 publicSG 中的 EC2 访问此服务。我想创建一个 API 网关,将这个 api 公开给我的客户[移动应用程序]。
实现这一目标的方法是什么?
我已经创建了 API 网关、资源和方法,但是这个 api 调用没有到达 ec2 上的服务。下面是错误
Wed Feb 17 10:14:38 UTC 2021 : Starting execution for request: c7290ccc-5859-44cf-bta2-90ff498cdec6
Wed Feb 17 10:14:38 UTC 2021 : HTTP Method: GET, Resource Path: /item/item-1
Wed Feb 17 10:14:38 UTC 2021 : Method request path: {id=item-1}
Wed Feb 17 10:14:38 UTC 2021 : Method request query string: {}
Wed Feb 17 10:14:38 UTC 2021 : Method request headers: {}
Wed Feb 17 10:14:38 UTC 2021 : Method request body before transformations:
Wed Feb 17 10:14:38 UTC 2021 : Execution failed due to configuration error: Invalid endpoint address
Wed Feb 17 10:14:38 UTC 2021 : Method completed with status: 500```
解决方案
要启用您的 API Gateway 访问您的私有实例,您可以设置API Gateway 私有集成:
API Gateway 私有集成使您可以轻松地在 Amazon VPC 中公开您的 HTTP/HTTPS 资源,以供 VPC 外部的客户端访问。
另一种方法是使用与您的 VPC 集成的 lambda 函数作为代理。因此,您的 API 会调用该函数,而该函数又会在私有实例上调用您的 API 并将答案返回给 API。
推荐阅读
- mysql - 替换 SQL 表中的值
- finite-automata - 设计一个 FA 来接受 L,其中 L = 'a' 总是出现三倍的字符串
- c# - 使用 observable 按字母顺序排序数据
- java - NPE 很难从 logcat 中发现它似乎是 Arraylist 但应该设置每个项目
- docker - Docker 拒绝挂载 NFS 共享
- sql - Laravel Eloquent:选择一个字段等于另一个字段的记录
- google-apps-script - 继续接收 抱歉,无法删除所有未冻结的行
- angular - angular: 封装一个 Stepper 组件
- python - Python:为什么 for 循环在 join() 函数的中间?
- java - Spring WebClient - 如何处理错误场景