Can't access to RDS from Amazon Lambda, same VPC and correct role permissions

孤人 提交于 2019-12-22 08:32:49

问题


i can't successfully connect to RDS from Amazon Lambda in production. For Amazon Lambda i'm using Serverless framework, executing sls offline i can connect with RDS from localhost, but in production Amazon Lambda doesn't.

Both are in same VPC, in same security group, that has all traffic inbound access, and a rule that is pointing to Vpc's CIDR.

I have these permissions attached: AmazonRDSFullAccess, AWSLambdaFullAccess, AmazonVPCFullAccess, AWSLambdaExecute and AWSLambdaVPCAccessExecutionRole.

Thank's for help.


回答1:


I had this issue and the following is a summary of the steps I took to resolve:

  1. In lambda network section select the VPC and all subnets. Set the security group to the security group the RDS was created with / set to.
  2. Edit said security group inbound policies and set a policy with RDS port/access settings and set the source equal to its own Group Id. It is not sufficient that they are in the same group, if it doesn't accept connections from it's own group.
  3. Ensure the lambda function execution role has AWSLambdaVPCAccessExecutionRole and AWSLambdaBasicExecutionRole policies attached.

Good luck.




回答2:


Try to change "IAM DB Authentication Enabled" to YES on your database and apply changes immediately so you don't wait for maintenance.

That solved my problem.



来源:https://stackoverflow.com/questions/45991897/cant-access-to-rds-from-amazon-lambda-same-vpc-and-correct-role-permissions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!