I have an AWS Lambda inside a private subnet in a VPC. I’m using FastAPI and Mangum for an API. The code is uploaded using a Docker container (250MB) to ECR.
I was able to run a Test Event with POST command successfully to one of my endpoints. The endpoint successfully makes a connection to an RDS database in the private subnet. In fact, it runs very quickly. I have the Memory set to 3008MB and the timeout to 15 minutes.
HOWEVER, without changing the code, suddenly the Lambda starts getting a timeout error. Then it won’t work anymore until I re-upload the code.
I can see in CloudWatch that the Request starts and then has a timeout. I have a logger logging as the first line inside my request function–but it never even gets to that. Therefore, I know it’s not even making it to the DB call.
It’s almost like a Cold Start issue, but it never starts up again.