sst 2.1.34 → 2.2.0

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.
@@ -100,16 +100,36 @@ export class Function extends CDKFunction {
100
100
  const tracing = Tracing[(props.tracing || "active").toUpperCase()];
101
101
  const logRetention = props.logRetention &&
102
102
  RetentionDays[props.logRetention.toUpperCase()];
103
- const isLiveDevEnabled = props.enableLiveDev === false ? false : true;
103
+ const isLiveDevEnabled = app.mode === "dev" && (props.enableLiveDev === false ? false : true);
104
104
  Function.validateHandlerSet(id, props);
105
105
  Function.validateVpcSettings(id, props);
106
+ // Handle inactive stacks
107
+ if (!stack.isActive) {
108
+ // Note: need to override runtime as CDK does not support inline code
109
+ // for some runtimes.
110
+ super(scope, id, {
111
+ ...props,
112
+ architecture,
113
+ code: Code.fromInline("export function placeholder() {}"),
114
+ handler: "index.placeholder",
115
+ functionName,
116
+ runtime: CDKRuntime.NODEJS_16_X,
117
+ memorySize,
118
+ ephemeralStorageSize: diskSize,
119
+ timeout,
120
+ tracing,
121
+ environment: props.environment,
122
+ layers: Function.buildLayers(scope, id, props),
123
+ logRetention,
124
+ });
125
+ }
106
126
  // Handle local development (ie. sst start)
107
127
  // - set runtime to nodejs12.x for non-Node runtimes (b/c the stub is in Node)
108
128
  // - set retry to 0. When the debugger is disconnected, the Cron construct
109
129
  // will still try to periodically invoke the Lambda, and the requests would
110
130
  // fail and retry. So when launching `sst start`, a couple of retry requests
111
131
  // from recent failed request will be received. And this behavior is confusing.
112
- if (isLiveDevEnabled && app.mode === "dev") {
132
+ else if (isLiveDevEnabled) {
113
133
  // If debugIncreaseTimeout is enabled:
114
134
  // set timeout to 900s. This will give people more time to debug the function
115
135
  // without timing out the request. Note API Gateway requests have a maximum
@@ -147,26 +167,6 @@ export class Function extends CDKFunction {
147
167
  }),
148
168
  ]);
149
169
  }
150
- // Handle remove (ie. sst remove)
151
- else if (app.skipBuild) {
152
- // Note: need to override runtime as CDK does not support inline code
153
- // for some runtimes.
154
- super(scope, id, {
155
- ...props,
156
- architecture,
157
- code: Code.fromInline("export function placeholder() {}"),
158
- handler: "index.placeholder",
159
- functionName,
160
- runtime: CDKRuntime.NODEJS_16_X,
161
- memorySize,
162
- ephemeralStorageSize: diskSize,
163
- timeout,
164
- tracing,
165
- environment: props.environment,
166
- layers: Function.buildLayers(scope, id, props),
167
- logRetention,
168
- });
169
- }
170
170
  // Handle build
171
171
  else {
172
172
  super(scope, id, {
@@ -193,12 +193,22 @@ export class Function extends CDKFunction {
193
193
  ...result.errors,
194
194
  ].join("\n"));
195
195
  }
196
+ // Update code
197
+ const cfnFunction = this.node.defaultChild;
196
198
  const code = AssetCode.fromAsset(result.out);
197
- // Update function's code
198
199
  const codeConfig = code.bind(this);
199
- const cfnFunction = this.node.defaultChild;
200
- cfnFunction.runtime =
201
- supportedRuntimes[props.runtime].toString();
200
+ cfnFunction.code = {
201
+ s3Bucket: codeConfig.s3Location?.bucketName,
202
+ s3Key: codeConfig.s3Location?.objectKey,
203
+ s3ObjectVersion: codeConfig.s3Location?.objectVersion,
204
+ };
205
+ cfnFunction.handler = result.handler;
206
+ code.bindToResource(cfnFunction);
207
+ // Update runtime
208
+ // @ts-ignore - override "runtime" private property
209
+ this.runtime =
210
+ supportedRuntimes[props.runtime];
211
+ cfnFunction.runtime = this.runtime.toString();
202
212
  /*
203
213
  if (isJavaRuntime) {
204
214
  const providedRuntime = (bundle as FunctionBundleJavaProps)
@@ -208,13 +218,6 @@ export class Function extends CDKFunction {
208
218
  }
209
219
  }
210
220
  */
211
- cfnFunction.code = {
212
- s3Bucket: codeConfig.s3Location?.bucketName,
213
- s3Key: codeConfig.s3Location?.objectKey,
214
- s3ObjectVersion: codeConfig.s3Location?.objectVersion,
215
- };
216
- cfnFunction.handler = result.handler;
217
- code.bindToResource(cfnFunction);
218
221
  });
