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

Debug serverless application with layer defined in the same template.yaml #1263

Closed
efremsternbach opened this issue Aug 22, 2020 · 5 comments
Labels
feature-request New feature or enhancement. May require GitHub community feedback. pending-release sam

Comments

@efremsternbach
Copy link

I have a serverless application that is a collection of cooperating Lambdas. These Lambdas have common code which is stable and that I'd like to put in a layer that exists only for this application (things like database table definitions). That way if I do need to change the code it will flow through to all the other Lambdas without requiring a lot of manual edits. I've created a layer within the template.yaml file with the name AppUtilitiesLayer and have assigned it to the Lambdas as - !Ref AppUtilitiesLayer

When I use SAM to build and deploy this to AWS it works correctly. However when I try to debug the Lambda in Visual Studio Code I get a message that says "Error with child process: Error: AppUtilitiesLayer is an Invalid Layer Arn."

I don't care about stepping through code in the Layer since this is stable code and shouldn't need to be debugged very often. If I build the layer independently in a separate template.yaml file the debugger doesn't have a problem. However the common code is specific to this particular serverless application and it makes sense to keep it as part of the application instead of requiring a separate build.

I am asking for functionality to debug a Lambda that has a layer defined in the same template.yaml file. Don't care about stepping through code in the Layer though that would be awesome. Right now this is impossible. It would be a huge help in keeping the code organized. Keeping common code synchronized across different Lambdas in the same application has been difficult at times.

Hope this isn't too hard. Thanks

@efremsternbach efremsternbach added the feature-request New feature or enhancement. May require GitHub community feedback. label Aug 22, 2020
@justinmk3
Copy link
Contributor

Related: #746 . Consider adding an upvote 👍 to that issue.

@justinmk3 justinmk3 added the sam label Aug 22, 2020
@plsalvado
Copy link

plsalvado commented Sep 3, 2020

Same problem here, my workaround at the moment is to reference the canonical Arn in the portal.

Screenshot 2020-09-03 at 09 23 54

Layers: - !Ref [long_arn]

Although that throws a CloudFormation error when the changes get pushed onto the pipeline. The workaround above will only unblock you from testing locally. Before pushing the changes to Git you'll have to revert to the layer logical ID, a bit of a hassle.

@evanerwee
Copy link

Same problem here

@justinmk3
Copy link
Contributor

Can you confirm if the 1.18 release helps/fixes this?

@efremsternbach
Copy link
Author

I have successfully been able to debug a lambda referencing a local Layer defined in the same yaml file. So the 1.18 release satisfies my personal needs. It allows me to maintain a set of code in a locally managed Layer shared by my serverless application lambdas without explicitly and separately publishing a global Layer.

Thanks for getting this done!

justinmk3 pushed a commit that referenced this issue Nov 28, 2023
weaverbird: remove reject and discuss button
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or enhancement. May require GitHub community feedback. pending-release sam
Projects
None yet
Development

No branches or pull requests

4 participants