Hi, eventually I managed to successfully deploy my...
# http4k
n
Hi, eventually I managed to successfully deploy my code, as an api gateway lambda, to localstack ... locally (of course).. I have created a "function url config" then tried to invoke one of my endpoint. I get this error in logs, perhaps has someone seen it already? : Execution environment startup failed: {"errorMessage":"method is invalid","errorType":"java.lang.IllegalStateException","stackTrace":["org.http4k.serverless.ApiGatewayV1AwsHttpAdapter.toHttp4kRequest(ApiGatewayV1.kt:34)","org.http4k.serverless.ApiGatewayV1AwsHttpAdapter.invoke(ApiGatewayV1.kt:41)","org.http4k.serverless.ApiGatewayV1AwsHttpAdapter.invoke(ApiGatewayV1.kt:31)","org.http4k.serverless.ApiGatewayFnLoader.invoke$lambda$0(ApiGatewayFnLoader.kt:24)","org.http4k.serverless.AwsLambdaEventFunction.handleRequest(AwsLambdaEventFunction.kt:15)
d
you're probably using the wrong wrapper: ApiGatewayV1AwsHttpAdapter <-- use v2 instead?
n
going to try
uhm with V2 function is not created .. need to understand the difference ...
ah no
d
so there are 2 different types of API "rest" and "http", and 2 different types of payload version in "http".
n
it's get created
it was just slow
it works!!! thanks a lot!
d
np. ๐Ÿ™‚
#ofCourseItWorks ๐Ÿ˜‰
n
๐Ÿ˜„ response doesnt get to my client but this is not a http4k problem, i see the response in the logs. have a nice day
d
anything else, just yell! ๐Ÿ™‚
n
Now I have a local working configuration But I still don't understand the V1 <-> V2 ApiGateway problem I had before. Now I am using the V2 version:
Copy code
@Suppress("unused")
class MyAwsLambdaExposedFunction : ApiGatewayV2LambdaFunction(printingAppWithEnv())
I've read that V1 is basically REST API. V2 is for Http and Websocket. I was quite sure my function is in REST style, why V1 does not work? It depends on some http4k configuration?
d
you probably want the HTTP v2 payload style (which is setup in your configuration for your lambda). The REST style is the old style which was using the AWS configured OpenAPI stuff.
From the http4k pulumi/serverless tutorial you can see the payload version set here: :
Copy code
const lambdaIntegration = new aws.apigatewayv2.Integration("hello-http4k-api-lambda-integration", {
    apiId: api.id,
    integrationType: "AWS_PROXY",
    integrationUri: lambdaFunction.arn,
    payloadFormatVersion: "1.0"
});
n
ah ok I see I haven't used pulumi, I've just used aws cli to create the function . I will look for a parameter like that in the aws cli reference, but basically I was just trying to understand .. So do you recommend the V2 version?
the old payload format is absolutely no good for web traffic because it doesn't support multiple headers with the same name
so, for example, you can't have more than one Cookie...
I think of the REST and v1 HTTP as deprecated
n
Very interesting! thank you very much
d
no problem - we learned the hard way so you don't have to! ๐Ÿ˜‚
(when you start to wonder why your app isn't working and it turns out that some headers go missing ๐Ÿ™ˆ )
n
ah really? that's incredible
d
well it is more like a "ah shit" moment- that's why they did v2! If you want to see incredible, you should see the Tencent serverless functions... is is a bad ripoff of the AWS API.,,
n
never heard of ... I guess I am lucky ๐Ÿ™‚
d
lol - they're massive out East - bit like Alibaba cloud. We have had the pleasure of integrating http4k with a load of APIs which are... let's just say... questionable. ๐Ÿ˜‚