# AliasProps

Properties for a new Lambda alias.

Extends: [AliasOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.AliasOptions.html)
Used as props by: [Alias](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Alias.html)

- Source: [`aws-lambda/lib/alias.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-lambda/lib/alias.ts#L77)

## Example

TypeScript:

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

Python:

```python
lambda_code = lambda_.Code.from_cfn_parameters()
func = lambda_.Function(self, "Lambda",
    code=lambda_code,
    handler="index.handler",
    runtime=lambda_.Runtime.NODEJS_LATEST
)
# used to make sure each CDK synthesis produces a different Version
version = func.current_version
alias = lambda_.Alias(self, "LambdaAlias",
    alias_name="Prod",
    version=version
)

codedeploy.LambdaDeploymentGroup(self, "DeploymentGroup",
    alias=alias,
    deployment_config=codedeploy.LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE
)
```

Java:

```java
CfnParametersCode lambdaCode = Code.fromCfnParameters();
Function func = Function.Builder.create(this, "Lambda")
        .code(lambdaCode)
        .handler("index.handler")
        .runtime(Runtime.NODEJS_LATEST)
        .build();
// used to make sure each CDK synthesis produces a different Version
Version version = func.getCurrentVersion();
Alias alias = Alias.Builder.create(this, "LambdaAlias")
        .aliasName("Prod")
        .version(version)
        .build();

LambdaDeploymentGroup.Builder.create(this, "DeploymentGroup")
        .alias(alias)
        .deploymentConfig(LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var lambdaCode = Code.FromCfnParameters();
var func = new Function(this, "Lambda", new FunctionProps {
    Code = lambdaCode,
    Handler = "index.handler",
    Runtime = Runtime.NODEJS_LATEST
});
// used to make sure each CDK synthesis produces a different Version
var version = func.CurrentVersion;
var alias = new Alias(this, "LambdaAlias", new AliasProps {
    AliasName = "Prod",
    Version = version
});

new LambdaDeploymentGroup(this, "DeploymentGroup", new LambdaDeploymentGroupProps {
    Alias = alias,
    DeploymentConfig = LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
lambdaCode := lambda.Code_FromCfnParameters()
func := lambda.NewFunction(this, jsii.String("Lambda"), &FunctionProps{
	Code: lambdaCode,
	Handler: jsii.String("index.handler"),
	Runtime: lambda.Runtime_NODEJS_LATEST(),
})
// used to make sure each CDK synthesis produces a different Version
version := func.currentVersion
alias := lambda.NewAlias(this, jsii.String("LambdaAlias"), &AliasProps{
	AliasName: jsii.String("Prod"),
	Version: Version,
})

codedeploy.NewLambdaDeploymentGroup(this, jsii.String("DeploymentGroup"), &LambdaDeploymentGroupProps{
	Alias: Alias,
	DeploymentConfig: codedeploy.LambdaDeploymentConfig_LINEAR_10PERCENT_EVERY_1MINUTE(),
})
```

## Properties

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

  **Default:** No additional versions

  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 — Description for the alias.

  **Default:** No description

- `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) — The destination for failed invocations.

  **Default:** no destination

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

  **Default:** no destination

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

  **Default:** No provisioned concurrency

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