I cannot get my Lambda functions to access my public RDS Postgresql database. I can connect locally and via tests. I was using a IAM User which had AdministratorAccess.
I need a clean way to configure this moving forward. How would I set this up in my .yml file:
Not working, but I noticed my RDS is available in ap-southeast-2b whilst my lambda functions are deployed to US East (N. Virginia) . Could this be an issue?
Your RDS database and Lambda function are required to be within the same VPC. The instruction on the AWS side on how to do so is here and how to specify VPC details in the Serverless framework is here.
Thanks again. I created a new IAM Role, which before I was adding the policies to the existing IAM User which was created for the serverless deployment:
If I create a database on aws. Should it then be possible for me to deploy a nodejs function (lambda) and with configuration in serverless.yml give it access to my database?
If I deploy my function and then go to my database and allow everyone to connect to it then it works. But is that nesseserry?
By reading here I have read I should configure this
The security group is from my mysql instance details page. And so are the subnets. Is that correct? It still doesnt work unless I allow access to my db from all ips.
Ok. Just learned a little more. The vpc securityGroup I add for my functions serverless.yml is the group which will be added to that function. And then what I need to do before that is to allow that group access to that vpc I use.
Is that the same way you guys do it? or is there a smarter way
RDS + Lambda is complicated. It feels like you need to chose between security or fast cold start times. If your Lambda is inside the VPC your database is secure but your Lamdba cold start time rises from 3s to 13s. Deploy Lambda outside the VPC and you need to open your database to the world.
Thx for replying . Can you tell me how I decide if my lambda runs on the vpc or “normal”. Is that by giving the lambdas security group access to the vpc resource?
Cool thx. The last days I have ben googling a bit about dynamodb it seems a few of the week points are transaction handling and backup of the database. Is that something you also experience as a problem?