从AWS Lambda函数连接到Redshift时出错

时间:2019-03-31 19:28:30

标签: python-3.x amazon-web-services aws-lambda

在从EC2实例运行相同代码时未尝试使用psycopg2 lib从aws lambda python代码连接redshift的问题。低于错误响应。

{
  "errorMessage": "FATAL:  no pg_hba.conf entry for host \"::xxxxx\", user \"xxxx\", database \"xxxx\", SSL off\n",
  "errorType": "OperationalError",
  "stackTrace": [
    [
      "/var/task/aws_unload_to_s3_audit.py",
      86,
      "lambda_handler",
      "mainly()"
    ],
    [
      "/var/task/aws_unload_to_s3_audit.py",
      74,
      "mainly",
      "con = psycopg2.connect(conn_string)"
    ],
    [
      "/var/task/psycopg2/__init__.py",
      130,
      "connect",
      "conn = _connect(dsn, connection_factory=connection_factory, **kwasync)"
    ]
  ]
}

1 个答案:

答案 0 :(得分:0)

我的建议是检查Redshift的网络配置,可能是连接被拒绝。

要检查的地方-

  1. Redshift安全组
  2. VPC配置是lambda驻留在专用子网下。