EACCES:AWS Lambda 上的权限被拒绝

EACCES: Permission denied on AWS Lambda

我已将我的文件路径添加为 /mnt/efs,但我仍然收到权限被拒绝的错误。

这是 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'
}

您是否在 Lambda 附带的 IAM 角色中添加了 EFS 权限? 检查此 link 以获得您可以在 IAM 角色中添加的 EFS 权限 https://docs.aws.amazon.com/efs/latest/ug/iam-access-control-nfs-efs.html

关于如何将IAM Role附加到Lambda检查 https://aws.amazon.com/blogs/security/how-to-create-an-aws-iam-policy-to-grant-aws-lambda-access-to-an-amazon-dynamodb-table/

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