Coder Social home page Coder Social logo

micronaut-function-aws-lambda's Introduction

Guide:

http://guides.micronaut.io/micronaut-function-aws-lambda/guide/index.html

cURL Command:

$ curl -X "POST" "http://localhost:8080/invoice/vat" -H 'Content-Type: application/json' -d $'{"countryCode": "es","vatNumber": "B86412491","lines": [{"count": 2,"price": 19.99,"productId": "1491950358"},{"count": 1,"price": 15,"productId": "1680502395"}]}'

curl Command API AWS Lambda:

$ curl -X "POST" "https://8ah5p89xof.execute-api.eu-west-3.amazonaws.com/beta" -H 'Content-Type: application/json' -d $'{"memberStateCode": "es","vatNumber": "B86412491"}'

micronaut-function-aws-lambda's People

Contributors

bkrzyzanski avatar graemerocher avatar ilopmar avatar jangroot avatar sdelamo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

micronaut-function-aws-lambda's Issues

Tests do not pass in "complete" projects - NoSuchBeanException in ViesVatValidatorFunctionTest

ViesVatValidatorFunctionTest fails in the "complete" projects with the following error:

example.micronaut.ViesVatValidatorFunctionTest > testViesVatValidatorFunction FAILED
io.micronaut.context.exceptions.NoSuchBeanException at ViesVatValidatorFunctionTest.java:17

It seems that ViesVatValidatorClient from src/test is not registered as a bean to be retrieved in the test via server.getApplicationContext().getBean(ViesVatValidatorClient.class);

example how to use graalvm, cloudwatch event of micronaut lambda

Hi,

I can't find example how to implement AbstractMicronautLambdaRuntime for cloudwatch event.

I try code below
`public class BookLambdaRuntime extends AbstractMicronautLambdaRuntime<CloudWatchLogsEvent, Void, Map<String, Object>, String> {

public static void main(String[] args) {
    try {
        new BookLambdaRuntime().run(args);

    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}

@Override
@Nullable
protected RequestHandler<Map<String, Object>, String> createRequestHandler(String... args) {
    return new BookRequestHandler();
}

}
`
Run test with cloudwatch event
{
"errorMessage": "Unconvertible input: null"
}

micronaut-function-aws-lambda graalvm native-image build fails

I am unable to build a native application using the micronaut-function-aws-lambda example. However, I am able to create a native application following micronaut-creating-first-graal-app.

Steps to Reproduce

  1. git clone https://github.com/micronaut-guides/micronaut-function-aws-lambda.git
  2. cd micronaut-function-aws-lambda/complete/vies-vat-validator-graal/
  3. sdk use java 19.2.1-grl
  4. gu install native-image
  5. ./gradlew assemble
  6. native-image --no-server --class-path build/libs/vies-vat-validator-0.1-all.jar

When run with native-image --no-server --no-fallback --class-path build/libs/vies-vat-validator-0.1-all.jar fails with:

Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of org.apache.logging.slf4j.Log4jLogger are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use -H:+TraceClassInitialization.

Expected Behaviour
Native application should be built

Actual Behaviour
Build Fails

Environment Information
Operating System: Manjaro 18.1.2
Micronaut Version: 1.2.7
JDK Version: OpenJDK 64-Bit GraalVM CE 19.2.1 (build 25.232-b07-jvmci-19.2-b03, mixed mode)
Example Application
https://github.com/micronaut-guides/micronaut-function-aws-lambda.git

Execution failed for task ':shadowJar'. > java.lang.AbstractMethodError (no error message)

Fresh generated project can not be built.
Steps to reproduce:

>.../mn $ mn --version
| Micronaut Version: 1.0.1
| JVM Version: 1.8.0_141

>.../mn $ mn create-function awsfunction && cd awsfunction
| Generating Java project...
| Function created at /Users/askvortcov/programming/softec.be/mn/awsfunction

>.../awsfunction $ vi build.gradle
>.../awsfunction $ # comment block in build.gradle starting with if(new File("${System.getProperty("user.home")}/.aws/credentials

>.../awsfunction $ ./gradlew build

> Task :compileJava
Note: Creating bean classes for 1 type elements

