import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { FunctionName, FunctionRef } from './lambda-ref'; import { FunctionVersion } from './lambda-version'; import { FunctionArn } from './lambda.generated'; import { Permission } from './permission'; /** * Properties for a new Lambda alias */ export interface AliasProps { /** * Description for the alias * * @default No description */ description?: string; /** * Function version this alias refers to * * Use lambda.addVersion() to obtain a new lambda version to refer to. */ version: FunctionVersion; /** * Name of this alias */ aliasName: string; /** * 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. * * @default No additional versions */ additionalVersions?: VersionWeight[]; } /** * A new alias to a particular version of a Lambda function. */ export declare class Alias extends FunctionRef { /** * 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. */ readonly functionName: FunctionName; /** * 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. */ readonly functionArn: FunctionArn; /** * Role associated with this alias */ readonly role?: iam.Role | undefined; protected readonly canCreatePermissions: boolean; /** * The actual Lambda function object that this Alias is pointing to */ private readonly underlyingLambda; constructor(parent: cdk.Construct, name: string, props: AliasProps); addPermission(name: string, permission: Permission): void; /** * Calculate the routingConfig parameter from the input props */ private determineRoutingConfig; /** * Validate that the additional version weights make sense * * We validate that they are positive and add up to something <= 1. */ private validateAdditionalWeights; } /** * A version/weight pair for routing traffic to Lambda functions */ export interface VersionWeight { /** * The version to route traffic to */ readonly version: FunctionVersion; /** * How much weight to assign to this version (0..1) */ readonly weight: number; }