sst 2.22.1 → 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.
@@ -91,7 +91,7 @@ export const deploy = (program) => program.command("deploy [filter]", "Deploy yo
91
91
  printDeploymentResults(assembly, results);
92
92
  if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
93
93
  process.exit(1);
94
- fs.writeFile(path.join(project.paths.out, "outputs.json"), JSON.stringify(mapValues(results, (val) => val.outputs), null, 2));
94
+ fs.writeFile(project.config.outputs || path.join(project.paths.out, "outputs.json"), JSON.stringify(mapValues(results, (val) => val.outputs), null, 2));
95
95
  // Update app state
96
96
  await saveAppMetadata({ mode: "deploy" });
97
97
  process.exit(0);
@@ -232,7 +232,8 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
232
232
  }
233
233
  lastDeployed = nextChecksum;
234
234
  // Write outputs.json
235
- fs.writeFile(path.join(project.paths.out, "outputs.json"), JSON.stringify(mapValues(results, (val) => val.outputs), null, 2));
235
+ fs.writeFile(project.config.outputs ||
236
+ path.join(project.paths.out, "outputs.json"), JSON.stringify(mapValues(results, (val) => val.outputs), null, 2));
236
237
  isWorking = false;
237
238
  if (isDirty)
238
239
  build();
@@ -228,4 +228,5 @@ export declare class Cognito extends Construct implements SSTConstruct {
228
228
  private createAuthRole;
229
229
  private createUnauthRole;
230
230
  private buildSignInAliases;
231
+ private cognitoIdentityName;
231
232
  }
@@ -310,13 +310,14 @@ export class Cognito extends Construct {
310
310
  return lambda;
311
311
  }
