0

Can anyone tell me how/why my Lambda function cannot 'see' a website served by Apache on an EC2 instance when they are both in the same VPC?

My setup:

Amazon Linux v2 Lambda function in the default VPC, same as the one the EC2 instance is on Lambda function using 'default' aka all permissions role to access EC2 instance Apache installed and working correctly on an elastic IP address serving an API and website publically

I know that if I choose to use a Lambda function in the VPC that the internet access is removed, so I can no longer access the website using mydomain.com and that's fine. Long term I will move to a VPC with public and private subnets and configure an internet gateway that the Lambda function can use, but for now I just wonder why I can't use the EC2 hosted website without the internet gateway. Surely the Lambda function should be able to connect to the EC2 website?

I have tried using both the private and public IP address of the EC2 instance and both timeout when trying to connect to Apache.

Any help gratefully received!

Thanks.

P.S. I'm new to AWS so please be kind :)

0
  1. Does the Lambda Security Group permit outbound access? Try opening all outbound to 0.0.0.0/0 for start.

  2. Does the EC2 Security Group permit inbound access from Lambda's SG?

0

Sorry found the issue - though I don't completely understand it. Not to do with AWS - I had https still on the API URL. Changed this to http and it worked fine. Obviously if I'm in the VPC then I don't need the https anyway.

Thanks for your answer @MLu - yes, I had checked both those and they were ok.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.