Debugging Lambdas with a Layer (Or alternative) #5045
Labels
guidance
General information and guidance, answers to FAQs, or recommended best practices/resources.
lambda
language:python
Issues related to debugging Python lambdas using SAM Local
sam
System details
Question
How can I debug Lambdas which will have a lambda layer attached using AWS SAM without including all dependencies in the
requirements.txt
?We have a repo which contains a series of about 15 services and the code for their associated lambdas. Each lambda has an associated
requirements.txt
which is used by a build job to package the code and upload to S3.We have a few instances where we're using lambda layers to include dependencies which aren't available through pip or simply to reduce the size of the deployment package, however I'm struggling to create a launch configuration for these functions which includes all the necessary dependancies during testing.
I've tried using a preLaunchTask to temporarily add the layer dependencies to requirements.txt, and a postDebugTask to clean these up, however I couldn't get the postDebugTask to run (I think it must run in a different context as it can never be found despite being in my tasks.json).
I've also looked into using a custom template for the invokeTarget, however this approach seems to lack the full debugging functionality with VSCode (Breakpoints etc).
I think a separate
prod-requirements.txt
might work for the instances where we aim to minimise the package size, but wouldn't solve the issue of including binaries which aren't in pip such as git-lambda-layer.Does anyone have any guidance on how we might be able to approach this, whilst managing the configuration for about 30 lambdas in a single repository.
I'm happy to provide more context if needed.
Sample from
launch.json
:Sample of File Structure:
The text was updated successfully, but these errors were encountered: