import { CustomResource } from "aws-cdk-lib"; import { IDistribution } from "aws-cdk-lib/aws-cloudfront"; import { ITableV2 } from "aws-cdk-lib/aws-dynamodb"; import { Function as LambdaFunction } from "aws-cdk-lib/aws-lambda"; import { IBucket } from "aws-cdk-lib/aws-s3"; import { Construct } from "constructs"; import { OptionalCustomResourceProps } from "./generated-structs/OptionalCustomResourceProps"; import { OptionalFunctionProps } from "./generated-structs/OptionalFunctionProps"; import { OptionalPostDeployCustomResourceProperties } from "./generated-structs/OptionalPostDeployCustomResourceProperties"; export interface NextjsPostDeployOverrides { readonly functionProps?: OptionalFunctionProps; /** * Props that define the custom resource */ readonly customResourceProps?: OptionalCustomResourceProps; /** * Properties passed into custom resource that are passed to Lambda event handler. */ readonly customResourceProperties?: OptionalPostDeployCustomResourceProperties; } export interface NextjsPostDeployProps { readonly buildId: string; /** * Cache bucket for cleaning up old BUILD_ID prefixed objects */ readonly cacheBucket?: IBucket; /** * DynamoDB table for cleaning up old BUILD_ID prefixed revalidation entries */ readonly revalidationTable?: ITableV2; /** * If true, logs details in custom resource lambda * @default true */ readonly debug?: boolean; /** * CloudFront Distribution to invalidate */ readonly distribution?: IDistribution; /** * Override props for every construct. */ readonly overrides?: NextjsPostDeployOverrides; /** * Required for `NextjsType.GlobalFunctions` and `NextjsType.GlobalContainers` */ readonly staticAssetsBucket?: IBucket; } export interface PostDeployCustomResourceProperties { /** * Build ID of current deployment. Used to prune cache bucket of objects * with old build ids, prune DynamoDB revalidation entries with old build ids, * and prune S3 static assets based on metadata and `msTtl` */ readonly buildId: string; /** * Cache bucket name for cleaning up old BUILD_ID prefixed objects */ readonly cacheBucketName?: string; /** * DynamoDB revalidation table name for cleaning up old BUILD_ID prefixed entries */ readonly revalidationTableName?: string; /** * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudfront/command/CreateInvalidationCommand/ * @default * { distributionId: this.props.distribution?.distributionId, invalidationBatch: { callerReference: new Date().toISOString(), paths: { quantity: 1, items: ["/*"], // invalidate all paths }, }, } */ readonly createInvalidationCommandInput?: Record; /** * Time to live in milliseconds * * Must be string because of CloudFormation Custom Resource limitation * @default (1000 * 60 * 60 * 24 * 30).toString() */ readonly msTtl: string; readonly staticAssetsBucketName?: string; } /** * Performs post deployment tasks in custom resource. * * 1. CloudFront Invalidation (defaults to /*) * 2. Prune cache bucket by removing objects with old BUILD_ID prefixes * 3. Prune DynamoDB revalidation table by removing entries with old BUILD_ID prefixes * 4. Prune static assets S3 by removing objects that don't have next-build-id metadata of * current build id AND are older than `msTtl` */ export declare class NextjsPostDeploy extends Construct { customResource: CustomResource; lambdaFunction: LambdaFunction; private props; constructor(scope: Construct, id: string, props: NextjsPostDeployProps); private createFunction; private createCustomResource; }