简体   繁体   English

如何将 Google Cloud API 限制为 AWS Lambda Endpoint?

[英]How to restrict Google Cloud API to AWS Lambda Endpoint?

We're setting up an API Key for using Google Maps API from an endpoint at AWS Lambda function.我们正在设置一个API 密钥,以便从AWS Lambda函数的端点使用Google Maps API And we are thinking about restrict it for the services used from AWS backend.我们正在考虑限制为从AWS后端使用的服务。

By IP or HTTP ?通过IPHTTP Since AWS uses load balancers and stuff, we're considering a proxy or something like that.由于 AWS 使用负载均衡器和其他东西,我们正在考虑使用代理或类似的东西。 Any ideas?有任何想法吗? Thanks!谢谢! :D :D

you can register your API gateway URL to the google console.您可以将您的 API 网关 URL 注册到谷歌控制台。

the url is something like this: https://.execute-api.ap-southeast-1.amazonaws.com/网址是这样的:https://.execute-api.ap-southeast-1.amazonaws.com/

that way you can restrict usage of your google cloud API key, only for your web这样你就可以限制你的谷歌云 API 密钥的使用,仅适用于你的网络

I'm not sure what you mean when you ask "by IP or HTTP?"当您询问“通过 IP 还是 HTTP?”时,我不确定您的意思。 The Google Maps API supports IP whitelisting so that you can limit the IP addresses that can use your API key to send requests. Google Maps API 支持 IP 白名单,以便您可以限制可以使用您的 API 密钥发送请求的 IP 地址。

The problem that you'll run into when trying to whitelist the IP address associated with your Lambda function is that you can't predict the IP.尝试将与您的 Lambda 函数关联的 IP 地址列入白名单时会遇到的问题是您无法预测 IP。 It'll be somewhere in the IP space of AWS Lambda.它将位于 AWS Lambda 的 IP 空间中的某个位置。

One option to consider is to setup a VPC with a NAT gateway, assign an Elastic IP to the NAT gateway, and route traffic from private subnets through the NAT device.要考虑的一种选择是设置带有 NAT 网关的 VPC,为 NAT 网关分配弹性 IP,并通过 NAT 设备路由来自私有子网的流量。 Then you can configure the Lambda function to run inside a private subnet of the VPC .然后,您可以将 Lambda 函数配置为在 VPC 的私有子网内运行。 All outbound traffic from the Lambda function to the internet (and Google Maps) will route via the NAT gatewayand hence come from a static IP (the Elastic IP you assigned to the NAT).从 Lambda 函数到互联网(和 Google 地图)的所有出站流量都将通过 NAT 网关路由,因此来自静态 IP(您分配给 NAT 的弹性 IP)。 Configure that in your Google Maps IP whitelisting.在您的 Google 地图 IP 白名单中进行配置。

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

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