# VersionOptions

Options for `lambda.Version`.

Extends: VersionOptions
Extends: EventInvokeConfigOptions

- Source: [`aws-lambda/lib/lambda-version.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-lambda/lib/lambda-version.ts#L49)
- Type last changed: v2.231.0 · 1 Dec 2025

## Example

```ts
const fn = new lambda.Function(this, 'MyFunction', {
  currentVersionOptions: {
    removalPolicy: RemovalPolicy.RETAIN, // retain old versions
    retryAttempts: 1,                   // async retry attempts
  },
  runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});

fn.addAlias('live');
```

## Properties

- `codeSha256`: string = No validation is performed — SHA256 of the version of the Lambda source code.

  Specify to validate that you're deploying the right version.

- `description`: string = Description of the Lambda — Description of the version.

- `maxEventAge`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.hours(6) — The maximum age of a request that Lambda sends to a function for processing.

  Minimum: 60 seconds
  Maximum: 6 hours

- `maxExecutionEnvironments`: number = No maximum specified — The maximum number of execution environments allowed for this version when published into a capacity provider.

  This setting limits the total number of execution environments that can be created
  to handle concurrent invocations of this specific version.

- `minExecutionEnvironments`: number = 3 execution environments are set to be the minimum — The minimum number of execution environments to maintain for this version when published into a capacity provider.

  This setting ensures that at least this many execution environments are always
  available to handle function invocations for this specific version, reducing cold start latency.

  **Default:** 3 execution environments are set to be the minimum

- `onFailure`: [IDestination](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IDestination.html) = no destination — The destination for failed invocations.

- `onSuccess`: [IDestination](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IDestination.html) = no destination — The destination for successful invocations.

- `provisionedConcurrentExecutions`: number = No provisioned concurrency — Specifies a provisioned concurrency configuration for a function's version.

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.DESTROY — Whether to retain old versions of this function when a new version is created.

- `retryAttempts`: number = 2 — The maximum number of times to retry when the function returns an error.

  Minimum: 0
  Maximum: 2