219
222
  }
220
223
  this.id = id;
package/constructs/Job.js CHANGED
@@ -41,6 +41,7 @@ export class Job extends Construct {
41
41
  constructor(scope, id, props) {
42
42
  super(scope, props.cdk?.id || id);
43
43
  const app = this.node.root;
44
+ const stack = Stack.of(scope);
44
45
  this.id = id;
45
46
  this.props = props;
46
47
  useFunctions().add(this.node.addr, {
@@ -52,10 +53,13 @@ export class Job extends Construct {
52
53
  .replace(/\$/g, "-")
53
54
  .replace(/\//g, "-")
54
55
  .replace(/\./g, "-");
55
- const isLiveDevEnabled = app.local && (this.props.enableLiveDev === false ? false : true);
56
+ const isLiveDevEnabled = app.mode === "dev" && (this.props.enableLiveDev === false ? false : true);
56
57
  this.job = this.createCodeBuildProject();
57
58
  this.createLogRetention();
58
- if (isLiveDevEnabled) {
59
+ if (!stack.isActive) {
60
+ this._jobInvoker = this.createCodeBuildInvoker();
61
+ }
62
+ else if (isLiveDevEnabled) {
59
63
  this._jobInvoker = this.createLocalInvoker();
60
64
  }
61
65
  else {
@@ -175,9 +179,6 @@ export class Job extends Construct {
175
179
  }
176
180
  buildCodeBuildProjectCode() {
177
181
  const app = this.node.root;
178
- // Handle remove (ie. sst remove)
179
- if (app.mode === "remove")
180
- return;
181
182
  useDeferredTasks().add(async () => {
182
183
  // Build function
183
184
  const bundle = await useRuntimeHandlers().build(this.node.addr, "deploy");
package/constructs/RDS.js CHANGED
@@ -274,7 +274,7 @@ export class RDS extends Construct {
274
274
  RDS_ENGINE_MODE: engine.includes("postgres") ? "postgres" : "mysql",
275
275
  // for live development, perserve the migrations path so the migrator
276
276
  // can locate the migration files
277
- RDS_MIGRATIONS_PATH: app.local ? migrations : migrationsDestination,
277
+ RDS_MIGRATIONS_PATH: app.mode === "dev" ? migrations : migrationsDestination,
278
278
  },
279
279
  // Note that we need to generate a relative path of the migrations off the
280
280
  // srcPath because sst.Function internally builds the copy "from" path by
@@ -313,17 +313,13 @@ export class RDS extends Construct {
313
313
  // infrastructure. Otherwise, there will always be a change when
314
314
  // rebuilding infrastructure b/c the "BuildAt" property changes on
315
315
  // each build.
316
- const hash = app.local ? 0 : this.generateMigrationsHash(migrations);
316
+ const hash = app.mode === "dev" ? 0 : this.generateMigrationsHash(migrations);
317
317
  new cdk.CustomResource(this, "MigrationResource", {
318
318
  serviceToken: handler.functionArn,
319
319
  resourceType: "Custom::SSTScript",
320
320
  properties: {
321
- UserCreateFunction: app.local
322
- ? undefined
323
- : this.migratorFunction?.functionName,
324
- UserUpdateFunction: app.local
325
- ? undefined
326
- : this.migratorFunction?.functionName,
321
+ UserCreateFunction: app.mode === "dev" ? undefined : this.migratorFunction?.functionName,
322
+ UserUpdateFunction: app.mode === "dev" ? undefined : this.migratorFunction?.functionName,
327
323
  UserParams: JSON.stringify({}),
328
324
  MigrationsHash: hash,
329
325
  },
@@ -133,7 +133,7 @@ export class Script extends Construct {
133
133
  // when rebuilding infrastructure. Otherwise, there will always be
134
134
  // a change when rebuilding infrastructure b/c the "BuildAt" property
135
135
  // changes on each build.
136
- const builtAt = app.local ? app.debugStartedAt : Date.now();
136
+ const builtAt = app.mode === "dev" ? app.debugStartedAt : Date.now();
137
137
  new cdk.CustomResource(this, "ScriptResource", {
138
138
  serviceToken: crFunction.functionArn,
139
139
  resourceType: "Custom::SSTScript",
@@ -52,6 +52,7 @@ export class SsrSite extends Construct {
52
52
  constructor(scope, id, props) {
53
53
  super(scope, props?.cdk?.id || id);
54
54
  const app = scope.node.root;
55
+ const stack = Stack.of(this);
55
56
  this.id = id;
56
57
  this.props = {
57
58
  path: ".",
@@ -61,7 +62,8 @@ export class SsrSite extends Construct {
61
62
  memorySize: "1024 MB",
62
63
  ...props,
63
64
  };
64
- this.doNotDeploy = (app.local || app.skipBuild) && !this.props.dev?.deploy;
65
+ this.doNotDeploy =
66
+ !stack.isActive || (app.mode === "dev" && !this.props.dev?.deploy);
65
67
  this.validateSiteExists();
66
68
  this.registerSiteEnvironment();
67
69
  if (this.doNotDeploy) {
@@ -28,9 +28,17 @@ export declare class Stack extends cdk.Stack {
28
28
  */
29
29
  readonly defaultFunctionProps: FunctionProps[];
30
30
  /**
31
+ * Create a custom resource handler per stack. This handler will
32
+ * be used by all the custom resources in the stack.
31
33
  * @internal
32
34
  */
33
35
  readonly customResourceHandler: lambda.Function;
36
+ /**
37
+ * Skip building Function/Site code when stack is not active
38
+ * ie. `sst remove` and `sst deploy PATTERN` (pattern not matched)
39
+ * @internal
40
+ */
41
+ readonly isActive: boolean;
34
42
  constructor(scope: Construct, id: string, props?: StackProps);
35
43
  /**
36
44
  * The default function props to be applied to all the Lambda functions in the stack.
@@ -30,27 +30,36 @@ export class Stack extends cdk.Stack {
30
30
  */
31
31
  defaultFunctionProps;
32
32
  /**
33
+ * Create a custom resource handler per stack. This handler will
34
+ * be used by all the custom resources in the stack.
33
35
  * @internal
34
36
  */
35
37
  customResourceHandler;
38
+ /**
39
+ * Skip building Function/Site code when stack is not active
40
+ * ie. `sst remove` and `sst deploy PATTERN` (pattern not matched)
41
+ * @internal
42
+ */
43
+ isActive;
36
44
  constructor(scope, id, props) {
37
- const root = scope.node.root;
38
- const stackId = root.logicalPrefixedName(id);
45
+ const app = scope.node.root;
46
+ const stackId = app.logicalPrefixedName(id);
39
47
  Stack.checkForPropsIsConstruct(id, props);
40
48
  Stack.checkForEnvInProps(id, props);
41
49
  super(scope, stackId, {
42
50
  ...props,
43
51
  env: {
44
- account: root.account,
45
- region: root.region,
52
+ account: app.account,
53
+ region: app.region,
46
54
  },
47
55
  synthesizer: props?.synthesizer || Stack.buildSynthesizer(),
48
56
  });
49
- this.stage = root.stage;
50
- this.defaultFunctionProps = root.defaultFunctionProps.map((dfp) => typeof dfp === "function" ? dfp(this) : dfp);
51
- // Create a custom resource handler per stack. This handler will
52
- // be used by all the custom resources in the stack.
57
+ this.stage = app.stage;
58
+ this.defaultFunctionProps = app.defaultFunctionProps.map((dfp) => typeof dfp === "function" ? dfp(this) : dfp);
53
59
  this.customResourceHandler = this.createCustomResourceHandler();
60
+ this.isActive =
61
+ app.mode !== "remove" &&
62
+ (!app.isActiveStack || app.isActiveStack?.(this.stackName) === true);
54
63
  }
55
64
  /**
56
65
  * The default function props to be applied to all the Lambda functions in the stack.
@@ -53,13 +53,15 @@ export class StaticSite extends Construct {
53
53
  constructor(scope, id, props) {
54
54
  super(scope, props?.cdk?.id || id);
55
55
  const app = scope.node.root;
56
+ const stack = Stack.of(this);
56
57
  this.id = id;
57
58
  this.props = {
58
59
  path: ".",
59
60
  waitForInvalidation: false,
60
61
  ...props,
61
62
  };
62
- this.doNotDeploy = (app.local || app.skipBuild) && !this.props.dev?.deploy;
63
+ this.doNotDeploy =
64
+ !stack.isActive || (app.mode === "dev" && !this.props.dev?.deploy);
63
65
  this.validateCustomDomainSettings();
64
66
  this.registerSiteEnvironment();
65
67
  this.generateViteTypes();
@@ -117,9 +117,10 @@ export class NextjsSite extends Construct {
117
117
  super(scope, props.cdk?.id || id);
118
118
  this.id = id;
119
119
  const app = scope.node.root;
120
+ const stack = Stack.of(this);
120
121
  // Local development or skip build => stub asset
121
122
  this.isPlaceholder =
122
- (app.local || app.skipBuild) && !props.disablePlaceholder;
123
+ !stack.isActive && app.mode === "dev" && !props.disablePlaceholder;
123
124
  this.sstBuildDir = useProject().paths.artifacts;
124
125
  const fileSizeLimit = app.isRunningSSTTest()
125
126
  ? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
package/credentials.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Client } from "@aws-sdk/smithy-client";
3
3
  import { RegionInputConfig } from "@aws-sdk/config-resolver";
4
4
  import { RetryInputConfig } from "@aws-sdk/middleware-retry";
5
5
  import { AwsAuthInputConfig } from "@aws-sdk/middleware-signing";
6
- import { SdkProvider } from "aws-cdk/lib/api/aws-auth/sdk-provider.js";
6
+ import { SdkProvider } from "sst-aws-cdk/lib/api/aws-auth/sdk-provider.js";
7
7
  type Config = RegionInputConfig & RetryInputConfig & AwsAuthInputConfig & HostHeaderConditionConfig;
8
8
  export declare const useAWSCredentialsProvider: () => import("@aws-sdk/types").AwsCredentialIdentityProvider;
9
9
  export declare const useAWSCredentials: () => Promise<import("@aws-sdk/types").AwsCredentialIdentity>;
package/credentials.js CHANGED
@@ -3,7 +3,7 @@ import { Context } from "./context/context.js";
3
3
  import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
4
4
  import { GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts";
5
5
  import { Logger } from "./logger.js";
6
- import { SdkProvider } from "aws-cdk/lib/api/aws-auth/sdk-provider.js";
6
+ import { SdkProvider } from "sst-aws-cdk/lib/api/aws-auth/sdk-provider.js";
7
7
  import { StandardRetryStrategy } from "@aws-sdk/middleware-retry";
8
8
  export const useAWSCredentialsProvider = Context.memo(() => {
9
9
  const project = useProject();
@@ -66,17 +66,24 @@ export function useAWSClient(client, force = false) {
66
66
  region: project.config.region,
67
67
  credentials: credentials,
68
68
  retryStrategy: new StandardRetryStrategy(async () => 10000, {
69
- retryDecider: (err) => {
70
- // Handle credential errors => no retry
71
- if (err.name === "CredentialsProviderError")
72
- return false;
73
- if (err.message === "Could not load credentials from any providers")
74
- return false;
75
- // Handle no internet connection
76
- if (err.code === "ENOTFOUND") {
69
+ retryDecider: (e) => {
70
+ // Handle no internet connection => retry
71
+ if (e.code === "ENOTFOUND") {
77
72
  printNoInternet();
78
73
  }
79
- return true;
74
+ // Handle throttling errors => retry
75
+ if ([
76
+ "ThrottlingException",
77
+ "Throttling",
78
+ "TooManyRequestsException",
79
+ "OperationAbortedException",
80
+ "TimeoutError",
81
+ "NetworkingError",
82
+ ].includes(e.name)) {
83
+ Logger.debug("Retry AWS call", e.name, e.message);
84
+ return true;
85
+ }
86
+ return false;
80
87
  },
81
88
  delayDecider: (_, attempts) => {
82
89
  return Math.min(1.5 ** attempts * 100, 5000);
@@ -12,14 +12,7 @@ const SessionMemo = /* @__PURE__ */ Context.memo(() => {
12
12
  if (cookie)
13
13
  token = cookie;
14
14
  if (token) {
15
- try {
16
- const jwt = createVerifier({
17
- algorithms: ["RS512"],
18
- key: getPublicKey(),
19
- })(token);
20
- return jwt;
21
- }
22
- catch { }
15
+ return Session.verify(token);
23
16
  }
24
17
  return {
25
18
  type: "public",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.1.34",
3
+ "version": "2.2.0",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -30,11 +30,7 @@
30
30
  "@aws-cdk/cloud-assembly-schema": "2.62.2",
31
31
  "@aws-cdk/cloudformation-diff": "2.62.2",
32
32
  "@aws-cdk/cx-api": "2.62.2",
33
- "@aws-cdk/region-info": "2.62.2",
34
- "@aws-sdk/client-api-gateway": "^3.208.0",
35
33
  "@aws-sdk/client-cloudformation": "^3.279.0",
36
- "@aws-sdk/client-cloudfront": "^3.279.0",
37
- "@aws-sdk/client-iam": "^3.279.0",
38
34
  "@aws-sdk/client-iot": "^3.279.0",
39
35
  "@aws-sdk/client-iot-data-plane": "^3.279.0",
40
36
  "@aws-sdk/client-lambda": "^3.279.0",
@@ -51,16 +47,12 @@
51
47
  "@babel/core": "^7.0.0-0",
52
48
  "@babel/generator": "^7.20.5",
53
49
  "@trpc/server": "9.16.0",
54
- "adm-zip": "^0.5.10",
55
- "archiver": "^5.3.1",
56
- "aws-cdk": "2.62.2",
57
50
  "aws-cdk-lib": "2.62.2",
58
51
  "aws-iot-device-sdk": "^2.2.12",
59
- "aws-iot-device-sdk-v2": "^1.9.5",
60
52
  "aws-sdk": "^2.1326.0",
61
53
  "builtin-modules": "3.2.0",
62
54
  "cdk-assets": "2.62.2",
63
- "chalk": "^4.1.2",
55
+ "chalk": "^5.2.0",
64
56
  "chokidar": "^3.5.3",
65
57
  "ci-info": "^3.7.0",
66
58
  "colorette": "^2.0.19",
@@ -85,17 +77,20 @@
85
77
  "minimatch": "^6.1.6",
86
78
  "openid-client": "^5.1.8",
87
79
  "ora": "^6.1.2",
88
- "promptly": "^3.2.0",
89
80
  "react": "17.0.2",
90
81
  "remeda": "^1.3.0",
82
+ "sst-aws-cdk": "2.62.2-2",
91
83
  "undici": "^5.12.0",
92
84
  "uuid": "^9.0.0",
93
85
  "ws": "^8.11.0",
94
- "yaml": "1.10.2",
95
86
  "yargs": "^17.6.2",
96
87
  "zip-local": "^0.3.5"
97
88
  },
98
89
  "devDependencies": {
90
+ "adm-zip": "^0.5.10",
91
+ "@aws-sdk/client-iam": "^3.279.0",
92
+ "@aws-sdk/client-cloudfront": "^3.279.0",
93
+ "@aws-sdk/client-api-gateway": "^3.208.0",
99
94
  "@aws-sdk/client-codebuild": "^3.279.0",
100
95
  "@aws-sdk/types": "^3.272.0",
101
96
  "@graphql-tools/merge": "^8.3.16",
@@ -114,6 +109,7 @@
114
109
  "@types/uuid": "^8.3.4",
115
110
  "@types/ws": "^8.5.3",
116
111
  "@types/yargs": "^17.0.13",
112
+ "archiver": "^5.3.1",
117
113
  "tsx": "^3.12.1",
118
114
  "typescript": "^4.9.5",
119
115
  "vitest": "^0.28.3"
package/sst.mjs CHANGED
@@ -1595,7 +1595,7 @@ __export(credentials_exports, {
1595
1595
  });
1596
1596
  import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
1597
1597
  import { GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts";
1598
- import { SdkProvider } from "aws-cdk/lib/api/aws-auth/sdk-provider.js";
1598
+ import { SdkProvider } from "sst-aws-cdk/lib/api/aws-auth/sdk-provider.js";
1599
1599
  import { StandardRetryStrategy } from "@aws-sdk/middleware-retry";
1600
1600
  import stupid from "aws-sdk/lib/maintenance_mode_message.js";
1601
1601
  import aws from "aws-sdk";
@@ -1619,15 +1619,22 @@ function useAWSClient(client, force = false) {
1619
1619
  region: project.config.region,
1620
1620
  credentials,
1621
1621
  retryStrategy: new StandardRetryStrategy(async () => 1e4, {
1622
- retryDecider: (err) => {
1623
- if (err.name === "CredentialsProviderError")
1624
- return false;
1625
- if (err.message === "Could not load credentials from any providers")
1626
- return false;
1627
- if (err.code === "ENOTFOUND") {
1622
+ retryDecider: (e) => {
1623
+ if (e.code === "ENOTFOUND") {
1628
1624
  printNoInternet();
1629
1625
  }
1630
- return true;
1626
+ if ([
1627
+ "ThrottlingException",
1628
+ "Throttling",
1629
+ "TooManyRequestsException",
1630
+ "OperationAbortedException",
1631
+ "TimeoutError",
1632
+ "NetworkingError"
1633
+ ].includes(e.name)) {
1634
+ Logger.debug("Retry AWS call", e.name, e.message);
1635
+ return true;
1636
+ }
1637
+ return false;
1631
1638
  },
1632
1639
  delayDecider: (_, attempts) => {
1633
1640
  return Math.min(1.5 ** attempts * 100, 5e3);
@@ -2910,14 +2917,14 @@ var init_util = __esm({
2910
2917
  import * as cxapi from "@aws-cdk/cx-api";
2911
2918
  import fs8 from "fs/promises";
2912
2919
  import * as uuid from "uuid";
2913
- import { addMetadataAssetsToManifest } from "aws-cdk/lib/assets.js";
2914
- import { debug, error, print } from "aws-cdk/lib/logging.js";
2915
- import { toYAML } from "aws-cdk/lib/serialize.js";
2916
- import { AssetManifestBuilder } from "aws-cdk/lib/util/asset-manifest-builder.js";
2917
- import { publishAssets } from "aws-cdk/lib/util/asset-publishing.js";
2918
- import { contentHash } from "aws-cdk/lib/util/content-hash.js";
2919
- import { CfnEvaluationException } from "aws-cdk/lib/api/evaluate-cloudformation-template.js";
2920
- import { tryHotswapDeployment } from "aws-cdk/lib/api/hotswap-deployments.js";
2920
+ import { addMetadataAssetsToManifest } from "sst-aws-cdk/lib/assets.js";
2921
+ import { debug, error, print } from "sst-aws-cdk/lib/logging.js";
2922
+ import { toYAML } from "sst-aws-cdk/lib/serialize.js";
2923
+ import { AssetManifestBuilder } from "sst-aws-cdk/lib/util/asset-manifest-builder.js";
2924
+ import { publishAssets } from "sst-aws-cdk/lib/util/asset-publishing.js";
2925
+ import { contentHash } from "sst-aws-cdk/lib/util/content-hash.js";
2926
+ import { CfnEvaluationException } from "sst-aws-cdk/lib/api/evaluate-cloudformation-template.js";
2927
+ import { tryHotswapDeployment } from "sst-aws-cdk/lib/api/hotswap-deployments.js";
2921
2928
  import {
2922
2929
  changeSetHasNoChanges,
2923
2930
  CloudFormationStack,
@@ -2925,7 +2932,7 @@ import {
2925
2932
  waitForChangeSet,
2926
2933
  waitForStackDeploy,
2927
2934
  waitForStackDelete
2928
- } from "aws-cdk/lib/api/util/cloudformation.js";
2935
+ } from "sst-aws-cdk/lib/api/util/cloudformation.js";
2929
2936
  import { blue as blue2 } from "colorette";
2930
2937
  async function deployStack(options) {
2931
2938
  const stackArtifact = options.stack;
@@ -3434,21 +3441,21 @@ __export(cloudformation_deployments_exports, {
3434
3441
  });
3435
3442
  import * as cxapi2 from "@aws-cdk/cx-api";
3436
3443
  import { AssetManifest } from "cdk-assets";
3437
- import { debug as debug2, warning } from "aws-cdk/lib/logging.js";
3444
+ import { debug as debug2, warning } from "sst-aws-cdk/lib/logging.js";
3438
3445
  import {
3439
3446
  buildAssets,
3440
3447
  publishAssets as publishAssets2
3441
- } from "aws-cdk/lib/util/asset-publishing.js";
3442
- import { Mode } from "aws-cdk/lib/api/aws-auth/credentials.js";
3448
+ } from "sst-aws-cdk/lib/util/asset-publishing.js";
3449
+ import { Mode } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
3443
3450
  import {
3444
3451
  loadCurrentTemplateWithNestedStacks,
3445
3452
  loadCurrentTemplate
3446
- } from "aws-cdk/lib/api/nested-stack-helpers.js";
3447
- import { ToolkitInfo } from "aws-cdk/lib/api/toolkit-info.js";
3453
+ } from "sst-aws-cdk/lib/api/nested-stack-helpers.js";
3454
+ import { ToolkitInfo } from "sst-aws-cdk/lib/api/toolkit-info.js";
3448
3455
  import {
3449
3456
  CloudFormationStack as CloudFormationStack2
3450
- } from "aws-cdk/lib/api/util/cloudformation.js";
3451
- import { replaceEnvPlaceholders } from "aws-cdk/lib/api/util/placeholders.js";
3457
+ } from "sst-aws-cdk/lib/api/util/cloudformation.js";
3458
+ import { replaceEnvPlaceholders } from "sst-aws-cdk/lib/api/util/placeholders.js";
3452
3459
  async function prepareSdkWithLookupRoleFor(sdkProvider, stack) {
3453
3460
  const resolvedEnvironment = await sdkProvider.resolveEnvironment(
3454
3461
  stack.environment
@@ -3757,16 +3764,16 @@ var cloudformation_deployments_wrapper_exports = {};
3757
3764
  __export(cloudformation_deployments_wrapper_exports, {
3758
3765
  publishDeployAssets: () => publishDeployAssets
3759
3766
  });
3760
- import { debug as debug3 } from "aws-cdk/lib/logging.js";
3767
+ import { debug as debug3 } from "sst-aws-cdk/lib/logging.js";
3761
3768
  import {
3762
3769
  CloudFormationStack as CloudFormationStack3,
3763
3770
  TemplateParameters as TemplateParameters2,
3764
3771
  waitForStackDelete as waitForStackDelete2
3765
- } from "aws-cdk/lib/api/util/cloudformation.js";
3766
- import { ToolkitInfo as ToolkitInfo2 } from "aws-cdk/lib/api/toolkit-info.js";
3767
- import { addMetadataAssetsToManifest as addMetadataAssetsToManifest2 } from "aws-cdk/lib/assets.js";
3768
- import { publishAssets as publishAssets3 } from "aws-cdk/lib/util/asset-publishing.js";
3769
- import { AssetManifestBuilder as AssetManifestBuilder2 } from "aws-cdk/lib/util/asset-manifest-builder.js";
3772
+ } from "sst-aws-cdk/lib/api/util/cloudformation.js";
3773
+ import { ToolkitInfo as ToolkitInfo2 } from "sst-aws-cdk/lib/api/toolkit-info.js";
3774
+ import { addMetadataAssetsToManifest as addMetadataAssetsToManifest2 } from "sst-aws-cdk/lib/assets.js";
3775
+ import { publishAssets as publishAssets3 } from "sst-aws-cdk/lib/util/asset-publishing.js";
3776
+ import { AssetManifestBuilder as AssetManifestBuilder2 } from "sst-aws-cdk/lib/util/asset-manifest-builder.js";
3770
3777
  async function publishDeployAssets(sdkProvider, options) {
3771
3778
  const {
3772
3779
  deployment,
@@ -5264,7 +5271,7 @@ var init_java = __esm({
5264
5271
  });
5265
5272
 
5266
5273
  // src/stacks/synth.ts
5267
- import * as contextproviders from "aws-cdk/lib/context-providers/index.js";
5274
+ import * as contextproviders from "sst-aws-cdk/lib/context-providers/index.js";
5268
5275
  import path15 from "path";
5269
5276
  async function synth(opts) {
5270
5277
  Logger.debug("Synthesizing stacks...");
@@ -5280,7 +5287,7 @@ async function synth(opts) {
5280
5287
  useJavaHandler2();
5281
5288
  useDotnetHandler();
5282
5289
  useRustHandler2();
5283
- const { Configuration } = await import("aws-cdk/lib/settings.js");
5290
+ const { Configuration } = await import("sst-aws-cdk/lib/settings.js");
5284
5291
  const project = useProject();
5285
5292
  const identity = await useSTSIdentity();
5286
5293
  opts = {
@@ -5299,7 +5306,7 @@ async function synth(opts) {
5299
5306
  region: project.config.region,
5300
5307
  mode: opts.mode,
5301
5308
  debugIncreaseTimeout: opts.increaseTimeout,
5302
- skipBuild: opts.mode === "remove"
5309
+ isActiveStack: opts.isActiveStack
5303
5310
  },
5304
5311
  {
5305
5312
  outdir: opts.buildDir,
@@ -5604,7 +5611,7 @@ async function bootstrapSST() {
5604
5611
  path16.resolve(__dirname2, "support/bootstrap-metadata-function")
5605
5612
  ),
5606
5613
  handler: "index.handler",
5607
- runtime: region?.startsWith("us-gov-") ? Runtime2.NODEJS_16_X : Runtime2.NODEJS_18_X,
5614
+ runtime: region?.startsWith("us-gov-") || region?.startsWith("cn-") ? Runtime2.NODEJS_16_X : Runtime2.NODEJS_18_X,
5608
5615
  environment: {
5609
5616
  BUCKET_NAME: bucket.bucketName
5610
5617
  },
@@ -6110,7 +6117,7 @@ var init_deploy2 = __esm({
6110
6117
  evt.LogicalResourceId
6111
6118
  );
6112
6119
  return /* @__PURE__ */ React.createElement(Box, { key: index }, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Spinner, null), " ", readable ? `${stackNameToId(evt.StackName)} ${readable} ${evt.ResourceType}` : `${stackNameToId(evt.StackName)} ${evt.ResourceType}`, " "), /* @__PURE__ */ React.createElement(Text, { color: color(evt.ResourceStatus || "") }, evt.ResourceStatus));
6113
- }), Object.entries(resources).length === 0 && /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Spinner, null), " ", /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "Deploying..."))));
6120
+ }), Object.entries(resources).length === 0 && /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Spinner, null), " ", /* @__PURE__ */ React.createElement(Text, { dimColor: true }, props.remove ? "Removing..." : "Deploying..."))));
6114
6121
  };
6115
6122
  }
6116
6123
  });
@@ -7266,6 +7273,7 @@ var deploy2 = (program2) => program2.command(
7266
7273
  Colors.line(` ${Colors.bold("Region:")} ${project.config.region}`);
7267
7274
  Colors.line(` ${Colors.bold("Account:")} ${identity.Account}`);
7268
7275
  Colors.gap();
7276
+ const isActiveStack = (stackId) => !args.filter || stackId.toLowerCase().replace(project.config.name.toLowerCase(), "").replace(project.config.stage.toLowerCase(), "").includes(args.filter.toLowerCase());
7269
7277
  const assembly = await async function() {
7270
7278
  if (args.from) {
7271
7279
  const result2 = await loadAssembly2(args.from);
@@ -7276,14 +7284,13 @@ var deploy2 = (program2) => program2.command(
7276
7284
  });
7277
7285
  const result = await Stacks.synth({
7278
7286
  fn: project.stacks,
7279
- mode: "deploy"
7287
+ mode: "deploy",
7288
+ isActiveStack
7280
7289
  });
7281
7290
  spinner.succeed();
7282
7291
  return result;
7283
7292
  }();
7284
- const target = assembly.stacks.filter(
7285
- (s) => !args.filter || s.id.toLowerCase().replace(project.config.name.toLowerCase(), "").replace(project.config.stage.toLowerCase(), "").includes(args.filter.toLowerCase())
7286
- );
7293
+ const target = assembly.stacks.filter((s) => isActiveStack(s.id));
7287
7294
  if (!target.length) {
7288
7295
  Colors.line(`No stacks found matching ${blue4(args.filter)}`);
7289
7296
  process.exit(1);
@@ -7370,7 +7377,9 @@ var remove2 = (program2) => program2.command(
7370
7377
  console.log(`No stacks found matching ${blue4(args.filter)}`);
7371
7378
  process.exit(1);
7372
7379
  }
7373
- const component = render(/* @__PURE__ */ React2.createElement(DeploymentUI2, { assembly }));
7380
+ const component = render(
7381
+ /* @__PURE__ */ React2.createElement(DeploymentUI2, { assembly, remove: true })
7382
+ );
7374
7383
  const results = await Stacks.removeMany(target);
7375
7384
  component.clear();
7376
7385
  component.unmount();
package/stacks/synth.d.ts CHANGED
@@ -2,10 +2,10 @@ import type { App } from "../constructs/App.js";
2
2
  interface SynthOptions {
3
3
  buildDir?: string;
4
4
  outDir?: string;
5
- skipBuild?: boolean;
6
5
  increaseTimeout?: boolean;
7
6
  mode: App["mode"];
8
7
  fn: (app: App) => Promise<void> | void;
8
+ isActiveStack?: (stackName: string) => boolean;
9
9
  }
10
10
  export declare function synth(opts: SynthOptions): Promise<import("aws-cdk-lib/cx-api").CloudAssembly>;
11
11
  export {};