2021年4月22日星期四

AWS ECS Task can't connect to RDS Database

I'm a newer AWS user and today I got stuck while working on a sample project. I successfully created a docker container that runs a simple R script that connects to my AWS RDS MySQL Database and creates & writes some basic files to it. I built a public ECR repository, pushed my docker image there, and built a ECS cluster & task choosing Fargate and using the container image from my repository. My task ran and I could see the R code being executed when I went through the logs, but it was never able to connect to the SQL Database and exited afterwards.

I've had to whitelist my own IP address in the security group for the RDS Database so that I can connect to it, so I'm aware I probably have to do that for my ECS task to establish that connection too. But won't that IP address constantly change because I won't have a static IP for the Fargate Server that is executing my task? I'm trying to stay on the free tier so I'm not sure I want to setup an elastic IP address for this server.

These 2 articles seem close if not the same issue I'm having but I can't figure out a solution. I haven't found any other info.

https://aws.amazon.com/premiumsupport/knowledge-center/ecs-fargate-task-database-connection/

https://aws.amazon.com/premiumsupport/knowledge-center/ecs-fargate-static-elastic-ip-address/

The end goal is to get this sample project successfully running on a scheduled fixed interval, and then running actual scripts on there to help automate things and make my life easier, so this sample project is a first step towards that. Any help or info on the questions I'm having would be appreciated !

https://stackoverflow.com/questions/67223885/aws-ecs-task-cant-connect-to-rds-database April 23, 2021 at 12:08PM

没有评论:

发表评论