lambda-version.d.ts
1 import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; 2 import { RemovalPolicy } from '@aws-cdk/core'; 3 import { Construct } from 'constructs'; 4 import { Alias, AliasOptions } from './alias'; 5 import { EventInvokeConfigOptions } from './event-invoke-config'; 6 import { IFunction, QualifiedFunctionBase } from './function-base'; 7 /** 8 * @stability stable 9 */ 10 export interface IVersion extends IFunction { 11 /** 12 * The most recently deployed version of this function. 13 * 14 * @stability stable 15 * @attribute true 16 */ 17 readonly version: string; 18 /** 19 * The underlying AWS Lambda function. 20 * 21 * @stability stable 22 */ 23 readonly lambda: IFunction; 24 /** 25 * The ARN of the version for Lambda@Edge. 26 * 27 * @stability stable 28 */ 29 readonly edgeArn: string; 30 /** 31 * Defines an alias for this version. 32 * 33 * @param aliasName The name of the alias. 34 * @param options Alias options. 35 * @stability stable 36 */ 37 addAlias(aliasName: string, options?: AliasOptions): Alias; 38 } 39 /** 40 * Options for `lambda.Version`. 41 * 42 * @stability stable 43 */ 44 export interface VersionOptions extends EventInvokeConfigOptions { 45 /** 46 * SHA256 of the version of the Lambda source code. 47 * 48 * Specify to validate that you're deploying the right version. 49 * 50 * @default No validation is performed 51 * @stability stable 52 */ 53 readonly codeSha256?: string; 54 /** 55 * Description of the version. 56 * 57 * @default Description of the Lambda 58 * @stability stable 59 */ 60 readonly description?: string; 61 /** 62 * Specifies a provisioned concurrency configuration for a function's version. 63 * 64 * @default No provisioned concurrency 65 * @stability stable 66 */ 67 readonly provisionedConcurrentExecutions?: number; 68 /** 69 * Whether to retain old versions of this function when a new version is created. 70 * 71 * @default RemovalPolicy.DESTROY 72 * @stability stable 73 */ 74 readonly removalPolicy?: RemovalPolicy; 75 } 76 /** 77 * Properties for a new Lambda version. 78 * 79 * @stability stable 80 */ 81 export interface VersionProps extends VersionOptions { 82 /** 83 * Function to get the value of. 84 * 85 * @stability stable 86 */ 87 readonly lambda: IFunction; 88 } 89 /** 90 * @stability stable 91 */ 92 export interface VersionAttributes { 93 /** 94 * The version. 95 * 96 * @stability stable 97 */ 98 readonly version: string; 99 /** 100 * The lambda function. 101 * 102 * @stability stable 103 */ 104 readonly lambda: IFunction; 105 } 106 /** 107 * A single newly-deployed version of a Lambda function. 108 * 109 * This object exists to--at deploy time--query the "then-current" version of 110 * the Lambda function that it refers to. This Version object can then be 111 * used in `Alias` to refer to a particular deployment of a Lambda. 112 * 113 * This means that for every new update you deploy to your Lambda (using the 114 * CDK and Aliases), you must always create a new Version object. In 115 * particular, it must have a different name, so that a new resource is 116 * created. 117 * 118 * If you want to ensure that you're associating the right version with 119 * the right deployment, specify the `codeSha256` property while 120 * creating the `Version. 121 * 122 * @stability stable 123 */ 124 export declare class Version extends QualifiedFunctionBase implements IVersion { 125 /** 126 * Construct a Version object from a Version ARN. 127 * 128 * @param scope The cdk scope creating this resource. 129 * @param id The cdk id of this resource. 130 * @param versionArn The version ARN to create this version from. 131 * @stability stable 132 */ 133 static fromVersionArn(scope: Construct, id: string, versionArn: string): IVersion; 134 /** 135 * @stability stable 136 */ 137 static fromVersionAttributes(scope: Construct, id: string, attrs: VersionAttributes): IVersion; 138 /** 139 * The most recently deployed version of this function. 140 * 141 * @stability stable 142 */ 143 readonly version: string; 144 /** 145 * The underlying AWS Lambda function. 146 * 147 * @stability stable 148 */ 149 readonly lambda: IFunction; 150 /** 151 * The ARN fo the function. 152 * 153 * @stability stable 154 */ 155 readonly functionArn: string; 156 /** 157 * The name of the function. 158 * 159 * @stability stable 160 */ 161 readonly functionName: string; 162 /** 163 * The qualifier of the version or alias of this function. 164 * 165 * A qualifier is the identifier that's appended to a version or alias ARN. 166 * 167 * @stability stable 168 */ 169 protected readonly qualifier: string; 170 /** 171 * Whether the addPermission() call adds any permissions. 172 * 173 * True for new Lambdas, false for version $LATEST and imported Lambdas 174 * from different accounts. 175 * 176 * @stability stable 177 */ 178 protected readonly canCreatePermissions = true; 179 /** 180 * @stability stable 181 */ 182 constructor(scope: Construct, id: string, props: VersionProps); 183 /** 184 * The principal this Lambda Function is running as. 185 * 186 * @stability stable 187 */ 188 get grantPrincipal(): import("@aws-cdk/aws-iam").IPrincipal; 189 /** 190 * The IAM role associated with this function. 191 * 192 * Undefined if the function was imported without a role. 193 * 194 * @stability stable 195 */ 196 get role(): import("@aws-cdk/aws-iam").IRole | undefined; 197 /** 198 * Return the given named metric for this Function. 199 * 200 * @stability stable 201 */ 202 metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric; 203 /** 204 * Defines an alias for this version. 205 * 206 * @param aliasName The name of the alias (e.g. "live"). 207 * @param options Alias options. 208 * @stability stable 209 */ 210 addAlias(aliasName: string, options?: AliasOptions): Alias; 211 /** 212 * The ARN of the version for Lambda@Edge. 213 * 214 * @stability stable 215 */ 216 get edgeArn(): string; 217 /** 218 * Validate that the provisionedConcurrentExecutions makes sense 219 * 220 * Member must have value greater than or equal to 1 221 */ 222 private determineProvisionedConcurrency; 223 } 224 /** 225 * Given an opaque (token) ARN, returns a CloudFormation expression that extracts the 226 * qualifier (= version or alias) from the ARN. 227 * 228 * Version ARNs look like this: 229 * 230 * arn:aws:lambda:region:account-id:function:function-name:qualifier 231 * 232 * ..which means that in order to extract the `qualifier` component from the ARN, we can 233 * split the ARN using ":" and select the component in index 7. 234 * 235 * @returns `FnSelect(7, FnSplit(':', arn))` 236 */ 237 export declare function extractQualifierFromArn(arn: string): string;