Skip to content

Set file permissions of code directory when layer present #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

joe4dev
Copy link
Member

@joe4dev joe4dev commented Oct 24, 2023

Motivation

At AWS, the file permissions of the Lambda code directory /var/task depend on whether at least one layer is used.

  • no layer: file permissions are preserved
  • at least one layer: file permissions are set to 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:

  • with layer: tests.aws.services.lambda_.test_lambda.TestLambdaLayerBehavior.test_file_permissions_with_layer
  • without layer: tests.aws.services.lambda_.test_lambda.TestLambdaLayerBehavior.test_file_permissions_without_layer

@joe4dev joe4dev self-assigned this Oct 24, 2023
Copy link
Member

@dominikschubert dominikschubert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants