sst 2.1.35 → 2.2.1

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.
Files changed (41) hide show
  1. package/bootstrap.js +1 -1
  2. package/cdk/cloudformation-deployments-wrapper.d.ts +1 -1
  3. package/cdk/cloudformation-deployments-wrapper.js +6 -6
  4. package/cdk/cloudformation-deployments.d.ts +8 -8
  5. package/cdk/cloudformation-deployments.js +7 -7
  6. package/cdk/deploy-stack.d.ts +6 -6
  7. package/cdk/deploy-stack.js +9 -9
  8. package/cli/colors.d.ts +9 -20
  9. package/cli/commands/deploy.js +8 -6
  10. package/cli/commands/remove.js +1 -1
  11. package/cli/ui/deploy.d.ts +1 -0
  12. package/cli/ui/deploy.js +1 -1
  13. package/constructs/App.d.ts +4 -27
  14. package/constructs/App.js +5 -31
  15. package/constructs/Cron.d.ts +1 -1
  16. package/constructs/EventBus.d.ts +68 -35
  17. package/constructs/EventBus.js +13 -4
  18. package/constructs/Function.js +36 -33
  19. package/constructs/Job.js +6 -5
  20. package/constructs/RDS.js +4 -8
  21. package/constructs/Script.js +1 -1
  22. package/constructs/SsrSite.js +3 -1
  23. package/constructs/Stack.d.ts +8 -0
  24. package/constructs/Stack.js +17 -8
  25. package/constructs/StaticSite.js +3 -1
  26. package/constructs/deprecated/NextjsSite.js +2 -1
  27. package/credentials.d.ts +1 -1
  28. package/credentials.js +1 -1
  29. package/node/future/auth/index.d.ts +1 -0
  30. package/node/future/auth/session.js +1 -8
  31. package/package.json +8 -12
  32. package/runtime/handlers/node.js +0 -1
  33. package/runtime/server.js +4 -2
  34. package/sst.mjs +40 -37
  35. package/stacks/synth.d.ts +1 -1
  36. package/stacks/synth.js +3 -3
  37. package/support/bootstrap-metadata-function/index.mjs +1027 -274
  38. package/support/bridge/bridge.mjs +46 -35
  39. package/support/custom-resources/index.mjs +1663 -910
  40. package/support/nodejs-runtime/index.mjs +38 -2
  41. package/support/python-runtime/runtime.py +10 -4
@@ -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();
@@ -6,5 +6,6 @@ export * from "./adapter/google.js";
6
6
  export * from "./adapter/link.js";
7
7
  export * from "./adapter/github.js";
8
8
  export * from "./adapter/oauth.js";
9
+ export type { Adapter } from "./adapter/adapter.js";
9
10
  export * from "./session.js";
10
11
  export * from "./handler.js";
@@ -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.35",
3
+ "version": "2.2.1",
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-3",
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"
@@ -33,7 +33,6 @@ export const useNodeHandler = Context.memo(async () => {
33
33
  new Promise(async () => {
34
34
  const worker = new Worker(url.fileURLToPath(new URL("../../support/nodejs-runtime/index.mjs", import.meta.url)), {
35
35
  env: {
36
- ...process.env,
37
36
  ...input.environment,
38
37
  IS_LOCAL: "true",
39
38
  },
package/runtime/server.js CHANGED
@@ -73,8 +73,10 @@ export const useRuntimeServer = Context.memo(async () => {
73
73
  "Lambda-Runtime-Aws-Request-Id": payload.context.awsRequestId,
74
74
  "Lambda-Runtime-Deadline-Ms": Date.now() + payload.deadline,
75
75
  "Lambda-Runtime-Invoked-Function-Arn": payload.context.invokedFunctionArn,
76
- "Lambda-Runtime-Client-Context": JSON.stringify(payload.context.clientContext || {}),
77
- "Lambda-Runtime-Cognito-Identity": JSON.stringify(payload.context.identity || {}),
76
+ "Lambda-Runtime-Client-Context": JSON.stringify(payload.context.clientContext || null),
77
+ "Lambda-Runtime-Cognito-Identity": JSON.stringify(payload.context.identity || null),
78
+ "Lambda-Runtime-Log-Group-Name": payload.context.logGroupName,
79
+ "Lambda-Runtime-Log-Stream-Name": payload.context.logStreamName,
78
80
  });
79
81
  res.json(payload.event);
80
82
  });
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";
@@ -2415,11 +2415,13 @@ var init_server2 = __esm({
2415
2415
  "Lambda-Runtime-Deadline-Ms": Date.now() + payload.deadline,
2416
2416
  "Lambda-Runtime-Invoked-Function-Arn": payload.context.invokedFunctionArn,
2417
2417
  "Lambda-Runtime-Client-Context": JSON.stringify(
2418
- payload.context.clientContext || {}
2418
+ payload.context.clientContext || null
2419
2419
  ),
2420
2420
  "Lambda-Runtime-Cognito-Identity": JSON.stringify(
2421
- payload.context.identity || {}
2422
- )
2421
+ payload.context.identity || null
2422
+ ),
2423
+ "Lambda-Runtime-Log-Group-Name": payload.context.logGroupName,
2424
+ "Lambda-Runtime-Log-Stream-Name": payload.context.logStreamName
2423
2425
  });
2424
2426
  res.json(payload.event);
2425
2427
  }
@@ -2917,14 +2919,14 @@ var init_util = __esm({
2917
2919
  import * as cxapi from "@aws-cdk/cx-api";
2918
2920
  import fs8 from "fs/promises";
2919
2921
  import * as uuid from "uuid";
2920
- import { addMetadataAssetsToManifest } from "aws-cdk/lib/assets.js";
2921
- import { debug, error, print } from "aws-cdk/lib/logging.js";
2922
- import { toYAML } from "aws-cdk/lib/serialize.js";
2923
- import { AssetManifestBuilder } from "aws-cdk/lib/util/asset-manifest-builder.js";
2924
- import { publishAssets } from "aws-cdk/lib/util/asset-publishing.js";
2925
- import { contentHash } from "aws-cdk/lib/util/content-hash.js";
2926
- import { CfnEvaluationException } from "aws-cdk/lib/api/evaluate-cloudformation-template.js";
2927
- import { tryHotswapDeployment } from "aws-cdk/lib/api/hotswap-deployments.js";
2922
+ import { addMetadataAssetsToManifest } from "sst-aws-cdk/lib/assets.js";
2923
+ import { debug, error, print } from "sst-aws-cdk/lib/logging.js";
2924
+ import { toYAML } from "sst-aws-cdk/lib/serialize.js";
2925
+ import { AssetManifestBuilder } from "sst-aws-cdk/lib/util/asset-manifest-builder.js";
2926
+ import { publishAssets } from "sst-aws-cdk/lib/util/asset-publishing.js";
2927
+ import { contentHash } from "sst-aws-cdk/lib/util/content-hash.js";
2928
+ import { CfnEvaluationException } from "sst-aws-cdk/lib/api/evaluate-cloudformation-template.js";
2929
+ import { tryHotswapDeployment } from "sst-aws-cdk/lib/api/hotswap-deployments.js";
2928
2930
  import {
2929
2931
  changeSetHasNoChanges,
2930
2932
  CloudFormationStack,
@@ -2932,7 +2934,7 @@ import {
2932
2934
  waitForChangeSet,
2933
2935
  waitForStackDeploy,
2934
2936
  waitForStackDelete
2935
- } from "aws-cdk/lib/api/util/cloudformation.js";
2937
+ } from "sst-aws-cdk/lib/api/util/cloudformation.js";
2936
2938
  import { blue as blue2 } from "colorette";
2937
2939
  async function deployStack(options) {
2938
2940
  const stackArtifact = options.stack;
@@ -3441,21 +3443,21 @@ __export(cloudformation_deployments_exports, {
3441
3443
  });
3442
3444
  import * as cxapi2 from "@aws-cdk/cx-api";
3443
3445
  import { AssetManifest } from "cdk-assets";
3444
- import { debug as debug2, warning } from "aws-cdk/lib/logging.js";
3446
+ import { debug as debug2, warning } from "sst-aws-cdk/lib/logging.js";
3445
3447
  import {
3446
3448
  buildAssets,
3447
3449
  publishAssets as publishAssets2
3448
- } from "aws-cdk/lib/util/asset-publishing.js";
3449
- import { Mode } from "aws-cdk/lib/api/aws-auth/credentials.js";
3450
+ } from "sst-aws-cdk/lib/util/asset-publishing.js";
3451
+ import { Mode } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
3450
3452
  import {
3451
3453
  loadCurrentTemplateWithNestedStacks,
3452
3454
  loadCurrentTemplate
3453
- } from "aws-cdk/lib/api/nested-stack-helpers.js";
3454
- import { ToolkitInfo } from "aws-cdk/lib/api/toolkit-info.js";
3455
+ } from "sst-aws-cdk/lib/api/nested-stack-helpers.js";
3456
+ import { ToolkitInfo } from "sst-aws-cdk/lib/api/toolkit-info.js";
3455
3457
  import {
3456
3458
  CloudFormationStack as CloudFormationStack2
3457
- } from "aws-cdk/lib/api/util/cloudformation.js";
3458
- import { replaceEnvPlaceholders } from "aws-cdk/lib/api/util/placeholders.js";
3459
+ } from "sst-aws-cdk/lib/api/util/cloudformation.js";
3460
+ import { replaceEnvPlaceholders } from "sst-aws-cdk/lib/api/util/placeholders.js";
3459
3461
  async function prepareSdkWithLookupRoleFor(sdkProvider, stack) {
3460
3462
  const resolvedEnvironment = await sdkProvider.resolveEnvironment(
3461
3463
  stack.environment
@@ -3764,16 +3766,16 @@ var cloudformation_deployments_wrapper_exports = {};
3764
3766
  __export(cloudformation_deployments_wrapper_exports, {
3765
3767
  publishDeployAssets: () => publishDeployAssets
3766
3768
  });
3767
- import { debug as debug3 } from "aws-cdk/lib/logging.js";
3769
+ import { debug as debug3 } from "sst-aws-cdk/lib/logging.js";
3768
3770
  import {
3769
3771
  CloudFormationStack as CloudFormationStack3,
3770
3772
  TemplateParameters as TemplateParameters2,
3771
3773
  waitForStackDelete as waitForStackDelete2
3772
- } from "aws-cdk/lib/api/util/cloudformation.js";
3773
- import { ToolkitInfo as ToolkitInfo2 } from "aws-cdk/lib/api/toolkit-info.js";
3774
- import { addMetadataAssetsToManifest as addMetadataAssetsToManifest2 } from "aws-cdk/lib/assets.js";
3775
- import { publishAssets as publishAssets3 } from "aws-cdk/lib/util/asset-publishing.js";
3776
- import { AssetManifestBuilder as AssetManifestBuilder2 } from "aws-cdk/lib/util/asset-manifest-builder.js";
3774
+ } from "sst-aws-cdk/lib/api/util/cloudformation.js";
3775
+ import { ToolkitInfo as ToolkitInfo2 } from "sst-aws-cdk/lib/api/toolkit-info.js";
3776
+ import { addMetadataAssetsToManifest as addMetadataAssetsToManifest2 } from "sst-aws-cdk/lib/assets.js";
3777
+ import { publishAssets as publishAssets3 } from "sst-aws-cdk/lib/util/asset-publishing.js";
3778
+ import { AssetManifestBuilder as AssetManifestBuilder2 } from "sst-aws-cdk/lib/util/asset-manifest-builder.js";
3777
3779
  async function publishDeployAssets(sdkProvider, options) {
3778
3780
  const {
3779
3781
  deployment,
@@ -4525,7 +4527,6 @@ var init_node = __esm({
4525
4527
  ),
4526
4528
  {
4527
4529
  env: {
4528
- ...process.env,
4529
4530
  ...input.environment,
4530
4531
  IS_LOCAL: "true"
4531
4532
  },
@@ -5271,7 +5272,7 @@ var init_java = __esm({
5271
5272
  });
5272
5273
 
5273
5274
  // src/stacks/synth.ts
5274
- import * as contextproviders from "aws-cdk/lib/context-providers/index.js";
5275
+ import * as contextproviders from "sst-aws-cdk/lib/context-providers/index.js";
5275
5276
  import path15 from "path";
5276
5277
  async function synth(opts) {
5277
5278
  Logger.debug("Synthesizing stacks...");
@@ -5287,7 +5288,7 @@ async function synth(opts) {
5287
5288
  useJavaHandler2();
5288
5289
  useDotnetHandler();
5289
5290
  useRustHandler2();
5290
- const { Configuration } = await import("aws-cdk/lib/settings.js");
5291
+ const { Configuration } = await import("sst-aws-cdk/lib/settings.js");
5291
5292
  const project = useProject();
5292
5293
  const identity = await useSTSIdentity();
5293
5294
  opts = {
@@ -5306,7 +5307,7 @@ async function synth(opts) {
5306
5307
  region: project.config.region,
5307
5308
  mode: opts.mode,
5308
5309
  debugIncreaseTimeout: opts.increaseTimeout,
5309
- skipBuild: opts.mode === "remove"
5310
+ isActiveStack: opts.isActiveStack
5310
5311
  },
5311
5312
  {
5312
5313
  outdir: opts.buildDir,
@@ -5611,7 +5612,7 @@ async function bootstrapSST() {
5611
5612
  path16.resolve(__dirname2, "support/bootstrap-metadata-function")
5612
5613
  ),
5613
5614
  handler: "index.handler",
5614
- runtime: region?.startsWith("us-gov-") ? Runtime2.NODEJS_16_X : Runtime2.NODEJS_18_X,
5615
+ runtime: region?.startsWith("us-gov-") || region?.startsWith("cn-") ? Runtime2.NODEJS_16_X : Runtime2.NODEJS_18_X,
5615
5616
  environment: {
5616
5617
  BUCKET_NAME: bucket.bucketName
5617
5618
  },
@@ -6117,7 +6118,7 @@ var init_deploy2 = __esm({
6117
6118
  evt.LogicalResourceId
6118
6119
  );
6119
6120
  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));
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 }, "Deploying..."))));
6121
+ }), 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..."))));
6121
6122
  };
6122
6123
  }
6123
6124
  });
