Reputation: 4388
I have a simple .Net core 2.1 web application that I have deployed to AWS lambda. The application talks to a RDS PostGres database. The web application is able to connect to the RDS PostGres database from my local box but the same application times out connecting to RDS database in production.
What am I missing?
ASP.Net 2.1 Lambda configuration: The lambda has a execution role which has a policy with all rights to all RDS resources.
RDS=> Connecting and security tab:
CloudWatch logs: Clicking on the lambda function=> Monitoring tab=> view logs in cloudwatch logs shows the following error:
Upvotes: 0
Views: 5413
Reputation: 446
So it looks like your RDS's security group is only allowing inbound connections from 1 specific IP, 76.187.198.247.
This will ONLY work in the scenario that your lambda is in a subnet (which it is not) that is associated with an elastic IP, and that elastic IP is the inbound address for your RDS security group.
Lambdas are NOT tied to a specific piece of hardware, and the IP will change each time, so you'll block the inbound connection with the SG.
However, this elastic IP is an unnecessary cost in this instance, there is a better way to do it:
1) create a subnet that the lambda will be initialized in, 2) and then in the lambda settings select you want to launch into a VPC (the same one as the RDS instance) and 3) select those subnets (best practice is >2 in case there is an AZ outage) 4) change the RDS security group settings to allow inbound traffic from the subnet lambdas launch into
Upvotes: 3