Two years ago I toyed around with an odd idea of implementing recursion over HTTP redirects. The idea is that the state is managed through the query string arguments and at each recursive step we just redirect to the URL for the next one. I still can’t think of a legitimate use case for this approach but have been on an AWS Lambda binge lately and wanted to see whether I can get this “redirect recursion” working under Lambda. Turns out it’s incredibly easy.
The only question was exposing the Lambda function to the outside world but AWS offers the API Gateway service to make this happen. This also gave me a chance to mess around with the API Gateway for the first time and definitely has me thinking about entire tools and applications that can be done in a “serverless” way.
This connects any request to the /redirect-recursion endpoint to the Lambda function.
This shows the URL that needs to be invoked to run the recursion.