I've written an authorization server for CloudFront using Python/Flask and have wondered whether just writing the same functionality via Lua could be a better/faster replacement. I'm just not clear on how to use Lua to make the calls to our API. This is a good pointer in the right direction though.
Here is some example auth code for Amazon services in Lua for Nginx I wrote ages ago, which might help get an idea of what the code might look like https://gist.github.com/948423
It is very fast doing that type of stuff in Lua, and it all gets done in the same request context.
There is some new functionality in openresty since that example, so there are probably other choices of ways to implement it.