带有Nat Gateway的Fargate Task无法与RDS数据库连接 [英] Fargate Task with Nat Gateway fails to connect with RDS database

查看:93
本文介绍了带有Nat Gateway的Fargate Task无法与RDS数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我遵循以下两个指南:

Basically, I'm follow these two guides:

  1. 将Hasura部署在带有Fargate,RDS和Terraform的AWS
  2. 使用Fargate和Terraform在Amazon ECS上部署容器:第2部分

我有:

  • 在多可用区"中部署的Postgres RDS数据库
  • 我的python/flask应用跨多个可用区部署在Fargate中
  • 我在应用之前在任务定义内运行迁移
  • ALB任务之间的负载平衡
  • 将RDS,ECS和ALB登录到Cloudwatch日志中.
  • 具有用于每个专用子网的弹性IP的NAT网关,以实现Internet连接
  • 专用子网的新路由表
  • 没有证书
  • 我将terraform 0.12用于部署.
  • 存储库位于ECR上

但是...我的应用无法连接到RDS数据库:

But... My app can't connect to the RDS database:

sqlalchemy.exc.OperationalError
(psycopg2.OperationalError): FATAL:  password authentication failed for user "postgres"

这些是 pastebin日志

我已经尝试过将密码更改为一种非常简单的密码,然后再直接在控制台上部署,打开端口,将访问设置为公共,将私有更改为公共子网等,等等.

I've already tried changing the password to a very simple one, before deploy, on the console directly, opening ports, turning access public, changing private to public subnet, etcetera, etcetera...

请,我有一个星期出现此错误!!!

Please, I have a week with this error!!!

更新

我以这种方式注入数据库凭据:

I inject the database credentials in this way:

pastebin地形

推荐答案

我无法发表评论,但是我的意思是作为评论.

I cannot comment, but I mean this as a comment.

运行该任务的ECS服务上的安全组出口是什么样的?您需要确保它通常可以在端口5432上与RDS通讯.

What does the security group egress look like on your ECS service that runs the task? You need to make sure it can talk to the RDS, usually on port 5432.

这篇关于带有Nat Gateway的Fargate Task无法与RDS数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