6
votes

I have a lambda handler written in Python and I wish to perform a 301 redirect to the browser. I have no idea how I can configure the response Location header (or the status code) -- the documentation doesn't seem to cover anything in context object other than some properties. Apparently context.succeed works with Node JS but this doesn't help in Python.

Returning:

{"Location": "http://google.com/"}

causes the API gateway to report:

Fri Dec 09 16:20:53 UTC 2016 : Execution failed due to configuration error: Malformed Lambda proxy response

in the test console.

So, how do I perform a 301 redirect from a Python Lambda function when using API gateway and an "AWS Lambda Proxy" integration request?

1

1 Answers

1
votes

Turns out I need to manually map the response header and the response code in the integration response. The following post helped me get what I wanted: https://kennbrodhagen.net/2016/04/02/how-to-return-302-using-api-gateway-lambda/