Lambda - not connected to VPC - has no internet access

0

Hello,

I have created a lambda-function, but it seems to have no internet access. So, I created a new function, just doing a ping. socket.create_connection((host_to_ping, 80), timeout=timeout) response = { 'statusCode': 200, 'body': f'Ping successful {host_to_ping}' }

This always runs into an exception (timeout). I have assigned the AWSLambdaBasicExecutionRole to this lambda.

I had yesterday played around a lot with my VPCs, Subnets, ... and maybe I messed up. But this Lambda is NOT connected to a VPC - so I understand it should have internet access by default?

What could be wrong?

Greetings, Hendrik

Hendrik
asked 4 months ago164 views
2 Answers
0
Accepted Answer

Hello.

Looking at the explanation below, I thought that it was not possible to send ICMP packets from Lambda.
Therefore, I think it is probably not possible to ping from Lambda.
https://aws.amazon.com/lambda/faqs/?nc1=h_ls

Q: What restrictions apply to AWS Lambda function code? Lambda attempts to impose as few restrictions as possible on normal language and operating system activities, but there are a few activities that are disabled: Inbound network connections are blocked by AWS Lambda, and for outbound connections, only TCP/IP and UDP/IP sockets are supported, and ptrace (debugging) system calls are blocked. TCP port 25 traffic is also blocked as an anti-spam measure.

profile picture
EXPERT
answered 4 months ago
profile pictureAWS
EXPERT
reviewed 4 months ago
  • Agree with Riku: ping is ICMP and ICMP is not usable in Lambdas

0

Thanks a lot, that explains it!

Hendrik
answered 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions