I have created a simple lambda function having following code.
exports.handler = (event, context, callback) => {
const operation = event.body.operation;
console.log("operation = ", operation)
switch (operation) {
case 'add': callback(null, 'post method');
break;
case 'add1': callback(null, {
status: 0,
errorType: "InternalServerError",
errorCode: "001",
errorMessage: "post method error."
}
);
default: callback(null, 'Hello from Lambda');
break;
}
};
It will be connected with Amazon API Gateway. Using a REST client able to get success & error responses. But HTTP status code is still 200. Then I have modified API Gateway integration responses in two ways.
1. Selection pattern : “InternalServerError”
2. Selection pattern : “.*InternalServerError”
Method response : 500
But I still got 200 HTTP status code. What is the actual issue related with this selection patterns?
context.fail()
? (Scroll down past the accepted answer and read the others.) – Michael - sqlbot