I was searching for a while for some good design ideas, but haven't found yet the best option. Basically I'm developing serverless API for existing database (RDS MySQL inside VPC, private security group). So I want to query the database from multiple Lambda functions. I know about the following ways how to achieve this:
Any ideas or advices?
Thank you!
In answer to the question in your title, no, it is not possible.
From your description, you want to invoke lambdas that can access resources inside and outside of your VPC. Your first two options pretty much describe your only options here.
In regards to your option 1. You can place the lambdas inside the VPC and have a NAT to get back out to the internet. I assume this is what you meant by 'configuration will be much more difficult'. But at least nothing from outside your VPC could initiate connection to something inside the VPC. I don't believe adding a NAT Gateway (see https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html) is 'much more difficult', but I guess that is subjective.
In regards to your option 2. You can have a non-VPC Lambda, invoke a Lambda inside a VPC directly (the reverse will not work). So there is no real need for an additional component in the form of an API Gateway (private or otherwise). Lambdas inside VPCs will scale automatically, but limited by the number of available IPs in the sub-net you specify. So some capacity planning would be required.
NB - each option would require at least one lambda in a VPC. Cold starts of these lambdas will incur a slight delay for the ENI (elastic network interface) to be set-up.