The issue is actually with using the public EC2 IP, isn't it?
When you use the public IP, the Lambda function exits your VPC. So, within a VPC, it's generally more effective and secure to use the private IP for communication.