问题描述
我正在尝试通过Lambda函数将记录插入RDS中的Postgres数据库中.我的Node.js lambda函数在本地运行时可以正常运行,但是在AWS中运行时数据库连接会超时.
I'm trying to insert records into a Postgres database in RDS from a Lambda function. My Node.js lambda function works correctly when run locally, but the database connection times out when run in AWS.
我已经阅读了几篇文章和教程,这些文章和教程表明AWS Lambda函数无法访问VPC内的RDS实例.例如: http://ashiina.github.io/2015/01/amazon-lambda-first-impression/
I've read several articles and tutorials which suggest that AWS Lambda functions cannot access RDS instances that are within a VPC. For example: http://ashiina.github.io/2015/01/amazon-lambda-first-impression/
不幸的是;看来我无法创建VPC外部存在的RDS实例. 在此下拉菜单中,我希望能够为无VPC"或类似选项选择一个选项.
Unfortunately; it seems I am unable to create an RDS instance that exists outside of a VPC. At this dropdown I would expect to be able to select an option for "No VPC" or something along those lines.
此选项是否已删除?也许我错过了一步?
Has this option been removed? Perhaps I have missed a step?
推荐答案
您可以创建可公开访问的RDS实例.然后,您应该能够从AWS内部或外部的任何地方访问它.我相信这可以解决您与Lambda有关的问题.通过网络控制台创建新的RDS实例时,系统会询问您是否需要公开访问这些实例.
You can create a publicly accessible RDS instance. Then you should be able to access it from anywhere, inside or outside AWS. I believe that would get around your issue with Lambda. You are asked if the instances needs to be publicly accessible when you create a new RDS instance via the web console.
或者您可以等待几周,因为应该在VPC中启用Lambda"今年晚些时候".
Or you could just wait a few weeks, as Lambda within a VPC is supposed to be enabled "later this year".
编辑:请注意,较新的Amazon帐户仅限于VPC资源.您无法再在VPC之外创建EC2或RDS实例.这就是为什么您不再看到无VPC"选项的原因.
Note that newer Amazon accounts are restricted to VPC only resources. You can't create EC2 or RDS instances outside of a VPC anymore. That's why you don't see the "No VPC" option anymore.
第二现在可以正常使用Lambda功能的VPC了.
Second VPC access for Lambda functions is now genearally available.
这篇关于是否可以在没有VPC的情况下启动RDS实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!