'How to send JSON body from API Gateway without using Lambda in CDK
Is there a way to send JSON body as response for 'GET' method in AWS API Gateway without using AWS Lambda. Here JSON is constant. It will be same every time this 'GET' method is called that why I don't want create a Lambda for that.
Solution 1:[1]
Yes, your use case is ideal for mock API integration - https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-mock-integration.html
Solution 2:[2]
this.restApi.root.addResource("test").addMethod("GET", new MockIntegration({
requestTemplates: {
'application/json': `{"statusCode" : 200}`
},
integrationResponses: [
{
statusCode: '200',
responseTemplates: { 'application/json': `{"name": "John"}` }
}
]
}), {
methodResponses: [
{
statusCode: '200',
responseModels: { 'application/json': Model.EMPTY_MODEL }
}
]
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Milan Gatyas |
| Solution 2 | Pul kit |
