UNPKG

open-next-cdk

Version:

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

1,320 lines (833 loc) 222 kB
<h1 align="center"> <div align="center"> <img align="middle" alt="Typescript" src="./resources/typescript.svg" width=15> <img align="middle" alt="Java" src="./resources/java.svg" width=20> <img align="middle" alt="Go" src="./resources/go.svg" width=30> <img align="middle" alt="Python" src="./resources/python.svg" width=15> <img align="middle" alt=".NET" src="./resources/dotnet.svg" width=30> </div> OpenNext CDK </h1> <div align="center"> <a href="https://github.com/datasprayio/open-next-cdk/actions?query=workflow%3A%22build%22"> <img align="middle" alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/datasprayio/open-next-cdk/build.yml?style=for-the-badge"> </a> <a href="https://github.com/datasprayio/open-next-cdk/blob/master/LICENSE"> <img align="middle" alt="License" src="https://img.shields.io/github/license/datasprayio/open-next-cdk?style=for-the-badge"> </a> <a href="https://www.npmjs.com/package/open-next-cdk"> <img align="middle" alt="NPM release" src="https://img.shields.io/npm/v/open-next-cdk?label=RELEASE&color=blue&style=for-the-badge"> </a> </div> <h3 align="center">Deploy NextJS on AWS using CDK IaC and OpenNext packaging</h3> ### Contents - [What is this?](#what-is-this) - [Quickstart](#quickstart) - [Requirements](#requirements) - [Advanced](#advanced) - [Pre-built OpenNext package](#pre-built-opennext-package) - [Additional security](#additional-security) - [About](#about) - [Benefits](#benefits) - [Dependencies](#dependencies) - [Similar projects](#similar-projects) - [Fork from cdk-nextjs](#fork-from-cdk-nextjs) - [Contributing](#contributing) - [Using Projen](#using-projen) # What is this? A building block for Amazon's infrastructure-as-code CDK toolkit to deploy a NextJS app using AWS serverless services. Your NextJS app is packaged using OpenNext to fit the serverless format on Lambda # Requirements NextJs versions: >=12.3.0+ (includes 13.0.0+) Platforms: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-arm64, win32-x64 # Quickstart ### NextJS setup Add a dev dependency `esbuild@0.17.16` to your NextJS project. ```shell npm install --save-dev esbuild@0.17.16 ``` ### CDK Construct Use this construct in your CDK application to deploy your NextJS app to AWS. <details> <summary>Typescript <img align="middle" alt="Typescript" src="./resources/typescript.svg" width=20></summary> <a href="https://www.npmjs.com/package/open-next-cdk"> <img align="middle" alt="NPM release" src="https://img.shields.io/npm/v/open-next-cdk?style=for-the-badge"> </a> Install the dependency using npm: ```shell npm install --save-dev esbuild@0.17.16 open-next-cdk ``` Use the construct in your CDK application: ```ts import { Nextjs } from 'open-next-cdk'; new Nextjs(this, 'Web', { nextjsPath: './web', // relative path to nextjs project root }); ``` </details> <details> <summary>Java <img align="middle" alt="Java" src="./resources/java.svg" width=20></summary> <a href="https://search.maven.org/artifact/io.dataspray/open-next-cdk"> <img align="middle" alt="Maven Central release" src="https://img.shields.io/maven-central/v/io.dataspray/open-next-cdk?style=for-the-badge"> </a> Install the dependency using Maven: ```xml <dependency> <groupId>io.dataspray</groupId> <artifactId>open-next-cdk</artifactId> <version>x.y.z</version> </dependency> ``` Use the construct in your CDK application: ```java Nextjs.Builder.create(this, getConstructId()) .nextjsPath("./web") .build(); ``` </details> <details> <summary>Go <img align="middle" alt="Go" src="./resources/go.svg" width=20></summary> <a href="https://github.com/datasprayio/open-next-cdk/tree/main/opennextcdk"> <img align="middle" alt="Go release" src="https://img.shields.io/github/go-mod/go-version/datasprayio/open-next-cdk/go?filename=opennextcdk%2Fgo.mod&label=GO&style=for-the-badge"> </a> Install the dependency: ```shell go get github.com:datasprayio/open-next-cdk.git@go ``` Or checkout [the code in the `go` branch](https://github.com/datasprayio/open-next-cdk/tree/go). </details> <details> <summary>Python <img align="middle" alt="Python" src="./resources/python.svg" width=20></summary> <a href="https://pypi.org/project/open-next-cdk/"> <img align="middle" alt="Pypi release" src="https://img.shields.io/pypi/v/open-next-cdk?style=for-the-badge"> </a> Install the dependency: ```shell pip install open-next-cdk ``` </details> <details> <summary>.NET <img align="middle" alt=".NET" src="./resources/dotnet.svg" width=20></summary> <a href="https://www.nuget.org/packages/Dataspray.OpenNextCdk"> <img align="middle" alt="Nuget release" src="https://img.shields.io/nuget/v/Dataspray.OpenNextCdk?style=for-the-badge"> </a> Install the dependency: ```shell dotnet add package Dataspray.OpenNextCdk ``` </details> <br/> This will automatically build your NextJS app and package it for you as part of the CDK construct. If you would prefer to package it separately, see below: # Advanced ### Pre-built OpenNext package <details> <summary>How-to</summary> You may also provide already pre-built OpenNext package directly by building it yourself first: ```shell open-next build ``` You will find a new folder `.open-next` which contains the packaging for your NextJS App. Now you can use the construct by instructing it not to build your app, just use the OpenNext folder directly: ```ts import { Nextjs } from 'open-next-cdk'; new Nextjs(this, 'Web', { openNextPath: './web/.open-next', // relative path to .open-next folder }); ``` </details> ### Additional security <details> <summary>How-to</summary> ```ts import { RemovalPolicy, Stack } from "aws-cdk-lib"; import { Construct } from "constructs"; import { CfnWebAcl } from "aws-cdk-lib/aws-wafv2"; import { SecurityPolicyProtocol, type DistributionProps } from "aws-cdk-lib/aws-cloudfront"; import { Nextjs, type NextjsDistributionProps } from "cdk-nextjs-standalone"; import { Bucket, BlockPublicAccess, BucketEncryption } from "aws-cdk-lib/aws-s3"; // Because of `WebAcl`, this stack must be deployed in us-east-1. If you want // to deploy Nextjs in another region, add WAF in separate stack deployed in us-east-1 export class UiStack { constructor(scope: Construct, id: string) { const webAcl = new CfnWebAcl(this, "WebAcl", { ... }); new Nextjs(this, "NextSite", { nextjsPath: "...", defaults: { assetDeployment: { bucket: new Bucket(this, "NextjsAssetDeploymentBucket", { autoDeleteObjects: true, removalPolicy: RemovalPolicy.DESTROY, encryption: BucketEncryption.S3_MANAGED, enforceSSL: true, blockPublicAccess: BlockPublicAccess.BLOCK_ALL, }), }, distribution: { functionUrlAuthType: FunctionUrlAuthType.AWS_IAM, cdk: { distribution: { webAclId: webAcl.attrArn, minimumProtocolVersion: SecurityPolicyProtocol.TLS_V1_2_2021, } as DistributionProps, }, } satisfies Partial<NextjsDistributionProps>, }, }); } } ``` </details> <br /> # About Deploys a NextJs static site with server-side rendering and API support. Uses AWS lambda and CloudFront. There is a new (since Next 12) [standalone output mode which uses output tracing](https://nextjs.org/docs/advanced-features/output-file-tracing) to generate a minimal server and static files. This standalone server can be converted into a CloudFront distribution and a lambda handler that handles SSR, API, and routing. The CloudFront default origin first checks S3 for static files and falls back to an HTTP origin using a lambda function URL. ## Benefits This approach is most compatible with new NextJs features such as ESM configuration, [middleware](https://nextjs.org/docs/advanced-features/middleware), next-auth, and React server components ("appDir"). The unmaintained [@serverless-nextjs project](https://github.com/serverless-nextjs/serverless-next.js) uses the deprecated `serverless` NextJs build target which [prevents the use of new features](https://github.com/serverless-nextjs/serverless-next.js/pull/2478). This construct was created to use the new `standalone` output build and newer AWS features like lambda function URLs and fallback origins. You may want to look at [Serverless Stack](https://sst.dev) and its [NextjsSite](https://docs.sst.dev/constructs/NextjsSite) construct for an improved developer experience if you are building serverless applications on CDK. ## Dependencies Built on top of [open-next](https://open-next.js.org/), which was partially built using the original core of cdk-nextjs-standalone. ## Similar projects This project is heavily based on - [Open-next](https://open-next.js.org/) - <https://github.com/iiroj/iiro.fi/commit/bd43222032d0dbb765e1111825f64dbb5db851d9> - <https://github.com/sladg/nextjs-lambda> - <https://github.com/serverless-nextjs/serverless-next.js/tree/master/packages/compat-layers/apigw-lambda-compat> - [Serverless Stack](https://github.com/serverless-stack/sst) - [RemixSite](https://github.com/serverless-stack/sst/blob/master/packages/resources/src/NextjsSite.ts) construct - [NextjsSite](https://github.com/serverless-stack/sst/blob/master/packages/resources/src/RemixSite.ts) construct ### Fork from cdk-nextjs Compatible with: `cdk-nextjs`[@3.2.1](https://github.com/jetbridge/cdk-nextjs/releases/tag/v3.2.1) This project has been initially forked from [cdk-nextjs](https://github.com/jetbridge/cdk-nextjs) in order to [publish the package to other langugages](https://github.com/jetbridge/cdk-nextjs/issues/120#issuecomment-1634926223). So far notable changes are: - Extended language support: TS, Java, Go, .NET, Python. - Extended platform support: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-arm64, win32-x64 - Use pre-built open-next package # Contributing Hey there, we value every new contribution a lot 🙏🏼 thank you. Open an issue or a PR and we'll gladly help you out. ## Using Projen Most boilerplate files are pre-generated including package.json. Don't update it directly, rather update `.projenrc.js` then run `yarn projen` to re-generate the files. # API Reference <a name="API Reference" id="api-reference"></a> ## Constructs <a name="Constructs" id="Constructs"></a> ### ImageOptimizationLambda <a name="ImageOptimizationLambda" id="open-next-cdk.ImageOptimizationLambda"></a> This lambda handles image optimization. #### Initializers <a name="Initializers" id="open-next-cdk.ImageOptimizationLambda.Initializer"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' new ImageOptimizationLambda(scope: Construct, id: string, props: ImageOptimizationProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | | <code><a href="#open-next-cdk.ImageOptimizationLambda.Initializer.parameter.scope">scope</a></code> | <code>constructs.Construct</code> | *No description.* | | <code><a href="#open-next-cdk.ImageOptimizationLambda.Initializer.parameter.id">id</a></code> | <code>string</code> | *No description.* | | <code><a href="#open-next-cdk.ImageOptimizationLambda.Initializer.parameter.props">props</a></code> | <code><a href="#open-next-cdk.ImageOptimizationProps">ImageOptimizationProps</a></code> | *No description.* | --- ##### `scope`<sup>Required</sup> <a name="scope" id="open-next-cdk.ImageOptimizationLambda.Initializer.parameter.scope"></a> - *Type:* constructs.Construct --- ##### `id`<sup>Required</sup> <a name="id" id="open-next-cdk.ImageOptimizationLambda.Initializer.parameter.id"></a> - *Type:* string --- ##### `props`<sup>Required</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.Initializer.parameter.props"></a> - *Type:* <a href="#open-next-cdk.ImageOptimizationProps">ImageOptimizationProps</a> --- #### Methods <a name="Methods" id="Methods"></a> | **Name** | **Description** | | --- | --- | | <code><a href="#open-next-cdk.ImageOptimizationLambda.toString">toString</a></code> | Returns a string representation of this construct. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.applyRemovalPolicy">applyRemovalPolicy</a></code> | Apply the given removal policy to this resource. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.addEventSource">addEventSource</a></code> | Adds an event source to this function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.addEventSourceMapping">addEventSourceMapping</a></code> | Adds an event source that maps to this AWS Lambda function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.addFunctionUrl">addFunctionUrl</a></code> | Adds a url to this lambda function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.addPermission">addPermission</a></code> | Adds a permission to the Lambda resource policy. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.addToRolePolicy">addToRolePolicy</a></code> | Adds a statement to the IAM role assumed by the instance. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.configureAsyncInvoke">configureAsyncInvoke</a></code> | Configures options for asynchronous invocation. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.considerWarningOnInvokeFunctionPermissions">considerWarningOnInvokeFunctionPermissions</a></code> | A warning will be added to functions under the following conditions: - permissions that include `lambda:InvokeFunction` are added to the unqualified function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.grantInvoke">grantInvoke</a></code> | Grant the given identity permissions to invoke this Lambda. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.grantInvokeCompositePrincipal">grantInvokeCompositePrincipal</a></code> | Grant multiple principals the ability to invoke this Lambda via CompositePrincipal. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.grantInvokeUrl">grantInvokeUrl</a></code> | Grant the given identity permissions to invoke this Lambda Function URL. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metric">metric</a></code> | Return the given named metric for this Function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricDuration">metricDuration</a></code> | How long execution of this Lambda takes. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricErrors">metricErrors</a></code> | How many invocations of this Lambda fail. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricInvocations">metricInvocations</a></code> | How often this Lambda is invoked. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricThrottles">metricThrottles</a></code> | How often this Lambda is throttled. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.addAlias">addAlias</a></code> | Defines an alias for this function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.addEnvironment">addEnvironment</a></code> | Adds an environment variable to this Lambda function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.addLayers">addLayers</a></code> | Adds one or more Lambda Layers to this Lambda function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.invalidateVersionBasedOn">invalidateVersionBasedOn</a></code> | Mix additional information into the hash of the Version object. | --- ##### `toString` <a name="toString" id="open-next-cdk.ImageOptimizationLambda.toString"></a> ```typescript public toString(): string ``` Returns a string representation of this construct. ##### `applyRemovalPolicy` <a name="applyRemovalPolicy" id="open-next-cdk.ImageOptimizationLambda.applyRemovalPolicy"></a> ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void ``` Apply the given removal policy to this resource. The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). ###### `policy`<sup>Required</sup> <a name="policy" id="open-next-cdk.ImageOptimizationLambda.applyRemovalPolicy.parameter.policy"></a> - *Type:* aws-cdk-lib.RemovalPolicy --- ##### `addEventSource` <a name="addEventSource" id="open-next-cdk.ImageOptimizationLambda.addEventSource"></a> ```typescript public addEventSource(source: IEventSource): void ``` Adds an event source to this function. Event sources are implemented in the aws-cdk-lib/aws-lambda-event-sources module. The following example adds an SQS Queue as an event source: ``` import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources'; myFunction.addEventSource(new SqsEventSource(myQueue)); ``` ###### `source`<sup>Required</sup> <a name="source" id="open-next-cdk.ImageOptimizationLambda.addEventSource.parameter.source"></a> - *Type:* aws-cdk-lib.aws_lambda.IEventSource --- ##### `addEventSourceMapping` <a name="addEventSourceMapping" id="open-next-cdk.ImageOptimizationLambda.addEventSourceMapping"></a> ```typescript public addEventSourceMapping(id: string, options: EventSourceMappingOptions): EventSourceMapping ``` Adds an event source that maps to this AWS Lambda function. ###### `id`<sup>Required</sup> <a name="id" id="open-next-cdk.ImageOptimizationLambda.addEventSourceMapping.parameter.id"></a> - *Type:* string --- ###### `options`<sup>Required</sup> <a name="options" id="open-next-cdk.ImageOptimizationLambda.addEventSourceMapping.parameter.options"></a> - *Type:* aws-cdk-lib.aws_lambda.EventSourceMappingOptions --- ##### `addFunctionUrl` <a name="addFunctionUrl" id="open-next-cdk.ImageOptimizationLambda.addFunctionUrl"></a> ```typescript public addFunctionUrl(options?: FunctionUrlOptions): FunctionUrl ``` Adds a url to this lambda function. ###### `options`<sup>Optional</sup> <a name="options" id="open-next-cdk.ImageOptimizationLambda.addFunctionUrl.parameter.options"></a> - *Type:* aws-cdk-lib.aws_lambda.FunctionUrlOptions --- ##### `addPermission` <a name="addPermission" id="open-next-cdk.ImageOptimizationLambda.addPermission"></a> ```typescript public addPermission(id: string, permission: Permission): void ``` Adds a permission to the Lambda resource policy. > [Permission for details.](Permission for details.) ###### `id`<sup>Required</sup> <a name="id" id="open-next-cdk.ImageOptimizationLambda.addPermission.parameter.id"></a> - *Type:* string The id for the permission construct. --- ###### `permission`<sup>Required</sup> <a name="permission" id="open-next-cdk.ImageOptimizationLambda.addPermission.parameter.permission"></a> - *Type:* aws-cdk-lib.aws_lambda.Permission The permission to grant to this Lambda function. --- ##### `addToRolePolicy` <a name="addToRolePolicy" id="open-next-cdk.ImageOptimizationLambda.addToRolePolicy"></a> ```typescript public addToRolePolicy(statement: PolicyStatement): void ``` Adds a statement to the IAM role assumed by the instance. ###### `statement`<sup>Required</sup> <a name="statement" id="open-next-cdk.ImageOptimizationLambda.addToRolePolicy.parameter.statement"></a> - *Type:* aws-cdk-lib.aws_iam.PolicyStatement --- ##### `configureAsyncInvoke` <a name="configureAsyncInvoke" id="open-next-cdk.ImageOptimizationLambda.configureAsyncInvoke"></a> ```typescript public configureAsyncInvoke(options: EventInvokeConfigOptions): void ``` Configures options for asynchronous invocation. ###### `options`<sup>Required</sup> <a name="options" id="open-next-cdk.ImageOptimizationLambda.configureAsyncInvoke.parameter.options"></a> - *Type:* aws-cdk-lib.aws_lambda.EventInvokeConfigOptions --- ##### `considerWarningOnInvokeFunctionPermissions` <a name="considerWarningOnInvokeFunctionPermissions" id="open-next-cdk.ImageOptimizationLambda.considerWarningOnInvokeFunctionPermissions"></a> ```typescript public considerWarningOnInvokeFunctionPermissions(scope: Construct, action: string): void ``` A warning will be added to functions under the following conditions: - permissions that include `lambda:InvokeFunction` are added to the unqualified function. function.currentVersion is invoked before or after the permission is created. This applies only to permissions on Lambda functions, not versions or aliases. This function is overridden as a noOp for QualifiedFunctionBase. ###### `scope`<sup>Required</sup> <a name="scope" id="open-next-cdk.ImageOptimizationLambda.considerWarningOnInvokeFunctionPermissions.parameter.scope"></a> - *Type:* constructs.Construct --- ###### `action`<sup>Required</sup> <a name="action" id="open-next-cdk.ImageOptimizationLambda.considerWarningOnInvokeFunctionPermissions.parameter.action"></a> - *Type:* string --- ##### `grantInvoke` <a name="grantInvoke" id="open-next-cdk.ImageOptimizationLambda.grantInvoke"></a> ```typescript public grantInvoke(grantee: IGrantable): Grant ``` Grant the given identity permissions to invoke this Lambda. ###### `grantee`<sup>Required</sup> <a name="grantee" id="open-next-cdk.ImageOptimizationLambda.grantInvoke.parameter.grantee"></a> - *Type:* aws-cdk-lib.aws_iam.IGrantable --- ##### `grantInvokeCompositePrincipal` <a name="grantInvokeCompositePrincipal" id="open-next-cdk.ImageOptimizationLambda.grantInvokeCompositePrincipal"></a> ```typescript public grantInvokeCompositePrincipal(compositePrincipal: CompositePrincipal): Grant[] ``` Grant multiple principals the ability to invoke this Lambda via CompositePrincipal. ###### `compositePrincipal`<sup>Required</sup> <a name="compositePrincipal" id="open-next-cdk.ImageOptimizationLambda.grantInvokeCompositePrincipal.parameter.compositePrincipal"></a> - *Type:* aws-cdk-lib.aws_iam.CompositePrincipal --- ##### `grantInvokeUrl` <a name="grantInvokeUrl" id="open-next-cdk.ImageOptimizationLambda.grantInvokeUrl"></a> ```typescript public grantInvokeUrl(grantee: IGrantable): Grant ``` Grant the given identity permissions to invoke this Lambda Function URL. ###### `grantee`<sup>Required</sup> <a name="grantee" id="open-next-cdk.ImageOptimizationLambda.grantInvokeUrl.parameter.grantee"></a> - *Type:* aws-cdk-lib.aws_iam.IGrantable --- ##### `metric` <a name="metric" id="open-next-cdk.ImageOptimizationLambda.metric"></a> ```typescript public metric(metricName: string, props?: MetricOptions): Metric ``` Return the given named metric for this Function. ###### `metricName`<sup>Required</sup> <a name="metricName" id="open-next-cdk.ImageOptimizationLambda.metric.parameter.metricName"></a> - *Type:* string --- ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metric.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `metricDuration` <a name="metricDuration" id="open-next-cdk.ImageOptimizationLambda.metricDuration"></a> ```typescript public metricDuration(props?: MetricOptions): Metric ``` How long execution of this Lambda takes. Average over 5 minutes ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricDuration.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `metricErrors` <a name="metricErrors" id="open-next-cdk.ImageOptimizationLambda.metricErrors"></a> ```typescript public metricErrors(props?: MetricOptions): Metric ``` How many invocations of this Lambda fail. Sum over 5 minutes ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricErrors.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `metricInvocations` <a name="metricInvocations" id="open-next-cdk.ImageOptimizationLambda.metricInvocations"></a> ```typescript public metricInvocations(props?: MetricOptions): Metric ``` How often this Lambda is invoked. Sum over 5 minutes ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricInvocations.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `metricThrottles` <a name="metricThrottles" id="open-next-cdk.ImageOptimizationLambda.metricThrottles"></a> ```typescript public metricThrottles(props?: MetricOptions): Metric ``` How often this Lambda is throttled. Sum over 5 minutes ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricThrottles.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `addAlias` <a name="addAlias" id="open-next-cdk.ImageOptimizationLambda.addAlias"></a> ```typescript public addAlias(aliasName: string, options?: AliasOptions): Alias ``` Defines an alias for this function. The alias will automatically be updated to point to the latest version of the function as it is being updated during a deployment. ```ts declare const fn: lambda.Function; fn.addAlias('Live'); // Is equivalent to new lambda.Alias(this, 'AliasLive', { aliasName: 'Live', version: fn.currentVersion, }); ``` ###### `aliasName`<sup>Required</sup> <a name="aliasName" id="open-next-cdk.ImageOptimizationLambda.addAlias.parameter.aliasName"></a> - *Type:* string The name of the alias. --- ###### `options`<sup>Optional</sup> <a name="options" id="open-next-cdk.ImageOptimizationLambda.addAlias.parameter.options"></a> - *Type:* aws-cdk-lib.aws_lambda.AliasOptions Alias options. --- ##### `addEnvironment` <a name="addEnvironment" id="open-next-cdk.ImageOptimizationLambda.addEnvironment"></a> ```typescript public addEnvironment(key: string, value: string, options?: EnvironmentOptions): Function ``` Adds an environment variable to this Lambda function. If this is a ref to a Lambda function, this operation results in a no-op. ###### `key`<sup>Required</sup> <a name="key" id="open-next-cdk.ImageOptimizationLambda.addEnvironment.parameter.key"></a> - *Type:* string The environment variable key. --- ###### `value`<sup>Required</sup> <a name="value" id="open-next-cdk.ImageOptimizationLambda.addEnvironment.parameter.value"></a> - *Type:* string The environment variable's value. --- ###### `options`<sup>Optional</sup> <a name="options" id="open-next-cdk.ImageOptimizationLambda.addEnvironment.parameter.options"></a> - *Type:* aws-cdk-lib.aws_lambda.EnvironmentOptions Environment variable options. --- ##### `addLayers` <a name="addLayers" id="open-next-cdk.ImageOptimizationLambda.addLayers"></a> ```typescript public addLayers(layers: ILayerVersion): void ``` Adds one or more Lambda Layers to this Lambda function. ###### `layers`<sup>Required</sup> <a name="layers" id="open-next-cdk.ImageOptimizationLambda.addLayers.parameter.layers"></a> - *Type:* aws-cdk-lib.aws_lambda.ILayerVersion the layers to be added. --- ##### `invalidateVersionBasedOn` <a name="invalidateVersionBasedOn" id="open-next-cdk.ImageOptimizationLambda.invalidateVersionBasedOn"></a> ```typescript public invalidateVersionBasedOn(x: string): void ``` Mix additional information into the hash of the Version object. The Lambda Function construct does its best to automatically create a new Version when anything about the Function changes (its code, its layers, any of the other properties). However, you can sometimes source information from places that the CDK cannot look into, like the deploy-time values of SSM parameters. In those cases, the CDK would not force the creation of a new Version object when it actually should. This method can be used to invalidate the current Version object. Pass in any string into this method, and make sure the string changes when you know a new Version needs to be created. This method may be called more than once. ###### `x`<sup>Required</sup> <a name="x" id="open-next-cdk.ImageOptimizationLambda.invalidateVersionBasedOn.parameter.x"></a> - *Type:* string --- #### Static Functions <a name="Static Functions" id="Static Functions"></a> | **Name** | **Description** | | --- | --- | | <code><a href="#open-next-cdk.ImageOptimizationLambda.isConstruct">isConstruct</a></code> | Checks if `x` is a construct. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.isOwnedResource">isOwnedResource</a></code> | Returns true if the construct was created by CDK, and false otherwise. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.isResource">isResource</a></code> | Check whether the given construct is a Resource. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.classifyVersionProperty">classifyVersionProperty</a></code> | Record whether specific properties in the `AWS::Lambda::Function` resource should also be associated to the Version resource. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.fromFunctionArn">fromFunctionArn</a></code> | Import a lambda function into the CDK using its ARN. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.fromFunctionAttributes">fromFunctionAttributes</a></code> | Creates a Lambda function object which represents a function not defined within this stack. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.fromFunctionName">fromFunctionName</a></code> | Import a lambda function into the CDK using its name. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricAll">metricAll</a></code> | Return the given named metric for this Lambda. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricAllConcurrentExecutions">metricAllConcurrentExecutions</a></code> | Metric for the number of concurrent executions across all Lambdas. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricAllDuration">metricAllDuration</a></code> | Metric for the Duration executing all Lambdas. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricAllErrors">metricAllErrors</a></code> | Metric for the number of Errors executing all Lambdas. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricAllInvocations">metricAllInvocations</a></code> | Metric for the number of invocations of all Lambdas. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricAllThrottles">metricAllThrottles</a></code> | Metric for the number of throttled invocations of all Lambdas. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.metricAllUnreservedConcurrentExecutions">metricAllUnreservedConcurrentExecutions</a></code> | Metric for the number of unreserved concurrent executions across all Lambdas. | --- ##### ~~`isConstruct`~~ <a name="isConstruct" id="open-next-cdk.ImageOptimizationLambda.isConstruct"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.isConstruct(x: any) ``` Checks if `x` is a construct. ###### `x`<sup>Required</sup> <a name="x" id="open-next-cdk.ImageOptimizationLambda.isConstruct.parameter.x"></a> - *Type:* any Any object. --- ##### `isOwnedResource` <a name="isOwnedResource" id="open-next-cdk.ImageOptimizationLambda.isOwnedResource"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. ###### `construct`<sup>Required</sup> <a name="construct" id="open-next-cdk.ImageOptimizationLambda.isOwnedResource.parameter.construct"></a> - *Type:* constructs.IConstruct --- ##### `isResource` <a name="isResource" id="open-next-cdk.ImageOptimizationLambda.isResource"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. ###### `construct`<sup>Required</sup> <a name="construct" id="open-next-cdk.ImageOptimizationLambda.isResource.parameter.construct"></a> - *Type:* constructs.IConstruct --- ##### `classifyVersionProperty` <a name="classifyVersionProperty" id="open-next-cdk.ImageOptimizationLambda.classifyVersionProperty"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.classifyVersionProperty(propertyName: string, locked: boolean) ``` Record whether specific properties in the `AWS::Lambda::Function` resource should also be associated to the Version resource. See 'currentVersion' section in the module README for more details. ###### `propertyName`<sup>Required</sup> <a name="propertyName" id="open-next-cdk.ImageOptimizationLambda.classifyVersionProperty.parameter.propertyName"></a> - *Type:* string The property to classify. --- ###### `locked`<sup>Required</sup> <a name="locked" id="open-next-cdk.ImageOptimizationLambda.classifyVersionProperty.parameter.locked"></a> - *Type:* boolean whether the property should be associated to the version or not. --- ##### `fromFunctionArn` <a name="fromFunctionArn" id="open-next-cdk.ImageOptimizationLambda.fromFunctionArn"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.fromFunctionArn(scope: Construct, id: string, functionArn: string) ``` Import a lambda function into the CDK using its ARN. ###### `scope`<sup>Required</sup> <a name="scope" id="open-next-cdk.ImageOptimizationLambda.fromFunctionArn.parameter.scope"></a> - *Type:* constructs.Construct --- ###### `id`<sup>Required</sup> <a name="id" id="open-next-cdk.ImageOptimizationLambda.fromFunctionArn.parameter.id"></a> - *Type:* string --- ###### `functionArn`<sup>Required</sup> <a name="functionArn" id="open-next-cdk.ImageOptimizationLambda.fromFunctionArn.parameter.functionArn"></a> - *Type:* string --- ##### `fromFunctionAttributes` <a name="fromFunctionAttributes" id="open-next-cdk.ImageOptimizationLambda.fromFunctionAttributes"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.fromFunctionAttributes(scope: Construct, id: string, attrs: FunctionAttributes) ``` Creates a Lambda function object which represents a function not defined within this stack. ###### `scope`<sup>Required</sup> <a name="scope" id="open-next-cdk.ImageOptimizationLambda.fromFunctionAttributes.parameter.scope"></a> - *Type:* constructs.Construct The parent construct. --- ###### `id`<sup>Required</sup> <a name="id" id="open-next-cdk.ImageOptimizationLambda.fromFunctionAttributes.parameter.id"></a> - *Type:* string The name of the lambda construct. --- ###### `attrs`<sup>Required</sup> <a name="attrs" id="open-next-cdk.ImageOptimizationLambda.fromFunctionAttributes.parameter.attrs"></a> - *Type:* aws-cdk-lib.aws_lambda.FunctionAttributes the attributes of the function to import. --- ##### `fromFunctionName` <a name="fromFunctionName" id="open-next-cdk.ImageOptimizationLambda.fromFunctionName"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.fromFunctionName(scope: Construct, id: string, functionName: string) ``` Import a lambda function into the CDK using its name. ###### `scope`<sup>Required</sup> <a name="scope" id="open-next-cdk.ImageOptimizationLambda.fromFunctionName.parameter.scope"></a> - *Type:* constructs.Construct --- ###### `id`<sup>Required</sup> <a name="id" id="open-next-cdk.ImageOptimizationLambda.fromFunctionName.parameter.id"></a> - *Type:* string --- ###### `functionName`<sup>Required</sup> <a name="functionName" id="open-next-cdk.ImageOptimizationLambda.fromFunctionName.parameter.functionName"></a> - *Type:* string --- ##### `metricAll` <a name="metricAll" id="open-next-cdk.ImageOptimizationLambda.metricAll"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.metricAll(metricName: string, props?: MetricOptions) ``` Return the given named metric for this Lambda. ###### `metricName`<sup>Required</sup> <a name="metricName" id="open-next-cdk.ImageOptimizationLambda.metricAll.parameter.metricName"></a> - *Type:* string --- ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricAll.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `metricAllConcurrentExecutions` <a name="metricAllConcurrentExecutions" id="open-next-cdk.ImageOptimizationLambda.metricAllConcurrentExecutions"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.metricAllConcurrentExecutions(props?: MetricOptions) ``` Metric for the number of concurrent executions across all Lambdas. ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricAllConcurrentExecutions.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `metricAllDuration` <a name="metricAllDuration" id="open-next-cdk.ImageOptimizationLambda.metricAllDuration"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.metricAllDuration(props?: MetricOptions) ``` Metric for the Duration executing all Lambdas. ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricAllDuration.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `metricAllErrors` <a name="metricAllErrors" id="open-next-cdk.ImageOptimizationLambda.metricAllErrors"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.metricAllErrors(props?: MetricOptions) ``` Metric for the number of Errors executing all Lambdas. ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricAllErrors.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `metricAllInvocations` <a name="metricAllInvocations" id="open-next-cdk.ImageOptimizationLambda.metricAllInvocations"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.metricAllInvocations(props?: MetricOptions) ``` Metric for the number of invocations of all Lambdas. ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricAllInvocations.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `metricAllThrottles` <a name="metricAllThrottles" id="open-next-cdk.ImageOptimizationLambda.metricAllThrottles"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.metricAllThrottles(props?: MetricOptions) ``` Metric for the number of throttled invocations of all Lambdas. ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricAllThrottles.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- ##### `metricAllUnreservedConcurrentExecutions` <a name="metricAllUnreservedConcurrentExecutions" id="open-next-cdk.ImageOptimizationLambda.metricAllUnreservedConcurrentExecutions"></a> ```typescript import { ImageOptimizationLambda } from 'open-next-cdk' ImageOptimizationLambda.metricAllUnreservedConcurrentExecutions(props?: MetricOptions) ``` Metric for the number of unreserved concurrent executions across all Lambdas. ###### `props`<sup>Optional</sup> <a name="props" id="open-next-cdk.ImageOptimizationLambda.metricAllUnreservedConcurrentExecutions.parameter.props"></a> - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- #### Properties <a name="Properties" id="Properties"></a> | **Name** | **Type** | **Description** | | --- | --- | --- | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.env">env</a></code> | <code>aws-cdk-lib.ResourceEnvironment</code> | The environment this resource belongs to. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.stack">stack</a></code> | <code>aws-cdk-lib.Stack</code> | The stack in which this resource is defined. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.architecture">architecture</a></code> | <code>aws-cdk-lib.aws_lambda.Architecture</code> | The architecture of this Lambda Function (this is an optional attribute and defaults to X86_64). | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.connections">connections</a></code> | <code>aws-cdk-lib.aws_ec2.Connections</code> | Access the Connections object. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.functionArn">functionArn</a></code> | <code>string</code> | ARN of this function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.functionName">functionName</a></code> | <code>string</code> | Name of this function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.grantPrincipal">grantPrincipal</a></code> | <code>aws-cdk-lib.aws_iam.IPrincipal</code> | The principal this Lambda Function is running as. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.isBoundToVpc">isBoundToVpc</a></code> | <code>boolean</code> | Whether or not this Lambda function was bound to a VPC. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.latestVersion">latestVersion</a></code> | <code>aws-cdk-lib.aws_lambda.IVersion</code> | The `$LATEST` version of this function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.permissionsNode">permissionsNode</a></code> | <code>constructs.Node</code> | The construct node where permissions are attached. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.resourceArnsForGrantInvoke">resourceArnsForGrantInvoke</a></code> | <code>string[]</code> | The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.role">role</a></code> | <code>aws-cdk-lib.aws_iam.IRole</code> | Execution role associated with this function. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.currentVersion">currentVersion</a></code> | <code>aws-cdk-lib.aws_lambda.Version</code> | Returns a `lambda.Version` which represents the current version of this Lambda function. A new version will be created every time the function's configuration changes. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.logGroup">logGroup</a></code> | <code>aws-cdk-lib.aws_logs.ILogGroup</code> | The LogGroup where the Lambda function's logs are made available. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.runtime">runtime</a></code> | <code>aws-cdk-lib.aws_lambda.Runtime</code> | The runtime configured for this lambda. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.deadLetterQueue">deadLetterQueue</a></code> | <code>aws-cdk-lib.aws_sqs.IQueue</code> | The DLQ (as queue) associated with this Lambda Function (this is an optional attribute). | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.deadLetterTopic">deadLetterTopic</a></code> | <code>aws-cdk-lib.aws_sns.ITopic</code> | The DLQ (as topic) associated with this Lambda Function (this is an optional attribute). | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.timeout">timeout</a></code> | <code>aws-cdk-lib.Duration</code> | The timeout configured for this lambda. | | <code><a href="#open-next-cdk.ImageOptimizationLambda.property.bucket">bucket</a></code> | <code>aws-cdk-lib.aws_s3.IBucket</code> | *No description.* | --- ##### `node`<sup>Required</sup> <a name="node" id="open-next-cdk.ImageOptimizationLambda.property.node"></a> ```typescript public readonly node: Node; ``` - *Type:* constructs.Node The tree node. --- ##### `env`<sup>Required</sup> <a name="env" id="open-next-cdk.ImageOptimizationLambda.property.env"></a> ```typescript public readonly env: ResourceEnvironment; ``` - *Type:* aws-cdk-lib.ResourceEnvironment The environment this resource belongs to. For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into. --- ##### `stack`<sup>Required</sup> <a name="stack" id="open-next-cdk.ImageOptimizationLambda.property.stack"></a> ```typescript public readonly stack: Stack; ``` - *Type:* aws-cdk-lib.Stack The stack in which this resource is defined. --- ##### `architecture`<sup>Required</sup> <a name="architecture" id="open-next-cdk.ImageOptimizationLambda.property.architecture"></a> ```typescript public readonly architecture: Architecture; ``` - *Type:* aws-cdk-lib.aws_lambda.Architecture The architecture of this Lambda Function (this is an optional attribute and defaults to X86_64). --- ##### `connections`<sup>Required</sup> <a name="connections" id="open-next-cdk.ImageOptimizationLambda.property.connections"></a> ```typescript public readonly connections: Connections; ``` - *Type:* aws-cdk-lib.aws_ec2.Connections Access the Connections object. Will fail if not a VPC-enabled Lambda Function --- ##### `functionArn`<sup>Required</sup> <a name="functionArn" id="open-next-cdk.ImageOptimizationLambda.property.functionArn"></a> ```typescript public readonly functionArn: string; ``` - *Type:* string ARN of this function. --- ##### `functionName`<sup>Required</sup> <a name="functionName" id="open-next-cdk.ImageOptimizationLambda.property.functionName"></a> ```typescript public readonly functionName: string; ``` - *Type:* string Name of this function. --- ##### `grantPrincipal`<sup>Required</sup> <a name="grantPrincipal" id="open-next-cdk.ImageOptimizationLambda.property.grantPrincipal"></a> ```typescript public readonly grantPrincipal: IPrincipal; ``` - *Type:* aws-cdk-lib.aws_iam.IPrincipal The principal this Lambda Function is running as. --- ##### `isBoundToVpc`<sup>Required</sup> <a name="isBoundToVpc" id="open-next-cdk.ImageOptimizationLambda.property.isBoundToVpc"></a> ```typescript public readonly isBoundToVpc: boolean; ``` - *Type:* boolean Whether or not this Lambda function was bound to a VPC. If this is is `false`, trying to access the `connections` object will fail. --- ##### `latestVersion`<sup>Required</sup> <a name="latestVersion" id="open-next-cdk.ImageOptimizationLambda.property.latestVersion"></a> ```typescript public readonly latestVersion: IVersion; ``` - *Type:* aws-cdk-lib.aws_lambda.IVersion The `$LATEST` version of this function. Note that this is reference to a non-specific AWS Lambda version, which means the function this version refers to can return different results in different invocations. To obtain a reference to an explicit version which references the current function configuration, use `lambdaFunction.currentVersion` instead. --- ##### `permissionsNode`<sup>Required</sup> <a name="permissionsNode" id="open-next-cdk.ImageOptimizationLambda.property.permissionsNode"></a> ```typescript public readonly permissionsNode: Node; ``` - *Type:* constructs.Node The construct node where permissions are attached. --- ##### `resourceArnsForGrantInvoke`<sup>Required</sup> <a name="resourceArnsForGrantInvoke" id="open-next-cdk.ImageOptimizationLambda.property.resourceArnsForGrantInvoke"></a> ```typescript public readonly resourceArnsForGrantInvoke: string[]; ``` - *Type:* string[] The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). --- ##### `role`<sup>Optional</sup> <a name="role" id="open-next-cdk.ImageOptimizationLambda.property.role"></a> ```typescript public readonly role: IRole; ``` - *Type:* aws-cdk-lib.aws_iam.IRole Execution role associated with this function. --- ##### `currentVersion`<sup>Required</sup> <a name="currentVersion" id="open-next-cdk.ImageOptimizationLambda.property.currentVersion"></a> ```typescript public readonly currentVersion: Version; ``` - *Type:* aws-cdk-lib.aws_lambda.Version Returns a `lambda.Version` which represents the current version of this Lambda function. A new version will be created every time the function's configuration changes. You can specify options for this version using the `currentVersionOptions` prop when initializing the `lambda.Function`. --- ##### `logGroup`<sup>Required</sup> <a name="logGroup" id="open-next-cdk.ImageOptimizationLambda.property.logGroup"></a> ```typescript public readonly logGroup: ILogGroup; ``` - *Type:* aws-cdk-lib.aws_logs.ILogGroup The LogGroup where the Lambda function's logs are made available. If either `logRetention` is set or this property is called, a CloudFormation custom resource is added to the stack that pre-creates the log group as part of the stack deployment, if it already doesn't exist, and sets the correct log retention period (never expire, by default). Further, if the log group already exists and the `logRetention` is not set, the custom resource will reset the log retention to never expire even if it was configured with a different value. --- ##### `runtime`<sup>Required</sup> <a name="runtime" id="open-next-cdk.ImageOptimizationLambda.property.runtime"></a> ```typescript public readonly runtime: Runtime; ``` - *Type:* aws-cdk-lib.aws_lambda.Runtime The runtime configured for this lambda. --- ##### `deadLetterQueue`<sup>Optional</sup> <a name="deadLetterQueue" id="open-next-cdk.ImageOptimizationLambda.property.deadLetterQueue"></a> ```typescript public readonly deadLetterQueue: IQueue; ``` - *Type:* aws-cdk-lib.aws_sqs.IQ