Search code examples
javascriptnode.jsaws-lambdafsamazon-efs

EACCES: Permission denied on AWS Lambda


I have added my file path as /mnt/efs but still I'm getting Permission Denied error.

Here is the CloudWatchlog:

2022-01-04T20:16:03.992Z    f4c79867-d245-4800-9a7d-a07ee8e52f14    INFO    🚀 ~ file: db.js ~ line 81 ~ setCredentials ~ error [Error: EACCES: permission denied, open '/mnt/efs/.db.json.tmp'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/mnt/efs/.db.json.tmp'
}

Solution

  • Did you add the EFS permissions in the IAM Role attached with your Lambda? Check this link for EFS permissions you can add in your IAM Role https://docs.aws.amazon.com/efs/latest/ug/iam-access-control-nfs-efs.html

    As for how to attach IAM Role to Lambda check https://aws.amazon.com/blogs/security/how-to-create-an-aws-iam-policy-to-grant-aws-lambda-access-to-an-amazon-dynamodb-table/

    and

    https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html