AWS Lambda无法访问同一VPC内的EC2端口 [英] AWS Lambda unable to access EC2 port within the same VPC

查看:224
本文介绍了AWS Lambda无法访问同一VPC内的EC2端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个lambda函数来访问在同一VPC中的EC2实例上运行的Elasticsearch.不幸的是,即使我将其公开访问,lambda也无法访问该端口.

lambda和EC2均分配给同一VPC. lambda还分配给一个安全组,分配给EC2的SG明确向该安全组提供入站权限. Lambda函数还通过以下托管策略分配给角色:

  • AWSLambdaExecute
  • AWSLambdaVPCAccessExecutionRole
  • CloudWatchLogsFullAccess

Lambda是否缺少某些权限?

谢谢!

解决方案

分配给Lambda函数的IAM角色与此问题无关.

听起来您已正确设置了VPC和安全组.您如何从Lambda函数引用EC2服务器?您已经通过分配给EC2实例的专用IP地址来引用它,以使网络流量保持在VPC内,并且为了使安全组规则配置为正确应用./p>

I have a lambda function accessing Elasticsearch running on an EC2 instance in the same VPC. Unfortunately, the lambda fails to access the port even when I make it publicly accessible.

Both lambda and EC2 are assigned to the same VPC. The lambda is also assigned to a security group to which the SG assigned to EC2 explicitly gives inbound permissions. Lambda function is also assigned to a role with the following managed policies:

  • AWSLambdaExecute
  • AWSLambdaVPCAccessExecutionRole
  • CloudWatchLogsFullAccess

Is Lambda missing some permissions?

Thanks!

解决方案

The IAM Roles assigned to the Lambda function would have no bearing on this issue.

It sounds like you have setup the VPC and Security Groups correctly. How are you referencing the EC2 server from the Lambda function? You have to reference it via the private IP address assigned to the EC2 instance in order for the network traffic to stay within the VPC, and in order for the Security Group rule you have configured to apply correctly.

这篇关于AWS Lambda无法访问同一VPC内的EC2端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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