'Mount EFS to Lambda Container
I have a task that I would like to run inside a container on AWS Lambda. I know, that when using the regular function, not a container, it is possible to mount a persistent EFS storage to /mnt/
.
Is it possible to access this location from the running container?
Solution 1:[1]
Yes, just mount it as you would for a non-container Lambda function.
If you want to access an EFS from a Lambda container, Lambda will mount the EFS at the specified local mount path. For example, if your file system mount path is /mnt/data
, this is where you will find it in your Lambda container. A simple Lambda container listing files at /mnt/data
would check that everything is working as intended.
One limitation is that since Lambda can only mount file systems in /mnt
that is where your EFS will always live. This is different for example than mounting EFS through an ECS Task which allows specifying the mount path inside the container.
As for a walkthrough, you just have to specify the EFS and its mount path in the File systems part of the function Configuration. This step requires a VPC and the associated IAM policies (e.g., AWSLambdaVPCAccessExecutionRole). Note that now that the Lambda function is attached to a VPC, it may have lost internet access, and you may need to work out some networking.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | hrvg |