I provisioned a lambda function and api gateway resources in terraform, you know, the usual api gateway in front of lambda backend stuff. When I tried to return a response, i put a dictionary object in the body like this:
evt ={"pin": "some value"}
return {"statusCode": 200, "body": evt}
but it didn't work, i got an error saying malformed lambda response. Apparently the value of body needs to be a string. So it went through when I did this:
evt ={"pin": "some value"}
return {"statusCode": 200, "body": json.dumps(evt)}
So I need your help, how do i configure the API Gateway in terraform to make sure I can respond with a json/dictionary. I don't know why the event comes in as json (i checked) but I can't send back json.
These are the api gateway resources i have terraform:
aws_api_gateway_rest_api
aws_api_gateway_base_path_mapping
aws_api_gateway_deployment
aws_api_gateway_stage
aws_api_gateway_rest_api_policy
aws_api_gateway_resource
aws_lambda_permission
aws_api_gateway_method
aws_api_gateway_integration
aws_api_gateway_method_response
aws_api_gateway_integration_response
PS: I don't want to use a swagger file.