MY ECS task connects over RDS's DB endpoint. I even ran my container locally to the RDS PostgreSQL DB and it worked without a problem.
As you can see all the tables are properly created an populated nad Spring Boot App starts fine. enter image description here
Just about 3-4 minutes after all tables dissapear from Amazon RDS PostgreSQL DB. enter image description here ECS logs don't give any hint at all I only get sql error: 0, sqlstate: 42p01 Which only means that the tables are gone 😅
I also tried setting SPRING_JPA_HIBERNATE_DDL-AUTO=update so the App never deletes tables, nevertheless they seem to get deleted anyways. I've been trying to work around this for a whole day now, thanks in advance.
My guess is there is some sort of connection issue between ECS and RDS since my local container works fine with the RDS database.
By the way I have a load balancer connected to my ECS service. However I beleive that has nothing to do with it, but I turned on stickiness on the target group just in case, which also did nothing.
On further reading, it sounds like you have the hibernate DDL-AUTO set to create-drop
so when the old ECS task is stopped, after the new task has been flagged by ECS as healthy, it is deleting the records before it terminates. Even if you changed it from create-drop
to update
, you would have had to deploy twice to get rid of any old tasks configured with create-drop
to stop seeing the create-drop
behavior.
I would double verify that you have the configuration changed to update
and perform a few complete deployments to verify the issue goes away.
And I would still recommend switching to Flyway or Liquibase for your DDL management in the future.