I wrote a lambda function to access a database so the first step is to get secrets from AWS Secrets Manager. I have a private VPC as well as subnets, NAT Gateway, and security group associated with the lambda function. I also have secretsmanager.Secret.grantRead(lambda_exec_role)
so the lambda should have access to Secrets Manager.
For some reason when I test it in API Gateway, I got "errno": "ETIMEDOUT" and "code": "NetworkingError" in CloudWatch. And from the printed log I had in the API, getting secrets was failed.
I also tried to add a VPC endpoint for Secrets Manager as in here, but still got the same error.
Appreciated if anyone here could help me with this or give some hints.
Many thanks!