interface EndpointOptions {
    lambdaFunction: Function;
    apiPath?: string;
    apiMethod?: HttpMethod;
    corsPreflight?: CorsPreflightOptions;
}

Properties

lambdaFunction: Function

The existing Lambda function to integrate with the API Gateway.

This Lambda function will be invoked whenever a request is made to the API Gateway endpoint.

apiPath?: string

The path to expose on the API Gateway.

This is the URL path that clients will use to invoke the Lambda function.

'/'
const apiPath = '/my-endpoint';
apiMethod?: HttpMethod

The HTTP method to accept on the API Gateway.

apigateway.HttpMethod.ANY
import * as apigateway from 'aws-cdk-lib/aws-apigatewayv2';

const apiMethod = apigateway.HttpMethod.POST;
corsPreflight?: CorsPreflightOptions

CORS preflight options for the API Gateway.

Configures Cross-Origin Resource Sharing (CORS) to allow web applications running at one domain to access resources from another domain.

import * as apigateway from 'aws-cdk-lib/aws-apigatewayv2';

const corsOptions = {
allowOrigins: ['https://mydomain.com'],
allowMethods: [
apigateway.CorsHttpMethod.GET,
apigateway.CorsHttpMethod.POST,
],
allowHeaders: ['Content-Type', 'Authorization'],
};