Hi, I am a newbie to serverless and this example f...
# http4k
g
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
Hey. Not specifically any examples for this... although there should be no differences to using standard DB/cloud DB.
g
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
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
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
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
Thanks @dave , I am sorry, do u mind sending a small code snippet of what you just mentioned. Thanks
d
Copy code
val dynamo =
        DynamoDb.Http(
            http = SetBaseUriFrom(Uri.of("<http://localhost:8000>"))
                .then(JavaHttpClient())
        )