niketp
niketp

Reputation: 459

Will EFS maintain files after instance is terminated?

I am using cloudformation heavily currently, and I have a three stacks I am currently dealing with. The first stack is my load balancer stack, which essentially just has an application load balancer as its resource. The second stack only has a single resource: an elastic file system. The third stack is my main stack where I have an autoscaling group behind the load balancer mentioned in the first stack. This autoscaling group also mounts the EFS from the second stack onto each new instance. If my autoscaling group were to kill an unhealthy instance, and then initialize a new one to take its place, will it keep all of the files that were initially in the old EFS?

Basically, I am just wondering if files in an EFS in a particular instance will remain if that same file system is mounted in a different instance.

Upvotes: 0

Views: 2918

Answers (2)

Rodrigo Murillo
Rodrigo Murillo

Reputation: 13642

Basically, I am just wondering if files in an EFS in a particular instance will remain if that same file system is mounted in a different instance.

Yes. Files persist in an EFS filesystem until a) you delete them via a file operation from an instance that has mounted the EFS target, or b) the EFS resource itself is deleted from the console or CLI. They are independent of any instance.

This persistence is what make EFS useful as a sharable network attached file store. It is designed for your exact use case.

Please be aware you should consider backing up EFS fileshare to another EFS file share, or synced backup to S3, as a safety precaution. This backup is not built into the service, but can be added via scheduled tasks, Lambdas etc. In our system, I launch a scheduled instance once a day, and sync the production EFS with a backup EFS. for security and redundancy.

Upvotes: 4

Prathamesh Jagtap
Prathamesh Jagtap

Reputation: 403

Until you use the same EFS on new machine that was used in destroyed machine, you will not loose your files.

Based on my experience and description provided on EFS webpage, EFS files are not lost until EFS is terminated. As It is also used for containers, which are easily throw away environment, it would also suit for your ELB based architecture as well.

"Amazon EFS is ideal for container storage providing persistent shared access to a common file repository" https://aws.amazon.com/efs/

Upvotes: 0

Related Questions