Pul kit
Pul kit

Reputation: 55

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.

Upvotes: 2

Views: 1438

Answers (2)

Pul kit
Pul kit

Reputation: 55

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 }
            }
        ]
    });

Upvotes: 3

Milan Gatyás
Milan Gatyás

Reputation: 2777

Yes, your use case is ideal for mock API integration - https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-mock-integration.html

Upvotes: 2

Related Questions