-
Notifications
You must be signed in to change notification settings - Fork 824
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
Support for Mocking functions with layers and Docker #4826
Comments
I have the same problem... |
Same problem here... |
Same, amplify should support testing all the features with Docker, like Sam does at least |
Any updates on it ? |
same problem i am facing while running this command Unable to mock storageTrigger. Mocking a function with layers is not supported. To test in the cloud: run "amplify push" to deploy your function to the cloud and then run "amplify console function" to test your function in the Lambda console. |
I wonder what's the challenge with enabling mocks for functions with layers? From what I saw, we just need to setup the correct |
I've noticed this only seems to be a soft limitation of Amplify, since by temporarily removing the associated layer from the function's I've been working around this limitation using this method for a while now and haven't found any drawbacks of it as long as the dev env and build process are set up properly, so is there any chance this could be made toggleable with a switch on the mock command or a feature flag? |
Any progress on the topic? |
@mewtlu Thanks for sharing your solution. Could please share some code examples? with all the things you tweaked. Some more context of my case: I use the Appsync graphql layer (const API = require('@aws-amplify/api').default;) inside a lambda function. That lambda function is used to handle one route of the API Gateway. |
I'm not sure if there are any further issues related to the specifics of your situation, but to be able to mock any function that has a Lambda layer all that is required is manually editing your local I run the following bash script using jq whilst in in Hope this helps. |
@mewtlu how does your solution gets the related code stored in the lambda layer folders? |
If you're asking how we provide the code in the layer to the functions within the dev environment I simply use local npm dependencies, within my frontend application's package.json I have an npm dependency on the package within the monorepo which contains the code used for the Lambda Layer such as: As the Lambda layer contains TypeScript code/types we also use TS project references to support this which nicely links up in a similar manner using relative paths within the monorepo, then we simply have a deployment step that builds and copies the code from |
@mewtlu So you manually remove these local dependencies before you run amplify push/publish? |
Ah no, these changes are only ever made to the amplify-meta file which I believe should always be overwritten automatically before any deploys (with the built contents of the backend-config file). This change is only made to affect the |
Thanks a lot @mewtlu . I'll give it a shot. |
How do you handle the layer paths within the lambda function? Ex: /opt/folder/file.js ? Could you share your whole solution step by step? Man... not being able to test locally is doing my head. I not only have to deploy my whole application in order to test, i often get an error because of the number of layers it get created
|
Is your feature request related to a problem? Please describe.
When I try to test layers locally I've seen errors which shows that it's not implemented yet. It would be nice if we could install yumda packages using Docker.
Describe the solution you'd like
Use Docker to install yumda packages and test it locally, maybe with a flag
--docker
Describe alternatives you've considered
Test locally using common mocks
The text was updated successfully, but these errors were encountered: