# IVersion

Extends: IVersion
Extends: IFunction, IVersionRef
Implemented by: EdgeFunction, Version

- Source: [`aws-lambda/lib/lambda-version.ts`](https://github.com/aws/aws-cdk/blob/v2.273.0/packages/aws-cdk-lib/aws-lambda/lib/lambda-version.ts#L19)
- Type last changed: v2.224.0 · 13 Nov 2025

## Properties

- `architecture`: [Architecture](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Architecture.html) (required) — The system architectures compatible with this lambda function.

- `connections`: [Connections](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) (required) — The network connections associated with this resource.

- `edgeArn`: string (required) — The ARN of the version for Lambda@Edge.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) (required) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `functionArn`: string (required) — The ARN of the function.

- `functionName`: string (required) — The name of the function.

- `functionRef`: [FunctionReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_lambda.FunctionReference.html) (required) — A reference to a Function resource.

- `grantPrincipal`: [IPrincipal](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IPrincipal.html) (required) — The principal to grant permissions to.

- `isBoundToVpc`: boolean (required) — Whether or not this Lambda function was bound to a VPC.

  If this is `false`, trying to access the `connections` object will fail.

- `lambda`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) (required) — The underlying AWS Lambda function.

- `latestVersion`: [IVersion](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IVersion.html) (required) — 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.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The tree node.

- `permissionsNode`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The construct node where permissions are attached.

- `resourceArnsForGrantInvoke`: string[] (required) — The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().

  This property is for cdk modules to consume only. You should not need to use this property.
  Instead, use grantInvoke() directly.

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The IAM role associated with this function.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) (required) — The stack in which this resource is defined.

- `tenancyConfig`: [TenancyConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.TenancyConfig.html) — The tenancy configuration for this function.

- `version`: string (required) — The most recently deployed version of this function.

- `versionRef`: [VersionReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_lambda.VersionReference.html) (required) — A reference to a Version resource.

## Methods

- `addAlias(aliasName: string, options?: AliasOptions): Alias` — Calling `addAlias` on a `Version` object will cause the Alias to be replaced on every function update. Call `function.addAlias()` or `new Alias()` instead.

  **Parameters**

  - `aliasName` — The name of the alias.
  - `options` — Alias options.

- `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));
  ```

- `addEventSourceMapping(id: string, options: EventSourceMappingOptions): EventSourceMapping` — Adds an event source that maps to this AWS Lambda function.

  **Parameters**

  - `id` — construct ID.
  - `options` — mapping options.

- `addFunctionUrl(options?: FunctionUrlOptions): FunctionUrl` — Adds a url to this lambda function.

- `addPermission(id: string, permission: Permission): void` — Adds a permission to the Lambda resource policy.

  **Parameters**

  - `id` — The id for the permission construct.
  - `permission` — The permission to grant to this Lambda function.

- `addToRolePolicy(statement: PolicyStatement): void` — Adds a statement to the IAM role assumed by the instance.

- `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`).

- `configureAsyncInvoke(options: EventInvokeConfigOptions): void` — Configures options for asynchronous invocation.

- `grantInvoke(identity: IGrantable): Grant` — Grant the given identity permissions to invoke this Lambda.

- `grantInvokeCompositePrincipal(compositePrincipal: CompositePrincipal): Grant[]` — Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.

- `grantInvokeLatestVersion(identity: IGrantable): Grant` — Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda.

- `grantInvokeUrl(identity: IGrantable): Grant` — Grant the given identity permissions to invoke this Lambda Function URL.

- `grantInvokeVersion(identity: IGrantable, version: IVersion): Grant` — Grant the given identity permissions to invoke the given version of this Lambda.

- `metric(metricName: string, props?: MetricOptions): Metric` — Return the given named metric for this Lambda Return the given named metric for this Function.

- `metricDuration(props?: MetricOptions): Metric` — Metric for the Duration of this Lambda How long execution of this Lambda takes.

  Average over 5 minutes

- `metricErrors(props?: MetricOptions): Metric` — How many invocations of this Lambda fail.

  Sum over 5 minutes

- `metricInvocations(props?: MetricOptions): Metric` — Metric for the number of invocations of this Lambda How often this Lambda is invoked.

  Sum over 5 minutes

- `metricThrottles(props?: MetricOptions): Metric` — Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.

  Sum over 5 minutes

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
