UNPKG

4.61 kBTypeScriptView Raw
1import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
2import * as iam from '@aws-cdk/aws-iam';
3import { Construct } from 'constructs';
4import { Architecture } from './architecture';
5import { EventInvokeConfigOptions } from './event-invoke-config';
6import { IFunction, QualifiedFunctionBase } from './function-base';
7import { IVersion } from './lambda-version';
8import { AutoScalingOptions, IScalableFunctionAttribute } from './scalable-attribute-api';
9export interface IAlias extends IFunction {
10 /**
11 * Name of this alias.
12 *
13 * @attribute
14 */
15 readonly aliasName: string;
16 /**
17 * The underlying Lambda function version.
18 */
19 readonly version: IVersion;
20}
21/**
22 * Options for `lambda.Alias`.
23 */
24export interface AliasOptions extends EventInvokeConfigOptions {
25 /**
26 * Description for the alias
27 *
28 * @default No description
29 */
30 readonly description?: string;
31 /**
32 * Additional versions with individual weights this alias points to
33 *
34 * Individual additional version weights specified here should add up to
35 * (less than) one. All remaining weight is routed to the default
36 * version.
37 *
38 * For example, the config is
39 *
40 * version: "1"
41 * additionalVersions: [{ version: "2", weight: 0.05 }]
42 *
43 * Then 5% of traffic will be routed to function version 2, while
44 * the remaining 95% of traffic will be routed to function version 1.
45 *
46 * @default No additional versions
47 */
48 readonly additionalVersions?: VersionWeight[];
49 /**
50 * Specifies a provisioned concurrency configuration for a function's alias.
51 *
52 * @default No provisioned concurrency
53 */
54 readonly provisionedConcurrentExecutions?: number;
55}
56/**
57 * Properties for a new Lambda alias
58 */
59export interface AliasProps extends AliasOptions {
60 /**
61 * Name of this alias
62 */
63 readonly aliasName: string;
64 /**
65 * Function version this alias refers to
66 *
67 * Use lambda.currentVersion to reference a version with your latest changes.
68 */
69 readonly version: IVersion;
70}
71export interface AliasAttributes {
72 readonly aliasName: string;
73 readonly aliasVersion: IVersion;
74}
75/**
76 * A new alias to a particular version of a Lambda function.
77 */
78export declare class Alias extends QualifiedFunctionBase implements IAlias {
79 static fromAliasAttributes(scope: Construct, id: string, attrs: AliasAttributes): IAlias;
80 /**
81 * Name of this alias.
82 *
83 * @attribute
84 */
85 readonly aliasName: string;
86 /**
87 * ARN of this alias
88 *
89 * Used to be able to use Alias in place of a regular Lambda. Lambda accepts
90 * ARNs everywhere it accepts function names.
91 */
92 readonly functionName: string;
93 readonly lambda: IFunction;
94 readonly architecture: Architecture;
95 readonly version: IVersion;
96 /**
97 * ARN of this alias
98 *
99 * Used to be able to use Alias in place of a regular Lambda. Lambda accepts
100 * ARNs everywhere it accepts function names.
101 */
102 readonly functionArn: string;
103 protected readonly qualifier: string;
104 protected readonly canCreatePermissions: boolean;
105 private scalableAlias?;
106 private readonly scalingRole;
107 constructor(scope: Construct, id: string, props: AliasProps);
108 get grantPrincipal(): iam.IPrincipal;
109 get role(): iam.IRole | undefined;
110 metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
111 /**
112 * Configure provisioned concurrency autoscaling on a function alias. Returns a scalable attribute that can call
113 * `scaleOnUtilization()` and `scaleOnSchedule()`.
114 *
115 * @param options Autoscaling options
116 */
117 addAutoScaling(options: AutoScalingOptions): IScalableFunctionAttribute;
118 /**
119 * Calculate the routingConfig parameter from the input props
120 */
121 private determineRoutingConfig;
122 /**
123 * Validate that the additional version weights make sense
124 *
125 * We validate that they are positive and add up to something <= 1.
126 */
127 private validateAdditionalWeights;
128 /**
129 * Validate that the provisionedConcurrentExecutions makes sense
130 *
131 * Member must have value greater than or equal to 1
132 */
133 private determineProvisionedConcurrency;
134}
135/**
136 * A version/weight pair for routing traffic to Lambda functions
137 */
138export interface VersionWeight {
139 /**
140 * The version to route traffic to
141 */
142 readonly version: IVersion;
143 /**
144 * How much weight to assign to this version (0..1)
145 */
146 readonly weight: number;
147}