@@ -7273,6 +7274,7 @@ var deploy2 = (program2) => program2.command(
7273
7274
  Colors.line(` ${Colors.bold("Region:")} ${project.config.region}`);
7274
7275
  Colors.line(` ${Colors.bold("Account:")} ${identity.Account}`);
7275
7276
  Colors.gap();
7277
+ const isActiveStack = (stackId) => !args.filter || stackId.toLowerCase().replace(project.config.name.toLowerCase(), "").replace(project.config.stage.toLowerCase(), "").includes(args.filter.toLowerCase());
7276
7278
  const assembly = await async function() {
7277
7279
  if (args.from) {
7278
7280
  const result2 = await loadAssembly2(args.from);
@@ -7283,14 +7285,13 @@ var deploy2 = (program2) => program2.command(
7283
7285
  });
7284
7286
  const result = await Stacks.synth({
7285
7287
  fn: project.stacks,
7286
- mode: "deploy"
7288
+ mode: "deploy",
7289
+ isActiveStack
7287
7290
  });
7288
7291
  spinner.succeed();
7289
7292
  return result;
7290
7293
  }();
7291
- const target = assembly.stacks.filter(
7292
- (s) => !args.filter || s.id.toLowerCase().replace(project.config.name.toLowerCase(), "").replace(project.config.stage.toLowerCase(), "").includes(args.filter.toLowerCase())
7293
- );
7294
+ const target = assembly.stacks.filter((s) => isActiveStack(s.id));
7294
7295
  if (!target.length) {
7295
7296
  Colors.line(`No stacks found matching ${blue4(args.filter)}`);
7296
7297
  process.exit(1);
@@ -7377,7 +7378,9 @@ var remove2 = (program2) => program2.command(
7377
7378
  console.log(`No stacks found matching ${blue4(args.filter)}`);
7378
7379
  process.exit(1);
7379
7380
  }
7380
- const component = render(/* @__PURE__ */ React2.createElement(DeploymentUI2, { assembly }));
7381
+ const component = render(
7382
+ /* @__PURE__ */ React2.createElement(DeploymentUI2, { assembly, remove: true })
7383
+ );
7381
7384
  const results = await Stacks.removeMany(target);
7382
7385
  component.clear();
7383
7386
  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 {};