0

I have a POC working with Java, AWS API Gateway and Lambda. It is a simple POC to do a transform of some json. I realized or at least I think that I am using version 1 of the java SDK

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-lambda-java-core</artifactId>
    <version>1.2.0</version>
</dependency>

Which appears to have a method signature like this for Lambda to run:

public void runner(InputStream inputStream, OutputStream outputStream, Context context) {//...}

So with a new project I do not want to be behind the curve and updated to the presumed SDK version 2

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>bom</artifactId>
            <version>2.6.3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>lambda</artifactId>
    </dependency>

    <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>apigateway</artifactId>
    </dependency>
</dependencies>

Problem is I cannot seem to find any documentation on what the lambda signature should look like now. I am trying the below but receive a 502 Bad Gateway.

public void run(ApiGatewayRequest request) {//...}

Is my assumption of SDK versions correct? If so where is documentation on this newer version?

I have looked at both https://github.com/aws/aws-sdk-java-v2 https://aws.amazon.com/sdk-for-java/

both of which seem to refer back to com.amazonaws instead of software.amazon.awssdk.

nerdlyist
  • 2,842
  • 2
  • 20
  • 32
  • 1
    You can refer to [this project](https://github.com/zxkane/dingtalk-callback-on-aws). – Kane Jul 02 '19 at 09:08
  • @Kane thanks for the example. It looks like there is both `com.amazonaws` and `software.amazon.awssdk` in this project. I had read the changelog which made me think the latter version 2 did not have all the objects ported over. Is that the case? – nerdlyist Jul 02 '19 at 10:33
  • I think the Java v2 SDK should be enough. You can check the API doc for the services you are using. I used both of sdk versions due to some historical reasons. – Kane Jul 03 '19 at 14:18
  • @Kane your project definitely got me closer. I will need verify the case in version 2. I see not that Lambda events are more about what is calling them. – nerdlyist Jul 03 '19 at 17:44

0 Answers0