Allow AWS Lambda to access RDS Database

后端 未结 3 1971
我寻月下人不归
我寻月下人不归 2020-12-02 18:27

I am trying to connect to RDS Database from an AWS Lambda (Java).

Which IP should I enable from the RDS Security group rules?

相关标签:
3条回答
  • 2020-12-02 19:06

    You can't enable this via IP. First you will need to enable VPC access for the Lambda function, during which you will assign it a Security Group. Then, within the Security Group assigned to the RDS instance you will enable access for the Security Group assigned to the Lambda function.

    0 讨论(0)
  • 2020-12-02 19:12

    You can configure Lambda to access your RDS instance.

    You can enable this using Lambda management console. Select Lambda function which need access to RDS instance and then go to Configuration -> Advanced settings and select the VPC (which is your RDS instance is in) you need it to access.

    find out more here http://docs.aws.amazon.com/lambda/latest/dg/vpc.html

    0 讨论(0)
  • 2020-12-02 19:27

    Here is what I did

    I assigned same Subnets and VPCs to both services Lambda and RDS. Now I created a NAT Gateway choosing one of the subnet so that Lambda can use that NAT Gateway to interact with the outside world.

    Last thing is to add inbound entry in the security group that is attached to RDS as well as Lambda functions. Whitelist DB port 5432 in my case for postgresql and add security group name in the source.

    Security group is somehow whitelisting itself by adding an entry in inbound rules.

    This worked for me pretty well.

    0 讨论(0)
提交回复
热议问题