Deploying and testing

Now, we build and deploy the package in the usual way via the console, and test it using the curl command. The output is as follows:

Ameyas-MacBook-Pro:greeter-service Webonise$ curl -X POST -H 'x-api-key:1fmETyfh8x7OazCD4nPvd9WkUPM0An953mkmpmoN'  https://8uf5e3eccd.execute-api.us-west-1.amazonaws.com/test/greeter -d '"ameya"'"Hello, ameya on 2018-08-29 16:30:46.515508 as per the time on database server"

As we can verify the output is the same as was expected, this shows how we can use AWS KMS to encrypt environment variables supplied to a lambda function and decrypt them during its execution.

This is a very elegant way of designing lambda functions inline with the 12-Factor App philosophy. With this approach, one can ...

Get Hands-On Serverless Applications with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.