sst 2.22.2 → 2.22.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,12 +23,24 @@ export interface JobContainerProps {
23
23
  cmd: string[];
24
24
  }
25
25
  export interface JobProps {
26
+ /**
27
+ * The CPU architecture of the job.
28
+ * @default "x86_64"
29
+ * @example
30
+ * ```js
31
+ * new Job(stack, "MyJob", {
32
+ * architecture: "arm_64",
33
+ * handler: "src/job.handler",
34
+ * })
35
+ * ```
36
+ */
37
+ architecture?: "x86_64" | "arm_64";
26
38
  /**
27
39
  * The runtime environment for the job.
28
40
  * @default "nodejs"
29
41
  * @example
30
42
  * ```js
31
- * new Function(stack, "Function", {
43
+ * new Job(stack, "MyJob", {
32
44
  * runtime: "container",
33
45
  * handler: "src/job",
34
46
  * })
@@ -295,6 +307,7 @@ export declare class Job extends Construct implements SSTConstruct {
295
307
  private attachPermissionsForCodeBuild;
296
308
  private addEnvironmentForCodeBuild;
297
309
  private validateContainerProps;
310
+ private validateMemoryProps;
298
311
  private normalizeMemorySize;
299
312
  private normalizeTimeout;
300
313
  private convertJobRuntimeToFunctionRuntime;
package/constructs/Job.js CHANGED
@@ -48,6 +48,7 @@ export class Job extends Construct {
48
48
  this.props = props;
49
49
  const isLiveDevEnabled = app.mode === "dev" && (this.props.enableLiveDev === false ? false : true);
50
50
  this.validateContainerProps();
51
+ this.validateMemoryProps();
51
52
  this.job = this.createCodeBuildJob();
52
53
  if (!stack.isActive) {
53
54
  this._jobManager = this.createJobManager();
@@ -191,7 +192,7 @@ export class Job extends Construct {
191
192
  });
192
193
  }
193
194
  buildCodeBuildProjectCode() {
194
- const { handler, runtime, container } = this.props;
195
+ const { handler, architecture, runtime, container } = this.props;
195
196
  useDeferredTasks().add(async () => {
196
197
  // Build function
197
198
  const result = await useRuntimeHandlers().build(this.node.addr, "deploy");
@@ -205,12 +206,15 @@ export class Job extends Construct {
205
206
  if (runtime === "container") {
206
207
  const image = LinuxBuildImage.fromAsset(this, "ContainerImage", {
207
208
  directory: handler,
208
- platform: Platform.custom("linux/amd64"),
209
+ platform: architecture === "arm_64"
210
+ ? Platform.custom("linux/arm64")
211
+ : Platform.custom("linux/amd64"),
209
212
  });
210
213
  image.repository?.grantPull(this.job.role);
211
214
  const project = this.job.node.defaultChild;
212
215
  project.environment = {
213
216
  ...project.environment,
217
+ type: architecture === "arm_64" ? "ARM_CONTAINER" : "LINUX_CONTAINER",
214
218
  image: image.imageId,
215
219
  imagePullCredentialsType: "SERVICE_ROLE",
216
220
  };
@@ -259,9 +263,14 @@ export class Job extends Construct {
259
263
  const code = AssetCode.fromAsset(result.out);
260
264
  const codeConfig = code.bind(this);
261
265
  const project = this.job.node.defaultChild;
262
- const image = LinuxBuildImage.fromDockerRegistry("amazon/aws-lambda-nodejs:16");
266
+ const image = LinuxBuildImage.fromDockerRegistry(
267
+ // ARM images can be found here https://hub.docker.com/r/amazon/aws-lambda-nodejs
268
+ architecture === "arm_64"
269
+ ? "amazon/aws-lambda-nodejs:16.2023.07.13.14"
270
+ : "amazon/aws-lambda-nodejs:16");
263
271
  project.environment = {
264
272
  ...project.environment,
273
+ type: architecture === "arm_64" ? "ARM_CONTAINER" : "LINUX_CONTAINER",
265
274
  image: image.imageId,
266
275
  };
267
276
  image.repository?.grantPull(this.job.role);
@@ -351,6 +360,14 @@ export class Job extends Construct {
351
360
  }
352
361
  }
353
362
  }
363
+ validateMemoryProps() {
364
+ const { architecture, memorySize } = this.props;
365
+ if (architecture === "arm_64") {
366
+ if (memorySize === "7 GB" || memorySize === "145 GB") {
367
+ throw new Error(`ARM architecture only supports "3 GB" and "15 GB" memory sizes for the ${this.node.id} Job.`);
368
+ }
369
+ }
370
+ }
354
371
  normalizeMemorySize(memorySize) {
355
372
  if (memorySize === "3 GB") {
356
373
  return ComputeType.SMALL;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.22.2",
4
+ "version": "2.22.3",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },