AWS Lambda 可以读取但不能写入 RDS

AWS Lambda Can Read But Not Write To RDS

我目前正在编写一个将写入 RDS 数据库的 AWS Lambda。我能够从数据库中读取,但在尝试写入数据库时​​连接超时。我想知道是否是因为我正在尝试从 aws lambda 中将 geopandas DF 写入 Postgres 数据库:

eng = create_engine('postgresql://' + 'postgres_db' + \
                                ':' + 'password' + \
                                '@' + 'host_loc' + \
                                ':' + 'port' + \
                                '/' + 'db_name')
                             .
                             .
                             .
                             .

df1.to_postgis('table1', con=eng, if_exists='replace', index=False)
df2.to_postgis('table2', con=eng, if_exists='replace', index=False)

但是脚本一直失败:

Response:
{
  "errorMessage": "Task timed out after 3.00 seconds"
}

geopandas 的 to_postgis 功能是否可能导致此问题,我该如何纠正?我知道我能够从数据库中读取,因为我已经从 lambda 环境中成功地测试过了。该脚本仅在尝试使用 to_postgis 将 geopandas 数据帧写入我的 postgres 实例中的 postgis 时失败。

AWS Lambda 函数的默认超时为 3 秒。超时旨在停止“运行离开”任务,因为大多数 Lambda 功能仅 运行 几分之一秒。

您最多可以增加 15 分钟。打开功能后在页面上可以找到配置。

可能是数据库写操作耗时过长,导致Lambda函数超时。给它更多时间可能会解决问题。