serverless-application-model icon indicating copy to clipboard operation
serverless-application-model copied to clipboard

EFS permission denied

Open MatteoInfi opened this issue 6 years ago • 3 comments

I am unable to use EFS with lambda and I am getting permission denied following this example: https://aws.amazon.com/blogs/compute/using-amazon-efs-for-aws-lambda-in-your-serverless-applications/

func function() (events.APIGatewayProxyResponse, error) {
	if err := os.Mkdir(fmt.Sprintf("/mnt/efs/%v", "123"), os.ModePerm); err != nil {
		return events.APIGatewayProxyResponse{}, err
	}

	return events.APIGatewayProxyResponse{
		StatusCode:        200,
		Body:              "OK",
	}, nil
}

I get this error

mkdir /mnt/efs/123: permission denied: PathError null

MatteoInfi avatar Jun 22 '20 13:06 MatteoInfi

This example is very misleading: https://aws.amazon.com/blogs/compute/using-amazon-efs-for-aws-lambda-in-your-serverless-applications/

If you write like this:

 AccessPointResource:
   Type: 'AWS::EFS::AccessPoint'
   Properties:
     FileSystemId: !Ref FileSystemResource
     PosixUser:
       Uid: "1000"
       Gid: "1000"
     RootDirectory:
       CreationInfo:
         OwnerGid: "1000"
         OwnerUid: "1000"
         Permissions: "0777"
       Path: "/lambda" // <========== this one

Than this have to be:


  MyLambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
	...
      FileSystemConfigs:
      - Arn: arn:aws:elasticfilesystem:us-east-1:xxxxxx:accesspoint/
fsap-123abcdef12abcdef
        LocalMountPath: /mnt/lambda // <============ here

and not :

        LocalMountPath: /mnt/efs // <====================== wrong

I will leave this open, the docs should be changed.

MatteoInfi avatar Jun 23 '20 10:06 MatteoInfi

@MatteoInfi Thanks for letting us know. I reached out to the owner of the blog for him to address this. Closing as we don't own that content.

jfuss avatar Jun 24 '20 02:06 jfuss

Hi, In EFS access point my path is /opt/test/packs. I lambda function i can't able to give the full path(/mnt/opt/test/packs). I am getting some error says that we need to give the absolute path. any thoughts? cc @MatteoInfi

itsmano1993 avatar Mar 25 '21 05:03 itsmano1993