localstack / localstack

💻 A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline
https://localstack.cloud
Other
55.72k stars 3.97k forks source link

enhancement request: EFS support within Lambda #10915

Open markCalgary opened 4 months ago

markCalgary commented 4 months ago

Is there an existing issue for this?

Feature description

Trying to add EFS to a Lambda but I do not see the mounts being added to the Lambda Docker container. I believe the Lambda Docker container is not getting the properties to add the mount (mount_volumes’:[] ) in the first place.

When trying to add the file-system-configs to the Lambda update config the command runs without issue but the data returned does not include the file-system-configs data. I know that EFS support is not complete within LocalStack but I am just curious if this is incomplete development, there is in fact a bug? Any recommendations around this would be appreciated?

Thanks in advance.

Mark

Image: localstack/localstack-pro:latest (3.4.1-dev)

Cmd: awslocal lambda update-function-configuration --function-name myFunction-fb12c3c --file-system-configs ‘[{“Arn”:“arn:aws:elasticfilesystem:ca-central-1:000000000000:access-point/fsap-3ef9cb7c”,“LocalMountPath”:“/mnt/efs”}]’

Result: { "FunctionName": "myFunction-fb12c3c", "FunctionArn": "arn:aws:lambda:ca-central-1:000000000000:function:myFunction-fb12c3c", "Runtime": "python3.10", "Role": "arn:aws:iam::000000000000:role/lambdaRole-d7562e0", "Handler": "lambda_function.lambda_handler", "CodeSize": 531, "Description": "", "Timeout": 3, "MemorySize": 128, "LastModified": "2024-05-27T17:58:50.082977+0000", "CodeSha256": "q4YhDWusQ6vsQZxaqdUaLdH+gjl7p/fZ+MWwEGXA6gg=", "Version": "$LATEST", "VpcConfig": { "SubnetIds": [ "subnet-98fbef39" ], "SecurityGroupIds": [ "sg-fcc064e0452ac4a46" ], "VpcId": "vpc-0c8cf350" }, "TracingConfig": { "Mode": "PassThrough" }, "RevisionId": "43b968c7-1691-49f4-81e6-7efa675f0104", "State": "Active", "LastUpdateStatus": "InProgress", "LastUpdateStatusReason": "The function is being created.", "LastUpdateStatusReasonCode": "Creating", "PackageType": "Zip", "Architectures": [ "x86_64" ], "EphemeralStorage": { "Size": 512 }, "SnapStart": { "ApplyOn": "None", "OptimizationStatus": "Off" }, "RuntimeVersionConfig": { "RuntimeVersionArn": "arn:aws:lambda:ca-central-1::runtime:8eeff65f6809a3ce81507fe733fe09b835899b99481ba22fd75b5a7338290ec1" }, "LoggingConfig": { "LogFormat": "Text", "LogGroup": "/aws/lambda/myFunction-fb12c3c" } }

🧑‍💻 Implementation

No response

Anything else?

No response

localstack-bot commented 4 months ago

Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our contributing guide.

markCalgary commented 4 months ago

I figured a work around for us. We are planning to use EFS as a central file location for our different ECS and Lambda hosts but as EFS isn't supported yet within LocalStack, we are going to store our files on the local host and share them using the LAMBDA_DOCKER_FLAGS=-v host_folder_name:/mnt/efs . This means that files saved on the host will be shared with all our different docker images. The /mnt/efs will be the same whether running locally (volume share) or on the cloud using EFS, our code won't be able to tell any difference. Hopefully this helps people out there who are waiting on EFS support.

joe4dev commented 4 months ago

Hi @markCalgary 👋

I know that EFS support is not complete within LocalStack but I am just curious if this is incomplete development, there is in fact a bug?

This is a limitation of our current EFS implementation, which primarily supports API-level mocking rather than full emulation of the mounting behavior. Thanks for creating this feature request that can get upvoted 👍

Any recommendations around this would be appreciated?

Thank you for sharing the mounting workaround using LAMBDA_DOCKER_FLAGS=-v host_folder_name:/mnt/efs

ilya-adnymics commented 4 months ago

@markCalgary - thanks for the workaround! We have a pretty similar setup with EFS being the centralized storage for ECS and lambdas. Did you encounter issues with permissions when accessing the mounted volume from within e.g. lambda containers? I had to add couple more docker flags to make it work, but was just curious if there's a better way to do it. My current flags (as example with user id 1000):

LAMBDA_DOCKER_FLAGS=-v host_folder_name:/mnt/efs -v /etc/passwd:/etc/passwd:ro -u 1000:1000

I.e. I need to explicitly set the user to the one owning the host_folder_name and then mount /etc/passwd to have this same user within lambda container.

markCalgary commented 4 months ago

@ilya-adnymics happy to see my workaround worked for you. I didn't have the same permissions issue that you experienced I'm guessing because I'm on a Windows host. Next week these changes will be run on a Mac host so I'm assuming your solution will come into play for him. Thanks for the additional info.