问题
Basically, I'm follow these two guides:
- Deploying Hasura on AWS with Fargate, RDS and Terraform
- 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