Fargate Task with Nat Gateway fails to connect with RDS database

我的梦境 提交于 2021-02-11 14:34:54

问题


Basically, I'm follow these two guides:

  1. Deploying Hasura on AWS with Fargate, RDS and Terraform
  2. Deploying Containers on Amazon’s ECS using Fargate and Terraform: Part 2

I have:

  • Postgres RDS Database deployed in 'Multi-AZ'
  • My python/flask app deployed in Fargate across multiple AZ's
  • I run a migration inside the task definition before the app
  • ALB Load balancing between the tasks
  • Logging for RDS, ECS and ALB into Cloudwatch Logs.
  • A NAT gateway with an Elastic IP for each private subnet to get internet connectivity
  • A new route table for the private subnets
  • NO certificates
  • I use terraform 0.12 for the deploy.
  • The repository is on ECR

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

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

These are the logs on pastebin-logs

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!!!

UPDATE

I inject the database credentials in this way:

pastebin-terraform


回答1:


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

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.



来源:https://stackoverflow.com/questions/58757398/fargate-task-with-nat-gateway-fails-to-connect-with-rds-database

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