0
votes

I have deployed an application which exposes a REST API on EC2 instance.

This REST API needs to be accessible only from the lambda function.

I have created a VPC using launch VPC wizard and the VPC with a Single Public Subnet option.

I have created two subnets and a security group.

In the security group, I have configured the http port on which the REST service is running, to be accessible from the same security group. This security group is also assigned to Lambda function.

I have assigned the VPC, subnets and the security group to the lambda function.

I am following the below link -

Access EC2 Instance Service Via AWS Lambda Function

The lambda function is not able to connect to the REST API endpoint on the EC2 instance.

Any pointers?

1

1 Answers

0
votes

Your associated VPC must have a NAT Gateway (or a NAT Instance) in a public subnet. This looks to be missing in your case (based on the data that you have shared in the question).

I would implore you to go through this official tutorial. It clearly demonstrates what you need to access public endpoints from a Lambda function that is placed inside a manually created VPC.