Comments (8)
I answered in the pull request @ryansonshine and it was totally it! Thank you very much!
from aws-sam-webpack-plugin.
Hi @jgomes94 ,
Can you create a sample repo with all of the code? There could be a number of causes for this behavior.
A few things to consider/try:
- Disable optimization on your webpack config, this can sometimes cause issues with npm packages written specifically for node.
module.exports = {
// ... your webpack config
optimization: {
minimize: false,
},
}
- Make sure your
data-api-client
is included independencies
and notdevDependencies
- Try running your logic on my boilerplate here: https://github.com/ryansonshine/sam-typescript-vscode-starter
from aws-sam-webpack-plugin.
Hi @ryansonshine , thank you for looking at this,
I've did as you suggested, I turned the optimization off and, yes, the data api client is in the dependencies. Unfortunately without success :(.
The code i'm using is this:
https://github.com/jgomes94/sam-node
for you to use it:
docker-compose up -d
npm i
npm run local-start
this will create you a single lambda that you can find in the localhost:3000/cards if you do a GET there you'll see the error.
The strange thing is, however, if you just navigate to /lambdas/create-card and do "node app" you'll see the code works and it prints the right information. (just make sure the file calls the function or it will not print anything you can do it by adding this.lambdaHandler() at the end of the file).
Again, thanks ryan much appreciated
from aws-sam-webpack-plugin.
Hey @jgomes94 ,
Thanks for providing the sample. It appears you might have a misconfiguration in your template.yaml
Change
CodeUri: lambdas/create-card/
to
CodeUri: lambdas/create-card
without the trailing slash and let me know if that resolves your issue
from aws-sam-webpack-plugin.
Also, that path is defined as a post
rather than a get
in the template.yaml
, which would likely be the result of getting a 404 for doing a GET
on that path.
from aws-sam-webpack-plugin.
Thanks for the feedback @ryansonshine,
I've changed the codeUri, but unfortunately no success. The code runs, what fails is the the data client with the query. I can see the logs that I print there, so I know that the lambda code is executed.
Did you download the code to your machine? It manage to query the database? or you also didn't get anything?
Yes sorry my fault i meant POST not GET.
For example when I put this simple log:
from aws-sam-webpack-plugin.
I see now, the issue you're experiencing is more related to how docker networking works between containers since AWS SAM is launching your lambda in a container of its own.
To solve this, you'll want to provide the --docker-network
to the sam local start-api
command as well as reference the endpoint by the hostname and path it would resolve as from within the docker network itself.
I've created a PR in your repository with the fix: jgomes94/sam-node#1
from aws-sam-webpack-plugin.
@buggy This can be closed as it relates to docker/aws sam rather than the plugin specifically.
from aws-sam-webpack-plugin.
Related Issues (20)
- Generated template file should always be `template.yaml` HOT 1
- Can't use ES6 import/export HOT 3
- Best way of building source code when other runtimes exist in the project HOT 1
- Improve webpack build performance HOT 2
- NodeJS14 Support HOT 1
- Debugging on VSCode: payload and env vars? HOT 1
- Support for Node 14 HOT 3
- Multiply write into .aws-sam/template.yaml
- Debugging is broken with VS Code 1.60.0 HOT 5
- build.toml HOT 3
- Build process is breaking GraphQL endpoint when running SAM Local
- Would be possible to watch only one function? HOT 2
- Remove `"module": "commonJS"` in TSConfig Example to support Tree Shaking?
- Question about how to override template parameter during webpack building HOT 2
- Add a tag for Nodejs18.x HOT 2
- SAM deploying TypeScript source code instead of the transpiled JavaScript HOT 2
- Support ES Modules HOT 2
- <Function name> has an unsupport Runtime. Must be nodejs10.x or nodejs12.x
- Support for path aliases tsconfig.json HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-sam-webpack-plugin.