aws-cdk-lib.aws_lambda.IVersion

interface IVersion

LanguageType name
.NETAmazon.CDK.AWS.Lambda.IVersion
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslambda#IVersion
Javasoftware.amazon.awscdk.services.lambda.IVersion
Pythonaws_cdk.aws_lambda.IVersion
TypeScript (source)aws-cdk-lib » aws_lambda » IVersion

Implemented by EdgeFunction, Version

Obtainable from Version.fromVersionArn(), Version.fromVersionAttributes()

Properties

NameTypeDescription
architectureArchitectureThe system architectures compatible with this lambda function.
connectionsConnectionsThe network connections associated with this resource.
edgeArnstringThe ARN of the version for Lambda@Edge.
envResourceEnvironmentThe environment this resource belongs to.
functionArnstringThe ARN of the function.
functionNamestringThe name of the function.
grantPrincipalIPrincipalThe principal to grant permissions to.
isBoundToVpcbooleanWhether or not this Lambda function was bound to a VPC.
lambdaIFunctionThe underlying AWS Lambda function.
latestVersionIVersionThe $LATEST version of this function.
nodeNodeThe tree node.
permissionsNodeNodeThe construct node where permissions are attached.
resourceArnsForGrantInvokestring[]The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
stackStackThe stack in which this resource is defined.
versionstringThe most recently deployed version of this function.
role?IRoleThe IAM role associated with this function.

architecture

Type: Architecture

The system architectures compatible with this lambda function.


connections

Type: Connections

The network connections associated with this resource.


edgeArn

Type: string

The ARN of the version for Lambda@Edge.


env

Type: 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.


functionArn

Type: string

The ARN of the function.


functionName

Type: string

The name of the function.


grantPrincipal

Type: IPrincipal

The principal to grant permissions to.


isBoundToVpc

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.


lambda

Type: IFunction

The underlying AWS Lambda function.


latestVersion

Type: 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.


node

Type: Node

The tree node.


permissionsNode

Type: Node

The construct node where permissions are attached.


resourceArnsForGrantInvoke

Type: string[]

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.


stack

Type: Stack

The stack in which this resource is defined.


version

Type: string

The most recently deployed version of this function.


role?

Type: IRole (optional)

The IAM role associated with this function.

Methods

NameDescription
addAlias(aliasName, options?)⚠️Defines an alias for this version.
addEventSource(source)Adds an event source to this function.
addEventSourceMapping(id, options)Adds an event source that maps to this AWS Lambda function.
addFunctionUrl(options?)Adds a url to this lambda function.
addPermission(id, permission)Adds a permission to the Lambda resource policy.
addToRolePolicy(statement)Adds a statement to the IAM role assumed by the instance.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
configureAsyncInvoke(options)Configures options for asynchronous invocation.
grantInvoke(identity)Grant the given identity permissions to invoke this Lambda.
grantInvokeUrl(identity)Grant the given identity permissions to invoke this Lambda Function URL.
metric(metricName, props?)Return the given named metric for this Lambda Return the given named metric for this Function.
metricDuration(props?)Metric for the Duration of this Lambda How long execution of this Lambda takes.
metricErrors(props?)How many invocations of this Lambda fail.
metricInvocations(props?)Metric for the number of invocations of this Lambda How often this Lambda is invoked.
metricThrottles(props?)Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.

addAlias(aliasName, options?)⚠️

public addAlias(aliasName: string, options?: AliasOptions): Alias

⚠️ Deprecated: 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 string — The name of the alias.
  • options AliasOptions — Alias options.

Returns

  • Alias

Defines an alias for this version.


addEventSource(source)

public addEventSource(source: IEventSource): void

Parameters

  • source IEventSource

Adds an event source to this function.

Event sources are implemented in the @aws-cdk/aws-lambda-event-sources module.

The following example adds an SQS Queue as an event source:

import { SqsEventSource } from '@aws-cdk/aws-lambda-event-sources';
myFunction.addEventSource(new SqsEventSource(myQueue));

addEventSourceMapping(id, options)

public addEventSourceMapping(id: string, options: EventSourceMappingOptions): EventSourceMapping

Parameters

  • id string — construct ID.
  • options EventSourceMappingOptions — mapping options.

Returns

  • EventSourceMapping

Adds an event source that maps to this AWS Lambda function.


addFunctionUrl(options?)

public addFunctionUrl(options?: FunctionUrlOptions): FunctionUrl

Parameters

  • options FunctionUrlOptions

Returns

  • FunctionUrl

Adds a url to this lambda function.


addPermission(id, permission)

public addPermission(id: string, permission: Permission): void

Parameters

  • id string — The id for the permission construct.
  • permission Permission — The permission to grant to this Lambda function.

Adds a permission to the Lambda resource policy.

See also: [Permission for details.](Permission for details.)


addToRolePolicy(statement)

public addToRolePolicy(statement: PolicyStatement): void

Parameters

  • statement PolicyStatement

Adds a statement to the IAM role assumed by the instance.


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

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)

public configureAsyncInvoke(options: EventInvokeConfigOptions): void

Parameters

  • options EventInvokeConfigOptions

Configures options for asynchronous invocation.


grantInvoke(identity)

public grantInvoke(identity: IGrantable): Grant

Parameters

  • identity IGrantable

Returns

  • Grant

Grant the given identity permissions to invoke this Lambda.


grantInvokeUrl(identity)

public grantInvokeUrl(identity: IGrantable): Grant

Parameters

  • identity IGrantable

Returns

  • Grant

Grant the given identity permissions to invoke this Lambda Function URL.


metric(metricName, props?)

public metric(metricName: string, props?: MetricOptions): Metric

Parameters

  • metricName string
  • props MetricOptions

Returns

  • Metric

Return the given named metric for this Lambda Return the given named metric for this Function.


metricDuration(props?)

public metricDuration(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Metric for the Duration of this Lambda How long execution of this Lambda takes.

Average over 5 minutes


metricErrors(props?)

public metricErrors(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

How many invocations of this Lambda fail.

Sum over 5 minutes


metricInvocations(props?)

public metricInvocations(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Metric for the number of invocations of this Lambda How often this Lambda is invoked.

Sum over 5 minutes


metricThrottles(props?)

public metricThrottles(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.

Sum over 5 minutes