Giter VIP home page Giter VIP logo

Comments (8)

Ghilteras avatar Ghilteras commented on August 24, 2024 5

@markusgulden sam local does not work if you point the template CodeUri the pom.xml

It seems only AWS Toolkit would work like this, which is confusing because then you have to change your template based on whether you invoke Sam from your IDE or from the cli (or have 2 different templates).

from aws-lambda-builders.

harry-wright avatar harry-wright commented on August 24, 2024 5

Okay so the @jaxley fix worked. Although using the base as the override in the test, (as opposed to using the target executable as the override in the buildspec), is then causing the 'Deploy serverless application' feature (when right clicking template.yml) to fail.

So to clear things up, the default CodeUri needs to be the source root with the pom, then this needs to be overridden for a deployment. This is assumed. I have still not got round to fixing this but will follow up.

from aws-lambda-builders.

jaxley avatar jaxley commented on August 24, 2024 2

Figured an explicit workaround example would be useful.

Facing the same issue,
if I give a path to pom.xml then Sam local does not work,
and if I give the path to jar then sam build does not work. Any good way to do this?

You can use a Parameter in the template.yml file and specify the correct value for a sam build using --parameter-overrides. See the docs for this: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
Snippet from template.yaml:

Parameters:
  CodeUri:
    Description: CodeUri - change this to pom.xml directory for AWS Toolkit IDE plugin with --parameter-overrides "CodeUri"
    Type: String
    Default: lambda/target/foo.jar
Resources:
  LambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: !Sub ${CodeUri}
....

Invoking with sam (from project directory containing pom.xml; otherwise, choose a different directory relative to the template.yaml file location):

sam build --debug --parameter-overrides "ParameterKey=CodeUri,ParameterValue=."

from aws-lambda-builders.

markusgulden avatar markusgulden commented on August 24, 2024 1

You need to point the CodeUri attribute in your template.yaml to the directory with your pom.xml, not to */target/lambda.jar.
That solved the issue for me, at least.

from aws-lambda-builders.

jaapspiering avatar jaapspiering commented on August 24, 2024 1

Facing the same issue,
if I give a path to pom.xml then Sam local does not work,
and if I give the path to jar then sam build does not work. Any good way to do this?

You can use a Parameter in the template.yml file and specify the correct value for a sam build using --parameter-overrides. See the docs for this: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

from aws-lambda-builders.

Ghilteras avatar Ghilteras commented on August 24, 2024

same issue here, the only way I made it work is to have my handler implement RequestHandler

from aws-lambda-builders.

zeelmavani avatar zeelmavani commented on August 24, 2024

Facing the same issue,
if I give a path to pom.xml then Sam local does not work,
and if I give the path to jar then sam build does not work. Any good way to do this?

from aws-lambda-builders.

harry-wright avatar harry-wright commented on August 24, 2024

I too am having this issue. Will attempt the fix mentioned. Java8 + IntelliJ + AWS Toolkit Plugin, trying to test Lambda's locally using docker containers.

from aws-lambda-builders.

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.