UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

78 lines (77 loc) 2.84 kB
import { Construct } from 'constructs'; import { BundlingOptions } from './types'; import * as lambda from '../../aws-lambda'; /** * Properties for a NodejsFunction */ export interface NodejsFunctionProps extends lambda.FunctionOptions { /** * Path to the entry file (JavaScript or TypeScript). * * @default - Derived from the name of the defining file and the construct's id. * If the `NodejsFunction` is defined in `stack.ts` with `my-handler` as id * (`new NodejsFunction(this, 'my-handler')`), the construct will look at `stack.my-handler.ts` * and `stack.my-handler.js`. */ readonly entry?: string; /** * The name of the exported handler in the entry file. * * The handler is prefixed with `index.` unless the specified handler value contains a `.`, * in which case it is used as-is. * * @default handler */ readonly handler?: string; /** * The runtime environment. Only runtimes of the Node.js family are * supported. * * @default `Runtime.NODEJS_LATEST` if the `@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion` feature flag is enabled, otherwise `Runtime.NODEJS_16_X` */ readonly runtime?: lambda.Runtime; /** * Whether to automatically reuse TCP connections when working with the AWS * SDK for JavaScript. * * This sets the `AWS_NODEJS_CONNECTION_REUSE_ENABLED` environment variable * to `1`. * * @see https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html * * @default true */ readonly awsSdkConnectionReuse?: boolean; /** * The path to the dependencies lock file (`yarn.lock`, `pnpm-lock.yaml` or `package-lock.json`). * * This will be used as the source for the volume mounted in the Docker * container. * * Modules specified in `nodeModules` will be installed using the right * installer (`yarn`, `pnpm` or `npm`) along with this lock file. * * @default - the path is found by walking up parent directories searching for * a `yarn.lock`, `pnpm-lock.yaml` or `package-lock.json` file */ readonly depsLockFilePath?: string; /** * Bundling options * * @default - use default bundling options: no minify, no sourcemap, all * modules are bundled. */ readonly bundling?: BundlingOptions; /** * The path to the directory containing project config files (`package.json` or `tsconfig.json`) * * @default - the directory containing the `depsLockFilePath` */ readonly projectRoot?: string; } /** * A Node.js Lambda function bundled using esbuild */ export declare class NodejsFunction extends lambda.Function { constructor(scope: Construct, id: string, props?: NodejsFunctionProps); }