[英]AWS Lambda function can't communicate with EC2 Instance
On AWS, I created a new lambda function. 在AWS上,我创建了一个新的lambda函数。 I added a role to the lambda that has the policy, AWSLambdaVPCAccessExecutionRole.
我向具有策略的lambda添加了一个角色AWSLambdaVPCAccessExecutionRole。 I placed the lambda in the same VPC as my EC2 instance and made sure the security group assigned to the lambda and EC2 instance have the same default VPC security group created by AWS which allows all traffic within the vpc.
我将lambda与我的EC2实例放置在同一VPC中,并确保分配给lambda和EC2实例的安全组具有由AWS创建的相同的默认VPC安全组,该安全组允许vpc内的所有流量。 On my EC2 instance, I have a tomcat app running on port 8080. I tried to hit the URL by two methods in my lambda function:
在我的EC2实例上,我有一个运行在端口8080上的tomcat应用程序。我尝试通过lambda函数中的两种方法访问URL:
Both of these options do not work for the lambda function. 这两个选项均不适用于lambda函数。 I tried it on my local computer and it is fine.
我在本地计算机上尝试过,一切正常。
Any suggestions? 有什么建议么?
Security Group for Inbound 入站安全组
has the security group 8080 port open to internet? 安全组8080端口是否已向Internet开放?
To connect Lambdas with VPC you can't use the default VPC, you have to create one with a nat gateway. 要将Lambda与VPC连接,您不能使用默认VPC,而必须使用nat网关创建一个。
EDIT: Only if the Lambda fucntion needs to access to internet and VPC. 编辑:仅当Lambda功能需要访问Internet和VPC时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.