I've created a lambda function. I created a Elastic File System (EFS) and access points using all the default settings. I attached the EFS to the lambda function, again just using the defaults.
But! There is no write access to EFS.
What did I miss?
Hope some kind person knows :)
Notes....
The current answer doesn't seem to work. I've also been onto AWS support for over a week. They seem to think the EFS is not mounting.
EFS is mounted to lambda at = /mnt/fs
EFS Access point - Root Directory Path = / (A suggestion of changing this to /fs causes an internal server error, AWS support suggested /mnt/fs which also causes an internal service error).
AmazonElasticFileSystemClientFullAccess and AWSLambdaVPCAccessExecutionRole added to execution role.
Test Node js example:
exports.handler = function(event, ctx, callback) {
const fs = require("fs");
fs.mkdir('/mnt/fs/newfolder', { recursive: true }, (err) => {
callback(null, {
statusCode: 200,
"content-type": "text/html",
body: (err || "ok").toString()
})
});
};
The aws documentation misses the part about posix user settings, but a blog post explains it.
To add EFS to lambda.
AmazonElasticFileSystemClientFullAccess and AWSLambdaVPCAccessExecutionRole permissions need to be added to the execution role.
EFS is mounted to lambda at = /mnt/fs EFS Access point path = /mnt/fs
Add a posix user to the acccess point. User 1000, group 1000 & permissions 0777.
As explained in this blog post:
https://aws.amazon.com/blogs/compute/using-amazon-efs-for-aws-lambda-in-your-serverless-applications/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With