UNPKG

open-next-cdk

Version:

Deploy a NextJS app using OpenNext packaging to serverless AWS using CDK

91 lines (90 loc) 3.08 kB
import * as lambda from 'aws-cdk-lib/aws-lambda'; import { FunctionOptions } from 'aws-cdk-lib/aws-lambda'; import * as s3 from 'aws-cdk-lib/aws-s3'; import { Construct } from 'constructs'; import { ImageOptimizationLambda } from './ImageOptimizationLambda'; import { NextJsAssetsDeployment, NextjsAssetsDeploymentPropsDefaults } from './NextjsAssetsDeployment'; import { BaseSiteDomainProps, NextjsBaseProps } from './NextjsBase'; import { NextjsBuild } from './NextjsBuild'; import { NextjsDistribution, NextjsDistributionPropsDefaults } from './NextjsDistribution'; import { NextJsLambda } from './NextjsLambda'; export declare const CONFIG_ENV_JSON_PATH = "next-env.json"; export interface NextjsDomainProps extends BaseSiteDomainProps { } /** * Defaults for created resources. * Why `any`? see https://github.com/aws/jsii/issues/2901 */ export interface NextjsDefaultsProps { /** * Override static file deployment settings. */ readonly assetDeployment?: NextjsAssetsDeploymentPropsDefaults; /** * Override server lambda function settings. */ readonly lambda?: FunctionOptions; /** * Override CloudFront distribution settings. */ readonly distribution?: NextjsDistributionPropsDefaults; } export interface NextjsProps extends NextjsBaseProps { /** * Optional S3 Bucket to use, defaults to assets bucket */ readonly imageOptimizationBucket?: s3.IBucket; /** * Allows you to override defaults for the resources created by this * construct. */ readonly defaults?: NextjsDefaultsProps; } /** * The `Nextjs` construct is a higher level construct that makes it easy to create a NextJS app. * * Your standalone server application will be bundled using o(utput tracing and will be deployed to a Lambda function. * Static assets will be deployed to an S3 bucket and served via CloudFront. * You must use Next.js 10.3.0 or newer. * * Please provide a `nextjsPath` to the Next.js app inside your project. * * @example * new Nextjs(this, "Web", { * nextjsPath: path.resolve("packages/web"), * }) */ export declare class Nextjs extends Construct { protected props: NextjsProps; /** * The main NextJS server handler lambda function. */ serverFunction: NextJsLambda; /** * The image optimization handler lambda function. */ imageOptimizationFunction: ImageOptimizationLambda; /** * Built NextJS project output. */ nextBuild: NextjsBuild; /** * Asset deployment to S3. */ assetsDeployment: NextJsAssetsDeployment; /** * CloudFront distribution. */ distribution: NextjsDistribution; /** * Where build-time assets for deployment are stored. */ tempBuildDir: string; configBucket?: s3.Bucket; lambdaFunctionUrl: lambda.FunctionUrl; imageOptimizationLambdaFunctionUrl: lambda.FunctionUrl; protected staticAssetBucket: s3.IBucket; constructor(scope: Construct, id: string, props: NextjsProps); get url(): string; get bucket(): s3.IBucket; }