什么时候应该在 AWS Lambda 函数中配置或不配置 VPC
When should I configure or not configure VPC in AWS Lambda functions
我在 VPC 中有一个 EC2。我在没有配置 VPC 的情况下创建了一个 lambda 函数(因此 lambda 控制台显示没有 VPC)。但它仍然可以启动,停止 EC2。 (在 lambda 服务角色中,我授予启动、停止 ec2 的权限),
问题一:为什么lambda不在ec2的VPC中也能访问ec2?
但是,相同的 lambda 函数无法使用 http://website_of_ec2.com 访问安装在 EC2 中的 Web 服务器。除非我用 VPC、子网和安全组(与 EC2 相同的 VPC)配置 lambda
问题 2:为什么在这种情况下 lambda 需要配置 VPC?
I have an EC2 in a VPC. I created a lambda function without
configuring VPC (so lambda console shows No VPC). but it still can
start, stop the EC2. (in the lambda service role, I grant permission
to start, stop ec2), question 1: Why the lambda can access ec2 even if
it is not in the VPC of the ec2?
在这种情况下,Lambda 没有访问 ec2 实例,它正在访问 AWS 的 ec2 服务。此服务是一个 public API,您可以从 CLI 或(我猜您的 Lambda 正在做)调用一个合适的 SDK。这相当于AWS Console,你可以start/stop/terminate ec2 instances,但是你不能通过Console实际登录到ec2机器。
however, the same lambda function cannot access the web server
installed in the EC2 using http://website_of_ec2.com. unless I
configure the lambda with VPC, subnet and security group (the same VPC
as EC2) question 2: why in this case the lambda need to have VPC
configured?
在这种情况下,没有 public 端点供您的 Lambda 连接到 ec2 实例。 Lambda 需要访问您的 ec2 实例所在的 VPC,因此需要额外的配置。
我在 VPC 中有一个 EC2。我在没有配置 VPC 的情况下创建了一个 lambda 函数(因此 lambda 控制台显示没有 VPC)。但它仍然可以启动,停止 EC2。 (在 lambda 服务角色中,我授予启动、停止 ec2 的权限), 问题一:为什么lambda不在ec2的VPC中也能访问ec2?
但是,相同的 lambda 函数无法使用 http://website_of_ec2.com 访问安装在 EC2 中的 Web 服务器。除非我用 VPC、子网和安全组(与 EC2 相同的 VPC)配置 lambda 问题 2:为什么在这种情况下 lambda 需要配置 VPC?
I have an EC2 in a VPC. I created a lambda function without configuring VPC (so lambda console shows No VPC). but it still can start, stop the EC2. (in the lambda service role, I grant permission to start, stop ec2), question 1: Why the lambda can access ec2 even if it is not in the VPC of the ec2?
在这种情况下,Lambda 没有访问 ec2 实例,它正在访问 AWS 的 ec2 服务。此服务是一个 public API,您可以从 CLI 或(我猜您的 Lambda 正在做)调用一个合适的 SDK。这相当于AWS Console,你可以start/stop/terminate ec2 instances,但是你不能通过Console实际登录到ec2机器。
however, the same lambda function cannot access the web server installed in the EC2 using http://website_of_ec2.com. unless I configure the lambda with VPC, subnet and security group (the same VPC as EC2) question 2: why in this case the lambda need to have VPC configured?
在这种情况下,没有 public 端点供您的 Lambda 连接到 ec2 实例。 Lambda 需要访问您的 ec2 实例所在的 VPC,因此需要额外的配置。