Search code examples
amazon-web-servicesaws-cloudformationamazon-ecsamazon-efs

CloudFormation structure for per ECS service EFS volumes


I'm following the https://github.com/awslabs/ecs-refarch-cloudformation template to create an ECS cluster and launch applications on it using CloudFormation.

I'm now trying to add an EFS volume mount for one of the ECS services I have. For this I have to declare the CF template for the EFS volume, reference it in the service CF template and (the bad part) add it to the init script of the ECS instances.

This produces a bit of a chicken and egg problem. The ECS CF template should not have to know about EFS volumes used by some random service that is running on the cluster, but it seems there is no way around that init script.

So the question is not a technical one - I can get this working - but an architectural. How to not pollute the ECS cluster CF template with service specific volume mounts?


Solution

  • The only way to achieve this at this moment on ECS is to mount the EFS volume inside your container.

    Mounting nfs shares inside docker container