Git Product home page Git Product logo

Comments (8)

jgomes94 avatar jgomes94 commented on June 3, 2024 1

I answered in the pull request @ryansonshine and it was totally it! Thank you very much!

from aws-sam-webpack-plugin.

ryansonshine avatar ryansonshine commented on June 3, 2024

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:

  1. 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,
  },
}
  1. Make sure your data-api-client is included in dependencies and not devDependencies
  2. Try running your logic on my boilerplate here: https://github.com/ryansonshine/sam-typescript-vscode-starter

from aws-sam-webpack-plugin.

jgomes94 avatar jgomes94 commented on June 3, 2024

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.

ryansonshine avatar ryansonshine commented on June 3, 2024

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.

ryansonshine avatar ryansonshine commented on June 3, 2024

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.

jgomes94 avatar jgomes94 commented on June 3, 2024

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:

image

I can see it in the console:
image

from aws-sam-webpack-plugin.

ryansonshine avatar ryansonshine commented on June 3, 2024

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.

ryansonshine avatar ryansonshine commented on June 3, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.