限制对特定 vpc 的 lambda 或 api 网关的访问
Limit access to lambda or api gateway to a specific vpc
是否可以使 api 网关 或 lambda 函数只能由特定 vpc 访问。
我在 amazon doc 中搜索过,但我没有找到任何关于这个主题的信息。
提前致谢
很遗憾,您将无法执行此操作(请参阅下面的更新)。
s3 是通过 存储桶策略 .
提供这种控制访问的服务
您可以向调用者授予权限 (Lambda 调用者和 API 调用者).
看看这些资源:
- Control Access to an API with IAM Permissions
- Control Access for Invoking an API
- Overview of Managing Access Permissions to Your AWS Lambda Resources
更新: 来自 Michael - sqlbot
的重要评论
You might point out that the underlying reason why this isn't possible is that both the Lambda service API and API Gateway are accessed from the Internet, which means the VPC identity of the caller is lost -- however, the VPC can be identified indirectly by the EIPs of its NAT Gateways, which should be usable against the aws:sourceIp IAM policy condition key, indirectly restricting access to any machine behind those EIPs, thus only in the VPC. Maybe it's a hack, maybe it's a workaround.
2018 年 11 月 8 日更新
Introducing Amazon API Gateway Private Endpoints
当今应用程序开发的最大趋势之一是使用 APIs 来支持支持产品的后端技术。越来越多的移动、IoT、Web 应用程序或内部服务相互通信以及与应用程序前端通信的方式正在使用一些 API 接口。
除了这种构建 API 驱动的应用程序的趋势之外,还有向微服务应用程序设计模式的转变。较大的应用程序由许多较小的应用程序组件表示,通常也通过 API 进行通信。 API 和微服务一起使用的增长推动了各种公司,从初创公司到企业。以最小的运营开销大规模、安全地管理 API 所需的工具数量也在增长。
今天,我们很高兴地宣布推出 Amazon API 网关专用端点。这是该服务最受要求的功能之一。我们相信这将使创建和管理私人 API 变得更加容易。
Private endpoints
Today’s launch solves one of the missing pieces of the puzzle, which is the ability to have private API endpoints inside your own VPC. With this new feature, you can still use API Gateway features, while securely exposing REST APIs only to the other services and resources inside your VPC, or those connected via Direct Connect to your own data centers.
这是它的工作原理。
API 网关私有端点通过 AWS PrivateLink 接口 VPC 端点成为可能。接口端点通过在您在 VPC 内定义的子网中创建弹性网络接口来工作。然后,这些网络接口提供对其他 VPC 中的服务 运行 或 API 网关等 AWS 服务的访问。配置接口端点时,您指定哪些服务流量应通过它们。当使用私有 DNS 时,到该服务的所有流量都被定向到接口端点,而不是通过默认路由,例如通过 NAT 网关或 public IP 地址。
API 网关作为一项完全托管的服务在其自己的 VPC 中运行其基础设施。当您与 API 网关 public 仅可访问的端点交互时,它是通过 public 网络完成的。当它们配置为专用时,public 网络无法用于路由您的 API。相反,您的 API 只能使用您配置的接口端点进行访问。
是否可以使 api 网关 或 lambda 函数只能由特定 vpc 访问。
我在 amazon doc 中搜索过,但我没有找到任何关于这个主题的信息。
提前致谢
很遗憾,您将无法执行此操作(请参阅下面的更新)。
s3 是通过 存储桶策略 .
提供这种控制访问的服务您可以向调用者授予权限 (Lambda 调用者和 API 调用者).
看看这些资源:
- Control Access to an API with IAM Permissions
- Control Access for Invoking an API
- Overview of Managing Access Permissions to Your AWS Lambda Resources
更新: 来自 Michael - sqlbot
的重要评论You might point out that the underlying reason why this isn't possible is that both the Lambda service API and API Gateway are accessed from the Internet, which means the VPC identity of the caller is lost -- however, the VPC can be identified indirectly by the EIPs of its NAT Gateways, which should be usable against the aws:sourceIp IAM policy condition key, indirectly restricting access to any machine behind those EIPs, thus only in the VPC. Maybe it's a hack, maybe it's a workaround.
2018 年 11 月 8 日更新
Introducing Amazon API Gateway Private Endpoints
当今应用程序开发的最大趋势之一是使用 APIs 来支持支持产品的后端技术。越来越多的移动、IoT、Web 应用程序或内部服务相互通信以及与应用程序前端通信的方式正在使用一些 API 接口。
除了这种构建 API 驱动的应用程序的趋势之外,还有向微服务应用程序设计模式的转变。较大的应用程序由许多较小的应用程序组件表示,通常也通过 API 进行通信。 API 和微服务一起使用的增长推动了各种公司,从初创公司到企业。以最小的运营开销大规模、安全地管理 API 所需的工具数量也在增长。
今天,我们很高兴地宣布推出 Amazon API 网关专用端点。这是该服务最受要求的功能之一。我们相信这将使创建和管理私人 API 变得更加容易。
Private endpoints
Today’s launch solves one of the missing pieces of the puzzle, which is the ability to have private API endpoints inside your own VPC. With this new feature, you can still use API Gateway features, while securely exposing REST APIs only to the other services and resources inside your VPC, or those connected via Direct Connect to your own data centers.
这是它的工作原理。
API 网关私有端点通过 AWS PrivateLink 接口 VPC 端点成为可能。接口端点通过在您在 VPC 内定义的子网中创建弹性网络接口来工作。然后,这些网络接口提供对其他 VPC 中的服务 运行 或 API 网关等 AWS 服务的访问。配置接口端点时,您指定哪些服务流量应通过它们。当使用私有 DNS 时,到该服务的所有流量都被定向到接口端点,而不是通过默认路由,例如通过 NAT 网关或 public IP 地址。
API 网关作为一项完全托管的服务在其自己的 VPC 中运行其基础设施。当您与 API 网关 public 仅可访问的端点交互时,它是通过 public 网络完成的。当它们配置为专用时,public 网络无法用于路由您的 API。相反,您的 API 只能使用您配置的接口端点进行访问。