-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathruntime.ts
264 lines (221 loc) · 8.13 KB
/
runtime.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
import { BundlingDockerImage, DockerImage } from '@aws-cdk/core';
export interface LambdaRuntimeProps {
/**
* Whether the ``ZipFile`` (aka inline code) property can be used with this runtime.
* @default false
*/
readonly supportsInlineCode?: boolean;
/**
* The Docker image name to be used for bundling in this runtime.
* @default - the latest docker image "amazon/public.ecr.aws/sam/build-<runtime>" from https://gallery.ecr.aws
*/
readonly bundlingDockerImage?: string;
/**
* Whether this runtime is integrated with and supported for profiling using Amazon CodeGuru Profiler.
* @default false
*/
readonly supportsCodeGuruProfiling?: boolean;
}
export enum RuntimeFamily {
NODEJS,
JAVA,
PYTHON,
DOTNET_CORE,
GO,
RUBY,
OTHER
}
/**
* Lambda function runtime environment.
*
* If you need to use a runtime name that doesn't exist as a static member, you
* can instantiate a `Runtime` object, e.g: `new Runtime('nodejs99.99')`.
*/
export class Runtime {
/** A list of all known `Runtime`'s. */
public static readonly ALL = new Array<Runtime>();
/**
* The NodeJS runtime (nodejs)
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
*/
public static readonly NODEJS = new Runtime('nodejs', RuntimeFamily.NODEJS, { supportsInlineCode: true });
/**
* The NodeJS 4.3 runtime (nodejs4.3)
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
*/
public static readonly NODEJS_4_3 = new Runtime('nodejs4.3', RuntimeFamily.NODEJS, { supportsInlineCode: true });
/**
* The NodeJS 6.10 runtime (nodejs6.10)
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
*/
public static readonly NODEJS_6_10 = new Runtime('nodejs6.10', RuntimeFamily.NODEJS, { supportsInlineCode: true });
/**
* The NodeJS 8.10 runtime (nodejs8.10)
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
*/
public static readonly NODEJS_8_10 = new Runtime('nodejs8.10', RuntimeFamily.NODEJS, { supportsInlineCode: true });
/**
* The NodeJS 10.x runtime (nodejs10.x)
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
*/
public static readonly NODEJS_10_X = new Runtime('nodejs10.x', RuntimeFamily.NODEJS, { supportsInlineCode: true });
/**
* The NodeJS 12.x runtime (nodejs12.x)
*/
public static readonly NODEJS_12_X = new Runtime('nodejs12.x', RuntimeFamily.NODEJS, { supportsInlineCode: true });
/**
* The NodeJS 14.x runtime (nodejs14.x)
*/
public static readonly NODEJS_14_X = new Runtime('nodejs14.x', RuntimeFamily.NODEJS, { supportsInlineCode: true });
/**
* The NodeJS 16.x runtime (nodejs16.x)
*/
public static readonly NODEJS_16_X = new Runtime('nodejs16.x', RuntimeFamily.NODEJS, { supportsInlineCode: true });
/**
* The Python 2.7 runtime (python2.7)
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python runtime.
*/
public static readonly PYTHON_2_7 = new Runtime('python2.7', RuntimeFamily.PYTHON, { supportsInlineCode: true });
/**
* The Python 3.6 runtime (python3.6) (not recommended)
*
* The Python 3.6 runtime is deprecated as of July 2022.
*
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python runtime.
*/
public static readonly PYTHON_3_6 = new Runtime('python3.6', RuntimeFamily.PYTHON, {
supportsInlineCode: true,
supportsCodeGuruProfiling: true,
});
/**
* The Python 3.7 runtime (python3.7)
*/
public static readonly PYTHON_3_7 = new Runtime('python3.7', RuntimeFamily.PYTHON, {
supportsInlineCode: true,
supportsCodeGuruProfiling: true,
});
/**
* The Python 3.8 runtime (python3.8)
*/
public static readonly PYTHON_3_8 = new Runtime('python3.8', RuntimeFamily.PYTHON, {
supportsInlineCode: true,
supportsCodeGuruProfiling: true,
});
/**
* The Python 3.9 runtime (python3.9)
*/
public static readonly PYTHON_3_9 = new Runtime('python3.9', RuntimeFamily.PYTHON, {
supportsInlineCode: true,
supportsCodeGuruProfiling: true,
});
/**
* The Java 8 runtime (java8)
*/
public static readonly JAVA_8 = new Runtime('java8', RuntimeFamily.JAVA, {
supportsCodeGuruProfiling: true,
});
/**
* The Java 8 Corretto runtime (java8.al2)
*/
public static readonly JAVA_8_CORRETTO = new Runtime('java8.al2', RuntimeFamily.JAVA, {
supportsCodeGuruProfiling: true,
});
/**
* The Java 11 runtime (java11)
*/
public static readonly JAVA_11 = new Runtime('java11', RuntimeFamily.JAVA, {
supportsCodeGuruProfiling: true,
});
/**
* The .NET 6 runtime (dotnet6)
*/
public static readonly DOTNET_6 = new Runtime('dotnet6', RuntimeFamily.DOTNET_CORE);
/**
* The .NET Core 1.0 runtime (dotnetcore1.0)
* Legacy runtime no longer supported by AWS Lambda. Migrate to the latest .NET Core runtime.
*/
public static readonly DOTNET_CORE_1 = new Runtime('dotnetcore1.0', RuntimeFamily.DOTNET_CORE);
/**
* The .NET Core 2.0 runtime (dotnetcore2.0)
* Legacy runtime no longer supported by AWS Lambda. Migrate to the latest .NET Core runtime.
*/
public static readonly DOTNET_CORE_2 = new Runtime('dotnetcore2.0', RuntimeFamily.DOTNET_CORE);
/**
* The .NET Core 2.1 runtime (dotnetcore2.1)
* Legacy runtime no longer supported by AWS Lambda. Migrate to the latest .NET Core runtime.
*/
public static readonly DOTNET_CORE_2_1 = new Runtime('dotnetcore2.1', RuntimeFamily.DOTNET_CORE);
/**
* The .NET Core 3.1 runtime (dotnetcore3.1)
*/
public static readonly DOTNET_CORE_3_1 = new Runtime('dotnetcore3.1', RuntimeFamily.DOTNET_CORE);
/**
* The Go 1.x runtime (go1.x)
*/
public static readonly GO_1_X = new Runtime('go1.x', RuntimeFamily.GO);
/**
* The Ruby 2.5 runtime (ruby2.5)
* Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Ruby runtime.
*/
public static readonly RUBY_2_5 = new Runtime('ruby2.5', RuntimeFamily.RUBY);
/**
* The Ruby 2.7 runtime (ruby2.7)
*/
public static readonly RUBY_2_7 = new Runtime('ruby2.7', RuntimeFamily.RUBY);
/**
* The custom provided runtime (provided)
*/
public static readonly PROVIDED = new Runtime('provided', RuntimeFamily.OTHER);
/**
* The custom provided runtime (provided)
*/
public static readonly PROVIDED_AL2 = new Runtime('provided.al2', RuntimeFamily.OTHER);
/**
* A special runtime entry to be used when function is using a docker image.
*/
public static readonly FROM_IMAGE = new Runtime('FROM_IMAGE');
/**
* The name of this runtime, as expected by the Lambda resource.
*/
public readonly name: string;
/**
* Whether the ``ZipFile`` (aka inline code) property can be used with this
* runtime.
*/
public readonly supportsInlineCode: boolean;
/**
* Whether this runtime is integrated with and supported for profiling using Amazon CodeGuru Profiler.
*/
public readonly supportsCodeGuruProfiling: boolean;
/**
* The runtime family.
*/
public readonly family?: RuntimeFamily;
/**
* DEPRECATED
* @deprecated use `bundlingImage`
*/
public readonly bundlingDockerImage: BundlingDockerImage;
/**
* The bundling Docker image for this runtime.
*/
public readonly bundlingImage: DockerImage;
constructor(name: string, family?: RuntimeFamily, props: LambdaRuntimeProps = {}) {
this.name = name;
this.supportsInlineCode = !!props.supportsInlineCode;
this.family = family;
const imageName = props.bundlingDockerImage ?? `public.ecr.aws/sam/build-${name}`;
this.bundlingDockerImage = DockerImage.fromRegistry(imageName);
this.bundlingImage = this.bundlingDockerImage;
this.supportsCodeGuruProfiling = props.supportsCodeGuruProfiling ?? false;
Runtime.ALL.push(this);
}
public toString(): string {
return this.name;
}
public runtimeEquals(other: Runtime): boolean {
return other.name === this.name &&
other.family === this.family &&
other.supportsInlineCode === this.supportsInlineCode;
}
}