sst 2.24.18 → 2.24.20

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.
package/cli/sst.js CHANGED
@@ -55,6 +55,7 @@ process.on("uncaughtException", (err) => {
55
55
  spinner.fail(spinner.text);
56
56
  }
57
57
  if (!(err instanceof SilentError)) {
58
+ console.log();
58
59
  console.log(red("Error:"), err.message);
59
60
  if (!(err instanceof VisibleError)) {
60
61
  console.log();
package/config.js CHANGED
@@ -5,7 +5,6 @@ import { useProject } from "./project.js";
5
5
  import { useAWSClient } from "./credentials.js";
6
6
  import { useIOT } from "./iot.js";
7
7
  import { Stacks } from "./stacks/index.js";
8
- const ssm = useAWSClient(SSMClient);
9
8
  const FALLBACK_STAGE = ".fallback";
10
9
  const SECRET_UPDATED_AT_ENV = "SST_ADMIN_SECRET_UPDATED_AT";
11
10
  const PREFIX = {
@@ -171,6 +170,7 @@ export var Config;
171
170
  Config.restart = restart;
172
171
  })(Config || (Config = {}));
173
172
  async function* scanParameters(prefix) {
173
+ const ssm = useAWSClient(SSMClient);
174
174
  let token;
175
175
  while (true) {
176
176
  const results = await ssm.send(new GetParametersByPathCommand({
@@ -186,12 +186,14 @@ async function* scanParameters(prefix) {
186
186
  }
187
187
  }
188
188
  function getParameter(name) {
189
+ const ssm = useAWSClient(SSMClient);
189
190
  return ssm.send(new GetParameterCommand({
190
191
  Name: name,
191
192
  WithDecryption: true,
192
193
  }));
193
194
  }
194
195
  function putParameter(name, value) {
196
+ const ssm = useAWSClient(SSMClient);
195
197
  return ssm.send(new PutParameterCommand({
196
198
  Name: name,
197
199
  Value: value,
@@ -201,6 +203,7 @@ function putParameter(name, value) {
201
203
  }));
202
204
  }
203
205
  function deleteParameter(name) {
206
+ const ssm = useAWSClient(SSMClient);
204
207
  return ssm.send(new DeleteParameterCommand({
205
208
  Name: name,
206
209
  }));
@@ -342,24 +342,38 @@ export class Service extends Construct {
342
342
  /////////////////////
343
343
  validateServiceExists() {
344
344
  const { path: servicePath, file } = this.props;
345
+ // Validate path exists
345
346
  if (!fs.existsSync(servicePath)) {
346
- throw new Error(`No service found at "${path.resolve(servicePath)}"`);
347
+ throw new VisibleError(`In the "${this.node.id}" Service, path is not found at "${path.resolve(servicePath)}"`);
347
348
  }
349
+ // Validate path is a directory
350
+ if (fs.statSync(servicePath).isFile()) {
351
+ throw new VisibleError([
352
+ `In the "${this.node.id}" Service, the path "${path.resolve(servicePath)}" should be a directory.`,
353
+ `Did you mean:`,
354
+ ``,
355
+ ` {`,
356
+ ` path: "${path.dirname(servicePath)}",`,
357
+ ` file: "${path.basename(servicePath)}",`,
358
+ ` }`,
359
+ ].join("\n"));
360
+ }
361
+ // Validate path exists
348
362
  if (file) {
349
363
  const dockerfilePath = path.join(servicePath, file);
350
364
  if (!fs.existsSync(dockerfilePath)) {
351
- throw new Error(`No Dockerfile found at "${dockerfilePath}". Make sure to set the "file" property to the path of the Dockerfile relative to "${servicePath}".`);
365
+ throw new VisibleError(`In the "${this.node.id}" Service, no Dockerfile is found at "${dockerfilePath}". Make sure to set the "file" property to the path of the Dockerfile relative to "${servicePath}".`);
352
366
  }
353
367
  }
354
368
  }
355
369
  validateMemoryAndCpu() {
356
370
  const { memory, cpu } = this.props;
357
371
  if (!supportedCpus[cpu]) {
358
- throw new Error(`Only the following "cpu" settings are supported for the ${this.node.id} service: ${Object.keys(supportedCpus).join(", ")}`);
372
+ throw new VisibleError(`In the "${this.node.id}" Service, only the following "cpu" settings are supported: ${Object.keys(supportedCpus).join(", ")}`);
359
373
  }
360
374
  // @ts-ignore
361
375
  if (!supportedMemories[cpu][memory]) {
362
- throw new Error(`Only the following "memory" settings are supported with "${cpu}" for the ${this.node.id} service: ${Object.keys(supportedMemories[cpu]).join(", ")}`);
376
+ throw new VisibleError(`In the "${this.node.id}" Service, only the following "memory" settings are supported with "${cpu}": ${Object.keys(supportedMemories[cpu]).join(", ")}`);
363
377
  }
364
378
  }
365
379
  createVpc() {
@@ -491,7 +505,7 @@ export class Service extends Construct {
491
505
  assumedBy: new CompositePrincipal(new AccountPrincipal(app.account), new ServicePrincipal("lambda.amazonaws.com")),
492
506
  maxSessionDuration: CdkDuration.hours(12),
493
507
  });
494
- return new Function(this, `ServerFunction`, {
508
+ const fn = new Function(this, `ServerFunction`, {
495
509
  description: "Service dev function",
496
510
  handler: path.join(__dirname, "../support/service-dev-function", "index.handler"),
497
511
  runtime: "nodejs18.x",
@@ -502,6 +516,8 @@ export class Service extends Construct {
502
516
  environment,
503
517
  permissions,
504
518
  });
519
+ fn._doNotAllowOthersToBind = true;
520
+ return fn;
505
521
  }
506
522
  bindForService(constructs) {
507
523
  // Get referenced secrets
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.24.18",
4
+ "version": "2.24.20",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },