https://kotlinlang.org logo
#http4k
Title
# http4k
g

Gopal S Akshintala

08/16/2021, 4:25 PM
Hi, I am a newbie to serverless and this example from the documentation is very helpful: http4k Tutorial: Serverless http4k with AWS Lambda I am able to quickly deploy and understand the nuances. Thanks for this great library and documentation. Now I am looking for an example where a db is used with AWS lambda in Http4k, are there any sample codebases which can help? Thanks!
d

dave

08/16/2021, 4:38 PM
Hey. Not specifically any examples for this... although there should be no differences to using standard DB/cloud DB.
g

Gopal S Akshintala

08/16/2021, 4:50 PM
Thanks @dave for the response, I am looking to build something that runs on AWS lambda. (I used the pokemon example from Jetbrains webinar) and deployed with Pulumi… Now I am unable to connect the dots (coz of my lack of experience with aws) how can I make this cloud service use a cloud db as I deploy it? (sorry if it’s too basic)
Does this
http4kbox
serve as any reference?: https://github.com/daviddenton/http4kbox/tree/master/serverless
d

dave

08/16/2021, 4:56 PM
Not really because it uses raw http and S3. You want to use the aws SDK (or maybe Http4k-connect) with something like dynamodb.
g

Gopal S Akshintala

08/16/2021, 4:57 PM
yes right… let me dive into htt4k-connect… thanks @dave!
Hi @dave, I see this http-connect suits my usecase: https://github.com/http4k/http4k-connect/tree/master/amazon/dynamodb I am currently trying to connect to local DynamoDB (running on localhost:8000) and then deploy. How can I configure local endpoint with the
DynamoDb
client provided by http4k?
i m guessing somthing to do with the
DynamoDb.Http(environment)
but couldnt get it right!
d

dave

08/17/2021, 3:25 PM
Nope. You should wrap the http (client) handler passed into the Dynamo construction with a SetBaseHostFrom filter to set it up and redirect the traffic
g

Gopal S Akshintala

08/17/2021, 3:31 PM
Thanks @dave , I am sorry, do u mind sending a small code snippet of what you just mentioned. Thanks
d

dave

08/17/2021, 4:35 PM
Copy code
val dynamo =
        DynamoDb.Http(
            http = SetBaseUriFrom(Uri.of("<http://localhost:8000>"))
                .then(JavaHttpClient())
        )
13 Views