> Task :shadowJar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shadowJar'.
> java.lang.AbstractMethodError (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
7 actionable tasks: 7 executed

Stacktrace gives:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':shadowJar'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
....
Caused by: java.lang.AbstractMethodError
        at com.github.jengelman.gradle.plugins.shadow.transformers.Transformer$modifyOutputStream$2.call(Unknown Source)
        at com.github.jengelman.gradle.plugins.shadow.transformers.Transformer$modifyOutputStream$2.call(Unknown Source)
        at com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction$_processTransformers_closure1.doCall(ShadowCopyAction.groovy:133)
        at com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction.processTransformers(ShadowCopyAction.groovy:131)

I've tracked it down to the line runtime "com.amazonaws:aws-lambda-java-log4j2:1.0.0" in build.gradle disabling which fixes the build. (upgrading to 1.1.0 didn't help)

SAM Local Inovke Fails with ClassNotFoundException: MicronautRequestStreamHandler

I downloaded a fresh copy of the project and tried to run it, but it fails with the following message. Can someone please take a look. Thanks.

# sam local invoke ViesVatValidatorFunction -e event.json                   
Invoking io.micronaut.function.aws.MicronautRequestStreamHandler (java8)
2019-12-02 17:16:35 Found credentials in shared credentials file: ~/.aws/credentials

Fetching lambci/lambda:java8 Docker container image......
Mounting /home/rad/works/micronaut-function-aws-lambda-master/complete/vies-vat-validator/build/libs/complete/vies-vat-validator-0.1-all.jar as /var/task:ro,delegated inside runtime container
START RequestId: 348cd87a-7932-159b-a9de-24b5a9a066b4 Version: $LATEST
java.lang.ClassNotFoundException: io.micronaut.function.aws.MicronautRequestStreamHandler
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)

Exception in thread "main" java.lang.Error: java.lang.RuntimeException: java.lang.RuntimeException: Unexpected status code from invocation/response: 299
        at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:65)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:114)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Unexpected status code from invocation/response: 299
        at lambdainternal.LambdaRuntime.reportDone(LambdaRuntime.java:227)
        at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:366)
        at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:63)
        ... 3 more
Caused by: java.lang.RuntimeException: Unexpected status code from invocation/response: 299
        at lambdainternal.LambdaRuntime.reportDone(LambdaRuntime.java:224)
        ... 5 more

UPDATE
Ok that was a naming issue and I fixed it. But now I'm getting this:

# sam local invoke ViesVatValidatorFunction -e src/test/resources/event.json
Invoking io.micronaut.function.aws.MicronautRequestStreamHandler (java8)
2019-12-02 17:37:34 Found credentials in shared credentials file: ~/.aws/credentials
Decompressing /home/rad/works/vies-vat-validato/build/libs/vies-vat-validator-0.1-all.jar

Fetching lambci/lambda:java8 Docker container image......
Mounting /tmp/tmpx9rc294s as /var/task:ro,delegated inside runtime container
START RequestId: 9defde85-7b59-10d4-8e0d-4e0924e76465 Version: $LATEST
java.lang.Exception: Class io.micronaut.function.aws.MicronautRequestStreamHandler has no public zero-argument constructor
Caused by: java.lang.NoSuchMethodException: io.micronaut.function.aws.MicronautRequestStreamHandler.<init>()
	at java.lang.Class.getConstructor0(Class.java:3082)
	at java.lang.Class.getConstructor(Class.java:1825)

Exception in thread "main" java.lang.Error: java.lang.RuntimeException: java.lang.RuntimeException: Unexpected status code from invocation/response: 299
	at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:65)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:114)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Unexpected status code from invocation/response: 299
	at lambdainternal.LambdaRuntime.reportDone(LambdaRuntime.java:227)
	at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:366)
	at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:63)
	... 3 more
Caused by: java.lang.RuntimeException: Unexpected status code from invocation/response: 299
	at lambdainternal.LambdaRuntime.reportDone(LambdaRuntime.java:224)
	... 5 more

aws-lambda example example fails at the sam test

hi I am following the AWS lambda tutorial and when I try to use sam to test it I get

java.lang.Exception: Class io.micronaut.function.aws.MicronautRequestStreamHandler has no public zero-argument constructor Caused by: java.lang.NoSuchMethodException: io.micronaut.function.aws.MicronautRequestStreamHandler.() at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.getConstructor(Class.java:1825)

do I have to create a child implementation of MicronautRequestStreamHandler?

I did create a child and it worked.

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.