UNPKG

5.31 kBTypeScriptView Raw
1import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
2import { RemovalPolicy } from '@aws-cdk/core';
3import { Construct } from 'constructs';
4import { Alias, AliasOptions } from './alias';
5import { Architecture } from './architecture';
6import { EventInvokeConfigOptions } from './event-invoke-config';
7import { IFunction, QualifiedFunctionBase } from './function-base';
8export interface IVersion extends IFunction {
9 /**
10 * The most recently deployed version of this function.
11 * @attribute
12 */
13 readonly version: string;
14 /**
15 * The underlying AWS Lambda function.
16 */
17 readonly lambda: IFunction;
18 /**
19 * The ARN of the version for Lambda@Edge.
20 */
21 readonly edgeArn: string;
22 /**
23 * Defines an alias for this version.
24 * @param aliasName The name of the alias
25 * @param options Alias options
26 *
27 * @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.
28 */
29 addAlias(aliasName: string, options?: AliasOptions): Alias;
30}
31/**
32 * Options for `lambda.Version`
33 */
34export interface VersionOptions extends EventInvokeConfigOptions {
35 /**
36 * SHA256 of the version of the Lambda source code
37 *
38 * Specify to validate that you're deploying the right version.
39 *
40 * @default No validation is performed
41 */
42 readonly codeSha256?: string;
43 /**
44 * Description of the version
45 *
46 * @default Description of the Lambda
47 */
48 readonly description?: string;
49 /**
50 * Specifies a provisioned concurrency configuration for a function's version.
51 *
52 * @default No provisioned concurrency
53 */
54 readonly provisionedConcurrentExecutions?: number;
55 /**
56 * Whether to retain old versions of this function when a new version is
57 * created.
58 *
59 * @default RemovalPolicy.DESTROY
60 */
61 readonly removalPolicy?: RemovalPolicy;
62}
63/**
64 * Properties for a new Lambda version
65 */
66export interface VersionProps extends VersionOptions {
67 /**
68 * Function to get the value of
69 */
70 readonly lambda: IFunction;
71}
72export interface VersionAttributes {
73 /**
74 * The version.
75 */
76 readonly version: string;
77 /**
78 * The lambda function.
79 */
80 readonly lambda: IFunction;
81}
82/**
83 * Tag the current state of a Function with a Version number
84 *
85 * Avoid using this resource directly. If you need a Version object, use
86 * `function.currentVersion` instead. That will add a Version object to your
87 * template, and make sure the Version is invalidated whenever the Function
88 * object changes. If you use the `Version` resource directly, you are
89 * responsible for making sure it is invalidated (by changing its
90 * logical ID) whenever necessary.
91 *
92 * Version resources can then be used in `Alias` resources to refer to a
93 * particular deployment of a Lambda.
94 *
95 * If you want to ensure that you're associating the right version with
96 * the right deployment, specify the `codeSha256` property while
97 * creating the `Version.
98 */
99export declare class Version extends QualifiedFunctionBase implements IVersion {
100 /**
101 * Construct a Version object from a Version ARN.
102 *
103 * @param scope The cdk scope creating this resource
104 * @param id The cdk id of this resource
105 * @param versionArn The version ARN to create this version from
106 */
107 static fromVersionArn(scope: Construct, id: string, versionArn: string): IVersion;
108 static fromVersionAttributes(scope: Construct, id: string, attrs: VersionAttributes): IVersion;
109 readonly version: string;
110 readonly lambda: IFunction;
111 readonly functionArn: string;
112 readonly functionName: string;
113 readonly architecture: Architecture;
114 protected readonly qualifier: string;
115 protected readonly canCreatePermissions = true;
116 constructor(scope: Construct, id: string, props: VersionProps);
117 get grantPrincipal(): import("@aws-cdk/aws-iam").IPrincipal;
118 get role(): import("@aws-cdk/aws-iam").IRole | undefined;
119 metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
120 /**
121 * Defines an alias for this version.
122 * @param aliasName The name of the alias (e.g. "live")
123 * @param options Alias options
124 * @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.
125 */
126 addAlias(aliasName: string, options?: AliasOptions): Alias;
127 get edgeArn(): string;
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 * Given an opaque (token) ARN, returns a CloudFormation expression that extracts the
137 * qualifier (= version or alias) from the ARN.
138 *
139 * Version ARNs look like this:
140 *
141 * arn:aws:lambda:region:account-id:function:function-name:qualifier
142 *
143 * ..which means that in order to extract the `qualifier` component from the ARN, we can
144 * split the ARN using ":" and select the component in index 7.
145 *
146 * @returns `FnSelect(7, FnSplit(':', arn))`
147 */
148export declare function extractQualifierFromArn(arn: string): string;