312
312
  createAuthRole(identityPool) {
313
+ const identityName = this.cognitoIdentityName();
313
314
  const role = new Role(this, "IdentityPoolAuthRole", {
314
- assumedBy: new FederatedPrincipal("cognito-identity.amazonaws.com", {
315
+ assumedBy: new FederatedPrincipal(identityName, {
315
316
  StringEquals: {
316
- "cognito-identity.amazonaws.com:aud": identityPool.ref,
317
+ [`${identityName}:aud`]: identityPool.ref,
317
318
  },
318
319
  "ForAnyValue:StringLike": {
319
- "cognito-identity.amazonaws.com:amr": "authenticated",
320
+ [`${identityName}:amr`]: "authenticated",
320
321
  },
321
322
  }, "sts:AssumeRoleWithWebIdentity"),
322
323
  });
@@ -332,13 +333,14 @@ export class Cognito extends Construct {
332
333
  return role;
333
334
  }
334
335
  createUnauthRole(identityPool) {
336
+ const identityName = this.cognitoIdentityName();
335
337
  const role = new Role(this, "IdentityPoolUnauthRole", {
336
- assumedBy: new FederatedPrincipal("cognito-identity.amazonaws.com", {
338
+ assumedBy: new FederatedPrincipal(identityName, {
337
339
  StringEquals: {
338
- "cognito-identity.amazonaws.com:aud": identityPool.ref,
340
+ [`${identityName}:aud`]: identityPool.ref,
339
341
  },
340
342
  "ForAnyValue:StringLike": {
341
- "cognito-identity.amazonaws.com:amr": "unauthenticated",
343
+ [`${identityName}:amr`]: "unauthenticated",
342
344
  },
343
345
  }, "sts:AssumeRoleWithWebIdentity"),
344
346
  });
@@ -360,4 +362,9 @@ export class Cognito extends Construct {
360
362
  preferredUsername: login.includes("preferredUsername"),
361
363
  };
362
364
  }
365
+ cognitoIdentityName() {
366
+ return Stack.of(this).region.startsWith("us-gov-")
367
+ ? "cognito-identity-us-gov.amazonaws.com"
368
+ : "cognito-identity.amazonaws.com";
369
+ }
363
370
  }
@@ -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.1",
4
+ "version": "2.22.3",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -66,7 +66,7 @@
66
66
  "cross-spawn": "^7.0.3",
67
67
  "dendriform-immer-patch-optimiser": "^2.1.0",
68
68
  "dotenv": "^16.0.3",
69
- "esbuild": "0.18.11",
69
+ "esbuild": "0.18.13",
70
70
  "express": "^4.18.2",
71
71
  "fast-jwt": "^1.6.1",
72
72
  "get-port": "^6.1.2",
@@ -117,7 +117,7 @@
117
117
  "archiver": "^5.3.1",
118
118
  "tsx": "^3.12.1",
119
119
  "typescript": "^4.9.5",
120
- "vitest": "^0.28.3"
120
+ "vitest": "^0.33.0"
121
121
  },
122
122
  "peerDependencies": {
123
123
  "@sls-next/lambda-at-edge": "^3.7.0"
package/project.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface ConfigOptions {
11
11
  profile?: string;
12
12
  role?: string;
13
13
  ssmPrefix?: string;
14
+ outputs?: string;
14
15
  advanced?: {
15
16
  disableParameterizedStackNameCheck?: boolean;
16
17
  };
@@ -64,8 +64,8 @@ export const useGoHandler = Context.memo(async () => {
64
64
  const result = await execAsync([
65
65
  "go",
66
66
  "build",
67
- ...(ldFlags ? [`-ldflags "${ldFlags.join(" ")}"`] : []),
68
- ...(buildTags ? [`-t ${buildTags.join(" ")}`] : []),
67
+ ...(ldFlags.length ? [`-ldflags "${ldFlags.join(" ")}"`] : []),
68
+ ...(buildTags.length ? [`-tags ${buildTags.join(" ")}`] : []),
69
69
  `-o "${target}"`,
70
70
  `./${srcPath}`,
71
71
  ].join(" "), {
@@ -89,8 +89,8 @@ export const useGoHandler = Context.memo(async () => {
89
89
  await execAsync([
90
90
  "go",
91
91
  "build",
92
- ...(ldFlags ? [`-ldflags "${ldFlags.join(" ")}"`] : []),
93
- ...(buildTags ? [`-t ${buildTags.join(" ")}`] : []),
92
+ ...(ldFlags.length ? [`-ldflags "${ldFlags.join(" ")}"`] : []),
93
+ ...(buildTags.length ? [`-tags ${buildTags.join(" ")}`] : []),
94
94
  `-o "${target}"`,
95
95
  `./${srcPath}`,
96
96
  ].join(" "), {
@@ -15,6 +15,11 @@ export const useNodeHandler = Context.memo(async () => {
15
15
  const workers = await useRuntimeWorkers();
16
16
  const handlers = useRuntimeHandlers();
17
17
  const cache = {};
18
+ process.on("exit", () => {
19
+ for (const { ctx } of Object.values(cache)) {
20
+ ctx.dispose();
21
+ }
22
+ });
18
23
  const project = useProject();
19
24
  const threads = new Map();
20
25
  handlers.register({
package/sst.mjs CHANGED
@@ -5356,6 +5356,11 @@ var init_node = __esm({
5356
5356
  const workers = await useRuntimeWorkers();
5357
5357
  const handlers = useRuntimeHandlers();
5358
5358
  const cache = {};
5359
+ process.on("exit", () => {
5360
+ for (const { ctx } of Object.values(cache)) {
5361
+ ctx.dispose();
5362
+ }
5363
+ });
5359
5364
  const project = useProject();
5360
5365
  const threads = /* @__PURE__ */ new Map();
5361
5366
  handlers.register({
@@ -5670,8 +5675,8 @@ var init_go = __esm({
5670
5675
  [
5671
5676
  "go",
5672
5677
  "build",
5673
- ...ldFlags ? [`-ldflags "${ldFlags.join(" ")}"`] : [],
5674
- ...buildTags ? [`-t ${buildTags.join(" ")}`] : [],
5678
+ ...ldFlags.length ? [`-ldflags "${ldFlags.join(" ")}"`] : [],
5679
+ ...buildTags.length ? [`-tags ${buildTags.join(" ")}`] : [],
5675
5680
  `-o "${target}"`,
5676
5681
  `./${srcPath}`
5677
5682
  ].join(" "),
@@ -5697,8 +5702,8 @@ var init_go = __esm({
5697
5702
  [
5698
5703
  "go",
5699
5704
  "build",
5700
- ...ldFlags ? [`-ldflags "${ldFlags.join(" ")}"`] : [],
5701
- ...buildTags ? [`-t ${buildTags.join(" ")}`] : [],
5705
+ ...ldFlags.length ? [`-ldflags "${ldFlags.join(" ")}"`] : [],
5706
+ ...buildTags.length ? [`-tags ${buildTags.join(" ")}`] : [],
5702
5707
  `-o "${target}"`,
5703
5708
  `./${srcPath}`
5704
5709
  ].join(" "),
@@ -8655,7 +8660,7 @@ var dev = (program2) => program2.command(
8655
8660
  }
8656
8661
  lastDeployed = nextChecksum;
8657
8662
  fs19.writeFile(
8658
- path22.join(project.paths.out, "outputs.json"),
8663
+ project.config.outputs || path22.join(project.paths.out, "outputs.json"),
8659
8664
  JSON.stringify(
8660
8665
  mapValues(results, (val) => val.outputs),
8661
8666
  null,
@@ -9185,7 +9190,7 @@ Are you sure you want to deploy to this stage? (y/N) `,
9185
9190
  if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
9186
9191
  process.exit(1);
9187
9192
  fs18.writeFile(
9188
- path21.join(project.paths.out, "outputs.json"),
9193
+ project.config.outputs || path21.join(project.paths.out, "outputs.json"),
9189
9194
  JSON.stringify(
9190
9195
  mapValues(results, (val) => val.outputs),
9191
9196
  null,