Data Persistence Using AWS ECS

Hey all,

First off, I want to say that the n8n team clearly emphasizes how easy this can be. That being said, AWS really likes to make things over-complicated. I’m currently hosting n8n on an EC2 Docker container in ECS but I can’t get the data to persist after restarting the container. I’ve tried a lot of different combinations in the “Volumes” section and in the container config in my task definition and I do get his encouraging output in the CloudFront logs:

Alas, when I restart the container, I have no data persistence. When I log into the CentOS server that this is running inside, I can see that Docker has the container running and that the volume I made is mounted.

What’s confusing is that even though the previous log message says that the /home/node/.n8n/config file was created, the /home/node directory is empty even after I did a “mkdir /home/node/.n8n”

My guess is that this is a stupid AWS problem as it usually is but I also may be totally missing something.

Any help would be greatly appreciated!

Hey @ExactaIT!

Welcome to the community :sparkling_heart:

Thank you for your love!

Reading the documentation here: Best Practices - Persistent storage - Amazon Elastic Container Service, it seems like ECS doesn’t natively support data persistence. You will have to connect to a database. Maybe this helps: Amazon ECS - Persistent data between instances - Stack Overflow

As @harshil1712 wrote can you either use an external database like Posgres and make sure you set the encryption key via an environment variable or you can mount external storage from EFS or EBS.

Thanks, guys. I figure EFS is probably an easier and cheaper solution since i’m looking for a tiny bit of storage for data that doesn’t change much.

Any thoughts on what these parameters should be?

To close this out, I did figure it out. I didn’t end up using EFS, I just needed to change the following in my task definition:

  1. make a “bind mount” volume with a path of /home/node/.n8n
  2. edit the container definition, mount the volume I just made and set the “container path” as /home/node/.n8n

2 Likes

Thank you for sharing the solution!