sst 2.8.12 → 2.8.14

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/constructs/App.js CHANGED
@@ -186,6 +186,7 @@ export class App extends CDKApp {
186
186
  this.codegenTypes();
187
187
  this.createBindingSsmParameters();
188
188
  this.removeGovCloudUnsupportedResourceProperties();
189
+ const { config } = useProject();
189
190
  for (const child of this.node.children) {
190
191
  if (isStackConstruct(child)) {
191
192
  // Tag stacks
@@ -195,7 +196,8 @@ export class App extends CDKApp {
195
196
  if (this._defaultRemovalPolicy)
196
197
  this.applyRemovalPolicy(child, this._defaultRemovalPolicy);
197
198
  // Stack names need to be parameterized with the stage name
198
- if (!child.stackName.startsWith(`${this.stage}-`) &&
199
+ if (config.advanced?.disableParameterizedStackNameCheck !== true &&
200
+ !child.stackName.startsWith(`${this.stage}-`) &&
199
201
  !child.stackName.endsWith(`-${this.stage}`) &&
200
202
  child.stackName.indexOf(`-${this.stage}-`) === -1) {
201
203
  throw new Error(`Stack "${child.stackName}" is not parameterized with the stage name. The stack name needs to either start with "$stage-", end in "-$stage", or contain the stage name "-$stage-".`);
@@ -19,6 +19,20 @@ export interface ScriptProps {
19
19
  * ```
20
20
  */
21
21
  params?: Record<string, any>;
22
+ /**
23
+ * By default, the script runs during each deployment. If a version is provided, the script will only run when the version changes.
24
+ *
25
+ * @example
26
+ * ```js
27
+ * import { Script } from "sst/constructs";
28
+ *
29
+ * new Script(stack, "Script", {
30
+ * onCreate: "src/script.create",
31
+ * version: "v17",
32
+ * });
33
+ * ```
34
+ */
35
+ version?: string;
22
36
  defaults?: {
23
37
  /**
24
38
  * The default function props to be applied to all the Lambda functions in the API. The `environment`, `permissions` and `layers` properties will be merged with per route definitions if they are defined.
@@ -125,15 +125,17 @@ export class Script extends Construct {
125
125
  return handler;
126
126
  }
127
127
  createCustomResource(app, crFunction) {
128
- // Note: "BuiltAt" is set to current timestamp to ensure the Custom
128
+ // Note: "Version" is set to current timestamp to ensure the Custom
129
129
  // Resource function is run on every update.
130
130
  //
131
131
  // Do not use the current timestamp in Live mode, b/c we want the
132
132
  // this custom resource to remain the same in CloudFormation template
133
133
  // when rebuilding infrastructure. Otherwise, there will always be
134
- // a change when rebuilding infrastructure b/c the "BuildAt" property
134
+ // a change when rebuilding infrastructure b/c the "version" property
135
135
  // changes on each build.
136
- const builtAt = app.mode === "dev" ? app.debugStartedAt : Date.now();
136
+ const version = app.mode === "dev"
137
+ ? app.debugStartedAt
138
+ : this.props.version ?? Date.now().toString();
137
139
  new cdk.CustomResource(this, "ScriptResource", {
138
140
  serviceToken: crFunction.functionArn,
139
141
  resourceType: "Custom::SSTScript",
@@ -142,7 +144,7 @@ export class Script extends Construct {
142
144
  UserUpdateFunction: this.updateFunction?.functionName,
143
145
  UserDeleteFunction: this.deleteFunction?.functionName,
144
146
  UserParams: JSON.stringify(this.props.params || {}),
145
- BuiltAt: builtAt,
147
+ Version: version,
146
148
  },
147
149
  });
148
150
  }
@@ -145,6 +145,16 @@ export interface SsrSiteProps {
145
145
  * ```
146
146
  */
147
147
  deploy?: boolean;
148
+ /**
149
+ * The local site URL when running `sst dev`.
150
+ * @example
151
+ * ```js
152
+ * dev: {
153
+ * url: "http://localhost:3000"
154
+ * }
155
+ * ```
156
+ */
157
+ url?: string;
148
158
  };
149
159
  /**
150
160
  * While deploying, SST waits for the CloudFront cache invalidation process to finish. This ensures that the new content will be served once the deploy command finishes. However, this process can sometimes take more than 5 mins. For non-prod environments it might make sense to pass in `false`. That'll skip waiting for the cache to invalidate and speed up the deploy process.
@@ -120,7 +120,7 @@ export class SsrSite extends Construct {
120
120
  */
121
121
  get url() {
122
122
  if (this.doNotDeploy)
123
- return;
123
+ return this.props.dev?.url;
124
124
  return `https://${this.distribution.distributionDomainName}`;
125
125
  }
126
126
  /**
@@ -204,7 +204,7 @@ export class SsrSite extends Construct {
204
204
  url: this.doNotDeploy
205
205
  ? {
206
206
  type: "plain",
207
- value: "localhost",
207
+ value: this.props.dev?.url ?? "localhost",
208
208
  }
209
209
  : {
210
210
  // Do not set real value b/c we don't want to make the Lambda function
@@ -193,6 +193,18 @@ export interface StaticSiteProps {
193
193
  * ```
194
194
  */
195
195
  deploy?: boolean;
196
+ /**
197
+ * The local site URL when running `sst dev`.
198
+ * @example
199
+ * ```js
200
+ * new StaticSite(stack, "frontend", {
201
+ * dev: {
202
+ * url: "http://localhost:3000"
203
+ * }
204
+ * });
205
+ * ```
206
+ */
207
+ url?: string;
196
208
  };
197
209
  vite?: {
198
210
  /**
@@ -99,7 +99,7 @@ export class StaticSite extends Construct {
99
99
  */
100
100
  get url() {
101
101
  if (this.doNotDeploy)
102
- return;
102
+ return this.props.dev?.url;
103
103
  return `https://${this.distribution.distributionDomainName}`;
104
104
  }
105
105
  /**
@@ -150,7 +150,7 @@ export class StaticSite extends Construct {
150
150
  url: this.doNotDeploy
151
151
  ? {
152
152
  type: "plain",
153
- value: "localhost",
153
+ value: this.props.dev?.url ?? "localhost",
154
154
  }
155
155
  : {
156
156
  // Do not set real value b/c we don't want to make the Lambda function
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.8.12",
4
+ "version": "2.8.14",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
package/project.d.ts CHANGED
@@ -11,6 +11,9 @@ export interface ConfigOptions {
11
11
  profile?: string;
12
12
  role?: string;
13
13
  ssmPrefix?: string;
14
+ advanced?: {
15
+ disableParameterizedStackNameCheck?: boolean;
16
+ };
14
17
  bootstrap?: {
15
18
  stackName?: string;
16
19
  tags?: Record<string, string>;