Skip to content
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

How to run lambda with external dependencies locally while excluding the dependencies from being packaged and pushed to AWS? #4855

Open
kayvanmoj opened this issue Sep 2, 2024 · 1 comment
Labels
guidance General information and guidance, answers to FAQs, or recommended best practices/resources.

Comments

@kayvanmoj
Copy link

Your Environment

  • OS: macOS 14.2.1 (23C71)
  • JetBrains product: 2023.3.2 (Ultimate Edition)
  • JetBrains product version: Build #IU-233.13135.103, built on December 20, 2023
  • AWS Toolkit version: 3.26-233
  • SAM CLI version: 1.122.0
  • Python version: 3.12

Question

Hi,

In order to run a lambda function that has external dependencies locally, requirements.txt has to be provided to specify the dependencies.

The issue here is that sam build will package the dependencies with the lambda code that is pushed to AWS. However the dependencies already exist as layers in the AWS environment.

Is there a way to avoid this? Or any other workaround?

I know doing a sam deploy without a sam build will exclude the dependencies from the package. However one problem with that approach is that the run executor runs sam build before running the function so, before deployment, .aws-sam dir has to be deleted.

Is there a way to specify a different build dir for the run executor build?

Thanks.

@kayvanmoj kayvanmoj added the guidance General information and guidance, answers to FAQs, or recommended best practices/resources. label Sep 2, 2024
@kayvanmoj
Copy link
Author

My current hack:

deploy.sh

rm -rf .aws-sam
sam deploy --profile $1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance General information and guidance, answers to FAQs, or recommended best practices/resources.
Projects
None yet
Development

No branches or pull requests

1 participant