Amazon API Gateway to AWS Lambda

Create an Amazon API Gateway to AWS Lambda REST API

API Gateway REST APILambdaRequest ANY {proxy+}
import { App } from "aws-cdk-lib";
import { ApiStack } from "./api/index";
import { buildSync } from "esbuild";
import path from "node:path";

import config from "./api/config.json";

buildSync({
  bundle: true,
  entryPoints: [path.resolve(__dirname, "api", "lambda", "index.ts")],
  format: "cjs",
  outfile: path.join(__dirname, "api", "dist", "index.js"),
  platform: "node",
  sourcemap: true,
  target: "node16",
});

const app = new App();

new ApiStack(app, `${config.apiName}`, {
  description: `${config.apiDescription}`,
  stackName: `${config.apiName}`,
});

app.synth();

Download

git clone https://github.com/aws-samples/serverless-patterns
cd serverless-patterns/apigw-lambda-cdk

Pattern repository

View on GitHub

Last updated on 26 Dec 2024

Edit this page