# Alias

A new alias to a particular version of a Lambda function.

Extends: Construct › Resource › FunctionBase › QualifiedFunctionBase › Alias
Implements: IResource, IClientVpnConnectionHandler, IConnectable, IGrantable, IAlias, IFunction, IEnvironmentAware, IAliasRef, IFunctionRef, IConstruct, IDependable

- CloudFormation: [`AWS::Lambda::Alias`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-lambda-alias.html)
- L1 type: [`CfnAlias`](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.CfnAlias.html)
- Source: [`aws-lambda/lib/alias.ts`](https://github.com/aws/aws-cdk/blob/v2.273.0/packages/aws-cdk-lib/aws-lambda/lib/alias.ts#L99)
- Type last changed: v2.224.0 · 13 Nov 2025

## Example

```ts
const lambdaCode = lambda.Code.fromCfnParameters();
const func = new lambda.Function(this, 'Lambda', {
  code: lambdaCode,
  handler: 'index.handler',
  runtime: lambda.Runtime.NODEJS_LATEST,
});
// used to make sure each CDK synthesis produces a different Version
const version = func.currentVersion;
const alias = new lambda.Alias(this, 'LambdaAlias', {
  aliasName: 'Prod',
  version,
});

new codedeploy.LambdaDeploymentGroup(this, 'DeploymentGroup', {
  alias,
  deploymentConfig: codedeploy.LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
});
```

## Initializer

```ts
new Alias(scope: Construct, id: string, props: AliasProps)
```

## Construct Props

- `additionalVersions`: [VersionWeight](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.VersionWeight.html)[] = No additional versions — Additional versions with individual weights this alias points to.

  Individual additional version weights specified here should add up to
  (less than) one. All remaining weight is routed to the default
  version.

  For example, the config is

     version: "1"
     additionalVersions: [{ version: "2", weight: 0.05 }]

  Then 5% of traffic will be routed to function version 2, while
  the remaining 95% of traffic will be routed to function version 1.

- `aliasName`: string (required) — Name of this alias.

- `description`: string = No description — Description for the alias.

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

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

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

  Minimum: 0
  Maximum: 2

- `version`: [IVersion](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IVersion.html) (required) — Function version this alias refers to.

  Use lambda.currentVersion to reference a version with your latest changes.

## Properties

- `aliasName`: string (required) — Name of this alias.

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

- `architecture`: [Architecture](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Architecture.html) (required) — The architecture of this Lambda Function.

- `connections`: [Connections](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) (required) — Access the Connections object.

  Will fail if not a VPC-enabled Lambda Function

- `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) — ARN of this alias.

  Used to be able to use Alias in place of a regular Lambda. Lambda accepts
  ARNs everywhere it accepts function names.

- `functionName`: string (required) — ARN of this alias.

  Used to be able to use Alias in place of a regular Lambda. Lambda accepts
  ARNs everywhere it accepts function names.

- `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 this Lambda Function is running as.

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

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

- `PROPERTY_INJECTION_ID`: string (required) (static) — Uniquely identifies this class.

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

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

  Undefined if the function was imported without a role.

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

## Methods

- `addAutoScaling(options: AutoScalingOptions): IScalableFunctionAttribute` — Configure provisioned concurrency autoscaling on a function alias.

  Returns a scalable attribute that can call
  `scaleOnUtilization()` and `scaleOnSchedule()`.

  **Parameters**

  - `options` — Autoscaling 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.

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

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

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

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

- `fromAliasAttributes(scope: Construct, id: string, attrs: AliasAttributes): IAlias` (static)

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

  [disable-awslint:no-grants]

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

  [disable-awslint:no-grants]

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

  [disable-awslint:no-grants]

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

  [disable-awslint:no-grants]

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

  [disable-awslint:no-grants]

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

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

- `metricDuration(props?: MetricOptions): Metric` — 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` — How often this Lambda is invoked.

  Sum over 5 minutes

- `metricThrottles(props?: MetricOptions): Metric` — How often this Lambda is throttled.

  Sum over 5 minutes

- `toString(): string` — Returns a string representation of this construct.

- `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.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
