0

I am unable to map error from lambda to Status Code 400.

My lambda code in Go is as follows

package main

import (
    "errors"

    "github.com/aws/aws-lambda-go/lambda"
)

func main() {

    lambda.Start(returnError)
}

func returnError() error {

    return errors.New("Something went wrong!")
}

I have added Response Integration to Status Code 400 as follows.

enter image description here

Still I get response Status Code 200 as follows. I want it to be 400

enter image description here

I am already using mapping template for request and response. I want to separate Lambda from mapping & validation.

Apoorv Mote
  • 523
  • 3
  • 25

1 Answers1

0

You need to setup Lambda as Proxy integration and then write to return status code from lambda as 400.

Here is an existing post: Is there a way to change the http status codes returned by Amazon API Gateway?

James Dean
  • 4,033
  • 1
  • 9
  • 18
  • Sorry I should have mentioned in the Question. I don't want to use proxy. I am already mapping template for request and response. I want to separate Lambda from mapping & validation. – Apoorv Mote May 19 '19 at 12:54