0.36.1 • Published 3 years ago
@myhelix-cdk/apigateway-patterns v0.36.1
apigateway-patterns
A construct for setting up serverless apps using apigateway and lambda
Design
A new service gets a cdk app then maps a lambda to its respective api resource and method. Every api resource gets a new substack and methods are defined and added there.
Usage
const exampleApi = new apigwpattern.ApigatewayLambdaService(
this, "apiservice", {
apiName: "myapi"
});
// create resource "example"
const exampleResource = exampleApi.addNewEndpoint("example");
// add GET method
exampleResource.addResourceMethod(
exampleResourceGetLambda,
apigwpattern.apiGatewayMethods.GET
);
// add POST method
exampleResource.addResourceMethod(
exampleResourcePOSTLambda,
apigwpattern.apiGatewayMethods.POST
);
// create resource "example2"
const exampleResource2 = exampleApi.addNewEndpoint("example2");
// add POST method for example2
exampleResource.addResourceMethod(
example2ResourcePOSTLambda,
apigwpattern.apiGatewayMethods.POST
);