UNPKG

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