Set file permissions of code directory when layer present #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
At AWS, the file permissions of the Lambda code directory
/var/task
depend on whether at least one layer is used.755
This fixes sample applications on LocalStack using the aws-lambda-web-adapter. For example: https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examples/expressjs-zip
Changes
Conditionally change the file permissions of
/var/task
if we detect that layers are present (heuristic that/opt
is not empty).Testing
The branch
fix-lambda-file-permissions-with-layer
in localstack-ext provides AWS-validated tests for the two scenarios:tests.aws.services.lambda_.test_lambda.TestLambdaLayerBehavior.test_file_permissions_with_layer
tests.aws.services.lambda_.test_lambda.TestLambdaLayerBehavior.test_file_permissions_without_layer