Mount Amazon Elastic File System (EFS) in AWS Lambda Functions

For Lambda functions that run in a VPC, it’s possible to mount EFS onto them. This lets you share the EFS among concurrent executions of the Lambda function & even with EC2 & on-prem instances.

To mount an EFS in a Lambda function, open the function in the web console & scroll down to the File System section:

Assuming you have the EFS ready & that the Lambda is in the same VPC as the EFS, click Add File System:

All subsequent invocations of the Lambda function can now access the EFS at /mnt/efs. For demonstration, I’ve added an EFS to a Bash Lambda created here. The df command then shows the EFS at /mnt/efs. with 8 exabytes of free space!

function handler () {
    DATA=`df -h | grep /mnt/efs`
    RESPONSE="{\"statusCode\": 200, \"body\": \"$DATA\"}"
    echo $RESPONSE
  "statusCode": 200,
  "body": " 8.0E 0 8.0E 0% /mnt/efs"