我可以根据每个请求更改我的AWS Lambda的公共IP吗? [英] Can I change my AWS Lambda's public IP on every request?

查看:252
本文介绍了我可以根据每个请求更改我的AWS Lambda的公共IP吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我提出请求时,我都希望获得一个新的公共IP.是否可以故意触发我的IP重新配置?

I would love to get a new public IP every time I make a request. Is it possible to purposefully trigger my IP to be reprovisioned?

推荐答案

默认情况下,根据您的配置,从VPC中一个或多个子网中的私有IP调用Lambda函数.它没有配置公共IP#;它们被分配了专用IP.

By default, a Lambda function is invoked from a private IP within one or more subnets in your VPC, according to your configuration. It is not configured with a public IP #; they are assigned private IPs.

如果要求为Lambda函数分配公共IP编号,则需要

If the requirement is to have the Lambda function assigned a public IP number, you would need to configure a NAT Gateway or NAT instance to provide internet access, and therefore a public IP. The Lambda traffic would then be attributed to the public IP address of the NAT gateway/instance.

为弹性IP地址分配了给定的 NAT网关,但无法重新分配-它是静态的.因此,NAT网关无法满足您的目的.

An elastic IP address is assigned with a given NAT Gateway but it can't be reassigned - it is static. So a NAT Gateway would not work for your purpose.

您将必须使用 NAT实例.然后,Lambda函数将需要在每个请求结束时终止/启动NAT实例.这将导致EC2为您的NAT实例分配一个新的公共IP-假设从其启动的子网被配置为在启动时自动分配IP#.

You would have to use a NAT instance. The Lambda function would then need to terminate/launch the NAT instance at the end of each request. This would cause EC2 to assign a new public IP for your NAT instance - assuming the subnet it launches from is configured to auto-assign IP#s on launch.

鉴于此,您必须在每个请求之后重新启动NAT实例,以便为其分配新的IP#. 此过程允许每次将每个请求分配给新的公共IP#.

Given that, you would have to restart the NAT instance after each request, in order for it to be assigned a new IP#. This process would allow for each request to be attributed to a new public IP# each time.

请注意,在NAT实例启动/终止阶段,您的Lambda函数将无法访问互联网.您可以考虑使用简单队列服务对Lambda函数进行排队,以防止争用NAT实例.

Please note that during the NAT instance launch/termination phase, your Lambda function would not have access to the internet. You could consider queueing the Lambda function using Simple Queuing Service to prevent contention to the NAT instance.

扩展也将成为一个问题,因为所有功能都要求NAT实例可用于每次调用.如果需要考虑正常运行时间和可用性,则将需要在NAT服务级别实施HA解决方案

Scaling would also become an issue, as the functions would all require the NAT instance to be available for each invocation. If uptime and availability were a concern, you would need to implement a HA solution at the NAT service level.

这篇关于我可以根据每个请求更改我的AWS Lambda的公共IP吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