sst 2.48.5 → 2.49.2

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/bootstrap.js CHANGED
@@ -21,7 +21,7 @@ const SST_STACK_NAME = "SSTBootstrap";
21
21
  const SST_STACK_DESCRIPTION = "This stack includes resources needed to deploy SST apps into this environment";
22
22
  const OUTPUT_VERSION = "Version";
23
23
  const OUTPUT_BUCKET = "BucketName";
24
- const LATEST_VERSION = "7.3";
24
+ const LATEST_VERSION = "7.4";
25
25
  const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
26
26
  export const useBootstrap = lazy(async () => {
27
27
  Logger.debug("Initializing bootstrap context");
package/credentials.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { SdkProvider } from "sst-aws-cdk/lib/api/aws-auth/sdk-provider.js";
1
+ import type { AwsCredentialIdentityProvider } from "@aws-sdk/types";
2
2
  export type {} from "@smithy/types";
3
- export declare const useAWSCredentialsProvider: () => import("@smithy/types").AwsCredentialIdentityProvider;
4
- export declare const useAWSCredentials: () => Promise<import("@smithy/types").AwsCredentialIdentity>;
3
+ export declare const useAWSCredentialsProvider: () => AwsCredentialIdentityProvider;
4
+ export declare const useAWSCredentials: () => Promise<import("@aws-sdk/types").AwsCredentialIdentity>;
5
5
  export declare const useSTSIdentity: () => Promise<import("@aws-sdk/client-sts").GetCallerIdentityCommandOutput>;
6
6
  export declare function useAWSClient<C extends any>(client: new (config: any) => C, force?: boolean): C;
7
- export declare const useAWSProvider: () => Promise<SdkProvider>;
7
+ export declare const useAWSProvider: () => Promise<any>;
package/credentials.js CHANGED
@@ -1,7 +1,7 @@
1
+ import path from "path";
1
2
  import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
2
3
  import { GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts";
3
4
  import { Logger } from "./logger.js";
4
- import { SdkProvider } from "sst-aws-cdk/lib/api/aws-auth/sdk-provider.js";
5
5
  import { StandardRetryStrategy } from "@aws-sdk/middleware-retry";
6
6
  // @ts-expect-error
7
7
  import stupid from "aws-sdk/lib/maintenance_mode_message.js";
@@ -12,7 +12,7 @@ export const useAWSCredentialsProvider = lazy(() => {
12
12
  const project = useProject();
13
13
  Logger.debug("Using AWS profile", project.config.profile);
14
14
  const provider = fromNodeProviderChain({
15
- parentClientConfig: { region: project.config.region },
15
+ clientConfig: { region: project.config.region },
16
16
  profile: project.config.profile,
17
17
  roleArn: project.config.role,
18
18
  mfaCodeProvider: async (serialArn) => {
@@ -120,6 +120,17 @@ export function useAWSClient(client, force = false) {
120
120
  return result;
121
121
  }
122
122
  export const useAWSProvider = lazy(async () => {
123
+ const cdkToolkitUrl = await import.meta.resolve("@aws-cdk/toolkit-lib");
124
+ const cdkToolkitPath = new URL(cdkToolkitUrl).pathname;
125
+ const { SdkProvider } = await import(path.resolve(cdkToolkitPath, "..", "api", "aws-auth", "sdk-provider.js"));
126
+ const { IoHelper } = await import(path.resolve(cdkToolkitPath, "..", "api", "io", "private", "io-helper.js"));
123
127
  const project = useProject();
124
- return new SdkProvider(useAWSCredentialsProvider(), project.config.region);
128
+ return new SdkProvider(useAWSCredentialsProvider(), project.config.region, {
129
+ ioHelper: IoHelper.fromActionAwareIoHost({
130
+ //notify: (msg: IoMessage<unknown>) => console.log("!@#!@#! NOTIFY", msg),
131
+ notify: (msg) => { },
132
+ //requestResponse: <T>(msg: IoRequest<unknown, T>) => ioHost.requestResponse({ ...msg }),
133
+ requestResponse: (msg) => { },
134
+ }),
135
+ });
125
136
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.48.5",
4
+ "version": "2.49.2",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -25,39 +25,40 @@
25
25
  },
26
26
  "homepage": "https://sst.dev",
27
27
  "dependencies": {
28
- "@aws-cdk/aws-lambda-python-alpha": "2.179.0-alpha.0",
29
- "@aws-cdk/cloud-assembly-schema": "39.2.20",
30
- "@aws-cdk/cloudformation-diff": "2.179.0",
31
- "@aws-cdk/cx-api": "2.179.0",
28
+ "@aws-cdk/aws-lambda-python-alpha": "2.201.0-alpha.0",
29
+ "@aws-cdk/cloud-assembly-schema": "44.5.0",
30
+ "@aws-cdk/cloudformation-diff": "2.182.0",
31
+ "@aws-cdk/cx-api": "2.201.0",
32
+ "@aws-cdk/toolkit-lib": "1.1.1",
32
33
  "@aws-crypto/sha256-js": "^5.2.0",
33
- "@aws-sdk/client-cloudformation": "^3.454.0",
34
- "@aws-sdk/client-ecs": "^3.454.0",
35
- "@aws-sdk/client-eventbridge": "^3.454.0",
36
- "@aws-sdk/client-iam": "^3.454.0",
37
- "@aws-sdk/client-iot": "^3.454.0",
38
- "@aws-sdk/client-iot-data-plane": "^3.454.0",
39
- "@aws-sdk/client-lambda": "^3.454.0",
40
- "@aws-sdk/client-rds-data": "^3.454.0",
41
- "@aws-sdk/client-s3": "^3.454.0",
42
- "@aws-sdk/client-ssm": "^3.454.0",
43
- "@aws-sdk/client-sts": "^3.454.0",
44
- "@aws-sdk/config-resolver": "^3.374.0",
45
- "@aws-sdk/credential-providers": "^3.454.0",
46
- "@aws-sdk/middleware-retry": "^3.374.0",
47
- "@aws-sdk/middleware-signing": "^3.451.0",
48
- "@aws-sdk/signature-v4-crt": "^3.451.0",
49
- "@aws-sdk/smithy-client": "^3.374.0",
34
+ "@aws-sdk/client-cloudformation": "3.699.0",
35
+ "@aws-sdk/client-ecs": "3.699.0",
36
+ "@aws-sdk/client-eventbridge": "3.699.0",
37
+ "@aws-sdk/client-iam": "3.699.0",
38
+ "@aws-sdk/client-iot": "3.699.0",
39
+ "@aws-sdk/client-iot-data-plane": "3.699.0",
40
+ "@aws-sdk/client-lambda": "3.699.0",
41
+ "@aws-sdk/client-rds-data": "3.699.0",
42
+ "@aws-sdk/client-s3": "3.699.0",
43
+ "@aws-sdk/client-ssm": "3.699.0",
44
+ "@aws-sdk/client-sts": "3.699.0",
45
+ "@aws-sdk/config-resolver": "3.374.0",
46
+ "@aws-sdk/credential-providers": "3.699.0",
47
+ "@aws-sdk/middleware-retry": "3.374.0",
48
+ "@aws-sdk/middleware-signing": "3.451.0",
49
+ "@aws-sdk/signature-v4-crt": "3.451.0",
50
+ "@aws-sdk/smithy-client": "3.374.0",
50
51
  "@babel/core": "^7.0.0-0",
51
52
  "@babel/generator": "^7.20.5",
52
53
  "@babel/plugin-syntax-typescript": "^7.21.4",
53
- "@smithy/signature-v4": "^2.0.16",
54
- "@trpc/server": "9.16.0",
54
+ "@smithy/signature-v4": "2.0.16",
55
+ "@trpc/server": "9.18.0",
55
56
  "adm-zip": "0.5.14",
56
- "aws-cdk-lib": "2.179.0",
57
+ "aws-cdk-lib": "2.201.0",
57
58
  "aws-iot-device-sdk": "^2.2.13",
58
59
  "aws-sdk": "^2.1501.0",
59
60
  "builtin-modules": "3.2.0",
60
- "cdk-assets": "3.0.0-rc.143",
61
+ "cdk-assets": "3.3.1",
61
62
  "chalk": "^5.2.0",
62
63
  "chokidar": "^3.5.3",
63
64
  "ci-info": "^3.7.0",
@@ -85,7 +86,6 @@
85
86
  "ora": "^6.1.2",
86
87
  "react": "^18.0.0",
87
88
  "remeda": "^1.3.0",
88
- "sst-aws-cdk": "2.179.0-3",
89
89
  "tree-kill": "^1.2.2",
90
90
  "undici": "^5.12.0",
91
91
  "uuid": "^9.0.0",
@@ -94,11 +94,11 @@
94
94
  "zod": "^3.21.4"
95
95
  },
96
96
  "devDependencies": {
97
- "@aws-sdk/client-api-gateway": "^3.454.0",
98
- "@aws-sdk/client-cloudfront": "^3.454.0",
99
- "@aws-sdk/client-codebuild": "^3.454.0",
100
- "@aws-sdk/client-sqs": "^3.454.0",
101
- "@aws-sdk/types": "^3.451.0",
97
+ "@aws-sdk/client-api-gateway": "3.699.0",
98
+ "@aws-sdk/client-cloudfront": "3.699.0",
99
+ "@aws-sdk/client-codebuild": "3.699.0",
100
+ "@aws-sdk/client-sqs": "3.699.0",
101
+ "@aws-sdk/types": "3.451.0",
102
102
  "@graphql-tools/merge": "^8.3.16",
103
103
  "@sls-next/lambda-at-edge": "^3.7.0",
104
104
  "@smithy/types": "4.1.0",
@@ -115,7 +115,7 @@
115
115
  "@types/node": "18.11.9",
116
116
  "@types/react": "^18.0.28",
117
117
  "@types/uuid": "^8.3.4",
118
- "@types/ws": "^8.5.3",
118
+ "@types/ws": "8.5.3",
119
119
  "@types/yargs": "^17.0.13",
120
120
  "archiver": "^5.3.1",
121
121
  "astro-sst": "2.45.1",
package/package.json.bak CHANGED
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "sideEffects": false,
7
7
  "name": "sst",
8
- "version": "2.48.5",
8
+ "version": "2.49.2",
9
9
  "bin": {
10
10
  "sst": "cli/sst.js"
11
11
  },
@@ -35,39 +35,40 @@
35
35
  },
36
36
  "homepage": "https://sst.dev",
37
37
  "dependencies": {
38
- "@aws-cdk/aws-lambda-python-alpha": "2.179.0-alpha.0",
39
- "@aws-cdk/cloud-assembly-schema": "39.2.20",
40
- "@aws-cdk/cloudformation-diff": "2.179.0",
41
- "@aws-cdk/cx-api": "2.179.0",
38
+ "@aws-cdk/aws-lambda-python-alpha": "2.201.0-alpha.0",
39
+ "@aws-cdk/cloud-assembly-schema": "44.5.0",
40
+ "@aws-cdk/cloudformation-diff": "2.182.0",
41
+ "@aws-cdk/cx-api": "2.201.0",
42
+ "@aws-cdk/toolkit-lib": "1.1.1",
42
43
  "@aws-crypto/sha256-js": "^5.2.0",
43
- "@aws-sdk/client-cloudformation": "^3.454.0",
44
- "@aws-sdk/client-ecs": "^3.454.0",
45
- "@aws-sdk/client-eventbridge": "^3.454.0",
46
- "@aws-sdk/client-iam": "^3.454.0",
47
- "@aws-sdk/client-iot": "^3.454.0",
48
- "@aws-sdk/client-iot-data-plane": "^3.454.0",
49
- "@aws-sdk/client-lambda": "^3.454.0",
50
- "@aws-sdk/client-rds-data": "^3.454.0",
51
- "@aws-sdk/client-s3": "^3.454.0",
52
- "@aws-sdk/client-ssm": "^3.454.0",
53
- "@aws-sdk/client-sts": "^3.454.0",
54
- "@aws-sdk/config-resolver": "^3.374.0",
55
- "@aws-sdk/credential-providers": "^3.454.0",
56
- "@aws-sdk/middleware-retry": "^3.374.0",
57
- "@aws-sdk/middleware-signing": "^3.451.0",
58
- "@aws-sdk/signature-v4-crt": "^3.451.0",
59
- "@aws-sdk/smithy-client": "^3.374.0",
44
+ "@aws-sdk/client-cloudformation": "3.699.0",
45
+ "@aws-sdk/client-ecs": "3.699.0",
46
+ "@aws-sdk/client-eventbridge": "3.699.0",
47
+ "@aws-sdk/client-iam": "3.699.0",
48
+ "@aws-sdk/client-iot": "3.699.0",
49
+ "@aws-sdk/client-iot-data-plane": "3.699.0",
50
+ "@aws-sdk/client-lambda": "3.699.0",
51
+ "@aws-sdk/client-rds-data": "3.699.0",
52
+ "@aws-sdk/client-s3": "3.699.0",
53
+ "@aws-sdk/client-ssm": "3.699.0",
54
+ "@aws-sdk/client-sts": "3.699.0",
55
+ "@aws-sdk/config-resolver": "3.374.0",
56
+ "@aws-sdk/credential-providers": "3.699.0",
57
+ "@aws-sdk/middleware-retry": "3.374.0",
58
+ "@aws-sdk/middleware-signing": "3.451.0",
59
+ "@aws-sdk/signature-v4-crt": "3.451.0",
60
+ "@aws-sdk/smithy-client": "3.374.0",
60
61
  "@babel/core": "^7.0.0-0",
61
62
  "@babel/generator": "^7.20.5",
62
63
  "@babel/plugin-syntax-typescript": "^7.21.4",
63
- "@smithy/signature-v4": "^2.0.16",
64
- "@trpc/server": "9.16.0",
64
+ "@smithy/signature-v4": "2.0.16",
65
+ "@trpc/server": "9.18.0",
65
66
  "adm-zip": "0.5.14",
66
- "aws-cdk-lib": "2.179.0",
67
+ "aws-cdk-lib": "2.201.0",
67
68
  "aws-iot-device-sdk": "^2.2.13",
68
69
  "aws-sdk": "^2.1501.0",
69
70
  "builtin-modules": "3.2.0",
70
- "cdk-assets": "3.0.0-rc.143",
71
+ "cdk-assets": "3.3.1",
71
72
  "chalk": "^5.2.0",
72
73
  "chokidar": "^3.5.3",
73
74
  "ci-info": "^3.7.0",
@@ -95,7 +96,6 @@
95
96
  "ora": "^6.1.2",
96
97
  "react": "^18.0.0",
97
98
  "remeda": "^1.3.0",
98
- "sst-aws-cdk": "2.179.0-3",
99
99
  "tree-kill": "^1.2.2",
100
100
  "undici": "^5.12.0",
101
101
  "uuid": "^9.0.0",
@@ -104,11 +104,11 @@
104
104
  "zod": "^3.21.4"
105
105
  },
106
106
  "devDependencies": {
107
- "@aws-sdk/client-api-gateway": "^3.454.0",
108
- "@aws-sdk/client-cloudfront": "^3.454.0",
109
- "@aws-sdk/client-codebuild": "^3.454.0",
110
- "@aws-sdk/client-sqs": "^3.454.0",
111
- "@aws-sdk/types": "^3.451.0",
107
+ "@aws-sdk/client-api-gateway": "3.699.0",
108
+ "@aws-sdk/client-cloudfront": "3.699.0",
109
+ "@aws-sdk/client-codebuild": "3.699.0",
110
+ "@aws-sdk/client-sqs": "3.699.0",
111
+ "@aws-sdk/types": "3.451.0",
112
112
  "@graphql-tools/merge": "^8.3.16",
113
113
  "@sls-next/lambda-at-edge": "^3.7.0",
114
114
  "@smithy/types": "4.1.0",
@@ -125,7 +125,7 @@
125
125
  "@types/node": "18.11.9",
126
126
  "@types/react": "^18.0.28",
127
127
  "@types/uuid": "^8.3.4",
128
- "@types/ws": "^8.5.3",
128
+ "@types/ws": "8.5.3",
129
129
  "@types/yargs": "^17.0.13",
130
130
  "archiver": "^5.3.1",
131
131
  "astro-sst": "2.45.1",
@@ -1,4 +1,4 @@
1
- import type { CloudFormationStackArtifact } from "aws-cdk-lib/cx-api";
1
+ import { type CloudFormationStackArtifact } from "aws-cdk-lib/cx-api";
2
2
  import { StackDeploymentResult } from "./monitor.js";
3
3
  export declare function publishAssets(stacks: CloudFormationStackArtifact[]): Promise<Record<string, any>>;
4
4
  export declare function deployMany(stacks: CloudFormationStackArtifact[]): Promise<Record<string, {
package/stacks/deploy.js CHANGED
@@ -1,3 +1,4 @@
1
+ import path from "path";
1
2
  import { useBus } from "../bus.js";
2
3
  import { useProject } from "../project.js";
3
4
  import { useAWSClient, useAWSProvider } from "../credentials.js";
@@ -6,23 +7,16 @@ import { filterOutputs, isFailed, monitor, } from "./monitor.js";
6
7
  import { VisibleError } from "../error.js";
7
8
  export async function publishAssets(stacks) {
8
9
  Logger.debug("Publishing assets");
9
- const provider = await useAWSProvider();
10
- const { publishDeployAssets } = await import("../cdk/deployments-wrapper.js");
11
10
  const results = {};
12
- for (const stack of stacks) {
13
- const stackTags = Object.entries(stack.tags ?? {}).map(([Key, Value]) => ({
14
- Key,
15
- Value,
16
- }));
17
- const result = await publishDeployAssets(provider, {
18
- stack: stack,
19
- quiet: false,
20
- deploymentMethod: {
21
- method: "direct",
22
- },
23
- tags: stackTags,
24
- });
25
- results[stack.stackName] = result;
11
+ for (const stackArtifact of stacks) {
12
+ const cfnStack = await getCloudFormationStack(stackArtifact);
13
+ await addInUseExports(stackArtifact, cfnStack);
14
+ const deployment = await createCdkDeployments();
15
+ await buildAndPublishAssets(deployment, stackArtifact);
16
+ results[stackArtifact.stackName] = {
17
+ isUpdate: cfnStack && cfnStack.StackStatus !== "REVIEW_IN_PROGRESS",
18
+ params: await buildCloudFormationStackParams(deployment, stackArtifact),
19
+ };
26
20
  }
27
21
  return results;
28
22
  }
@@ -80,38 +74,39 @@ export async function deploy(stack) {
80
74
  const bus = useBus();
81
75
  const { cdk } = useProject().config;
82
76
  Logger.debug("Deploying stack", stack.id);
83
- const provider = await useAWSProvider();
84
- const { Deployments } = await import("../cdk/deployments.js");
85
- const deployment = new Deployments({ sdkProvider: provider });
86
- const stackTags = Object.entries(stack.tags ?? {}).map(([Key, Value]) => ({
87
- Key,
88
- Value,
89
- }));
90
77
  try {
91
- await addInUseExports(stack);
78
+ const cfnStack = await getCloudFormationStack(stack);
79
+ await addInUseExports(stack, cfnStack);
92
80
  bus.publish("stack.status", {
93
81
  stackID: stack.stackName,
94
82
  status: "PUBLISH_ASSETS_IN_PROGRESS",
95
83
  });
96
- const result = await deployment.deployStack({
97
- stack: stack,
98
- quiet: true,
99
- tags: stackTags,
100
- deploymentMethod: {
101
- method: "direct",
102
- },
103
- toolkitStackName: cdk?.toolkitStackName,
104
- });
105
- if (result?.type === "did-deploy-stack" && result.noOp) {
106
- bus.publish("stack.status", {
107
- stackID: stack.stackName,
108
- status: "SKIPPED",
109
- });
110
- return {
111
- errors: {},
112
- outputs: filterOutputs(result.outputs),
113
- status: "SKIPPED",
114
- };
84
+ const deployment = await createCdkDeployments();
85
+ await buildAndPublishAssets(deployment, stack);
86
+ if (cfnStack?.StackStatus === "ROLLBACK_COMPLETE" ||
87
+ cfnStack?.StackStatus === "ROLLBACK_FAILED") {
88
+ await deleteCloudFormationStack(stack.stackName);
89
+ }
90
+ const stackParams = await buildCloudFormationStackParams(deployment, stack);
91
+ try {
92
+ cfnStack && cfnStack.StackStatus !== "REVIEW_IN_PROGRESS"
93
+ ? await updateCloudFormationStack(stackParams)
94
+ : await createCloudFormationStack(stackParams);
95
+ }
96
+ catch (e) {
97
+ if (e.name === "ValidationError" &&
98
+ e.message.includes("No updates are to be performed.")) {
99
+ bus.publish("stack.status", {
100
+ stackID: stack.stackName,
101
+ status: "SKIPPED",
102
+ });
103
+ return {
104
+ errors: {},
105
+ outputs: filterOutputs(Object.fromEntries((cfnStack.Outputs || []).map((o) => [o.OutputKey, o.OutputValue]))),
106
+ status: "SKIPPED",
107
+ };
108
+ }
109
+ throw e;
115
110
  }
116
111
  bus.publish("stack.updated", {
117
112
  stackID: stack.stackName,
@@ -136,11 +131,11 @@ export async function deploy(stack) {
136
131
  };
137
132
  }
138
133
  }
139
- async function addInUseExports(stack) {
140
- // Get old outputs
141
- const oldOutputs = await getCloudFormationStackOutputs(stack);
142
- if (!oldOutputs)
134
+ async function addInUseExports(stackArtifact, cfnStack) {
135
+ if (!cfnStack)
143
136
  return;
137
+ // Get old outputs
138
+ const oldOutputs = cfnStack.Outputs || [];
144
139
  // Get new exports
145
140
  // note: that we only want to handle outputs exported by CDK.
146
141
  // ie.
@@ -153,7 +148,7 @@ async function addInUseExports(stack) {
153
148
  // "Name": "frank-acme-auth:ExportsOutputRefauthUserPoolA78B038B8D9965B5"
154
149
  // }
155
150
  // },
156
- const newTemplate = JSON.parse(await getLocalTemplate(stack));
151
+ const newTemplate = JSON.parse(await getLocalTemplate(stackArtifact));
157
152
  const newOutputs = newTemplate.Outputs || {};
158
153
  const newExportNames = Object.keys(newOutputs)
159
154
  .filter((outputKey) => outputKey.startsWith("ExportsOutput"))
@@ -192,10 +187,72 @@ async function addInUseExports(stack) {
192
187
  }));
193
188
  // Save new template
194
189
  if (isDirty) {
195
- await saveLocalTemplate(stack, JSON.stringify(newTemplate, null, 2));
190
+ await saveLocalTemplate(stackArtifact, JSON.stringify(newTemplate, null, 2));
191
+ }
192
+ }
193
+ async function createCdkDeployments() {
194
+ const cdkToolkitUrl = await import.meta.resolve("@aws-cdk/toolkit-lib");
195
+ const cdkToolkitPath = new URL(cdkToolkitUrl).pathname;
196
+ const { Deployments } = await import(path.resolve(cdkToolkitPath, "..", "api", "deployments", "deployments.js"));
197
+ const { IoHelper } = await import(path.resolve(cdkToolkitPath, "..", "api", "io", "private", "io-helper.js"));
198
+ const provider = await useAWSProvider();
199
+ await useAWSProvider();
200
+ const ioHelper = IoHelper.fromActionAwareIoHost({
201
+ notify: (msg) => { },
202
+ requestResponse: (msg) => { },
203
+ });
204
+ return new Deployments({
205
+ sdkProvider: provider,
206
+ ioHelper,
207
+ });
208
+ }
209
+ async function buildAndPublishAssets(deployment, stackArtifact) {
210
+ const { AssetManifestArtifact } = await import("aws-cdk-lib/cx-api");
211
+ const { AssetManifest } = await import("cdk-assets");
212
+ for (const artifact of stackArtifact.dependencies) {
213
+ if (!AssetManifestArtifact.isAssetManifestArtifact(artifact))
214
+ continue;
215
+ const manifest = AssetManifest.fromFile(artifact.file);
216
+ for (const entry of manifest.entries) {
217
+ await deployment.buildSingleAsset(artifact, manifest, entry, {
218
+ stack: stackArtifact,
219
+ roleArn: stackArtifact.cloudFormationExecutionRoleArn,
220
+ stackName: stackArtifact.stackName,
221
+ });
222
+ await deployment.publishSingleAsset(manifest, entry, {
223
+ stack: stackArtifact,
224
+ roleArn: stackArtifact.cloudFormationExecutionRoleArn,
225
+ stackName: stackArtifact.stackName,
226
+ });
227
+ }
196
228
  }
197
229
  }
198
- async function getCloudFormationStackOutputs(stack) {
230
+ async function buildCloudFormationStackParams(deployment, stack) {
231
+ const resolvedEnv = await deployment.resolveEnvironment(stack);
232
+ const s3Url = stack
233
+ .stackTemplateAssetObjectUrl.replace("${AWS::AccountId}", resolvedEnv.account)
234
+ .match(/s3:\/\/([^/]+)\/(.*)$/);
235
+ const templateUrl = s3Url
236
+ ? `https://s3.${resolvedEnv.region}.amazonaws.com/${s3Url[1]}/${s3Url[2]}`
237
+ : stack.stackTemplateAssetObjectUrl;
238
+ return {
239
+ StackName: stack.stackName,
240
+ TemplateURL: templateUrl,
241
+ //TemplateBody: bodyParameter.TemplateBody,
242
+ //Parameters: stackParams.apiParameters,
243
+ Parameters: [],
244
+ Capabilities: [
245
+ "CAPABILITY_IAM",
246
+ "CAPABILITY_NAMED_IAM",
247
+ "CAPABILITY_AUTO_EXPAND",
248
+ ],
249
+ Tags: Object.entries(stack.tags ?? {}).map(([Key, Value]) => ({
250
+ Key,
251
+ Value,
252
+ })),
253
+ };
254
+ }
255
+ async function getCloudFormationStack(stack) {
199
256
  const { CloudFormationClient, DescribeStacksCommand } = await import("@aws-sdk/client-cloudformation");
200
257
  const client = useAWSClient(CloudFormationClient);
201
258
  try {
@@ -204,7 +261,7 @@ async function getCloudFormationStackOutputs(stack) {
204
261
  }));
205
262
  if (!stacks || stacks.length === 0)
206
263
  return;
207
- return stacks[0].Outputs || [];
264
+ return stacks[0];
208
265
  }
209
266
  catch (e) {
210
267
  if (e.name === "ValidationError" &&
@@ -217,6 +274,49 @@ async function getCloudFormationStackOutputs(stack) {
217
274
  }
218
275
  }
219
276
  }
277
+ async function createCloudFormationStack(input) {
278
+ const { CloudFormationClient, CreateStackCommand } = await import("@aws-sdk/client-cloudformation");
279
+ const client = useAWSClient(CloudFormationClient);
280
+ await client.send(new CreateStackCommand(input));
281
+ }
282
+ async function updateCloudFormationStack(input) {
283
+ const { CloudFormationClient, UpdateStackCommand } = await import("@aws-sdk/client-cloudformation");
284
+ const client = useAWSClient(CloudFormationClient);
285
+ await client.send(new UpdateStackCommand(input));
286
+ }
287
+ async function deleteCloudFormationStack(stackName) {
288
+ const { CloudFormationClient, DescribeStacksCommand, DeleteStackCommand } = await import("@aws-sdk/client-cloudformation");
289
+ const client = useAWSClient(CloudFormationClient);
290
+ try {
291
+ await client.send(new DeleteStackCommand({ StackName: stackName }));
292
+ while (true) {
293
+ const { Stacks: stacks } = await client.send(new DescribeStacksCommand({
294
+ StackName: stackName,
295
+ }));
296
+ if (!stacks || stacks.length === 0) {
297
+ return;
298
+ }
299
+ const stack = stacks[0];
300
+ if (stack.StackStatus === "DELETE_IN_PROGRESS") {
301
+ await new Promise((resolve) => setTimeout(resolve, 5000));
302
+ }
303
+ if (stack.StackStatus === "DELETE_COMPLETE") {
304
+ return;
305
+ }
306
+ if (stack.StackStatus === "DELETE_FAILED") {
307
+ throw new Error(`Failed deleting stack ${stackName} that had previously failed creation (current state: ${stack.StackStatus})`);
308
+ }
309
+ }
310
+ }
311
+ catch (e) {
312
+ if (e.name === "ValidationError" &&
313
+ e.message.includes("Stack with id") &&
314
+ e.message.includes("does not exist")) {
315
+ return;
316
+ }
317
+ throw e;
318
+ }
319
+ }
220
320
  async function listImports(exportName) {
221
321
  const { CloudFormationClient, ListImportsCommand } = await import("@aws-sdk/client-cloudformation");
222
322
  const client = useAWSClient(CloudFormationClient);
package/stacks/synth.js CHANGED
@@ -1,16 +1,20 @@
1
1
  import { Logger } from "../logger.js";
2
2
  import { useProject } from "../project.js";
3
3
  import { useAWSProvider, useSTSIdentity } from "../credentials.js";
4
- import * as contextproviders from "sst-aws-cdk/lib/context-providers/index.js";
5
4
  import path from "path";
6
5
  import { VisibleError } from "../error.js";
7
6
  import { Semaphore } from "../util/semaphore.js";
7
+ import { Configuration } from "../util/user-configuration.js";
8
8
  const sem = new Semaphore(1);
9
9
  export async function synth(opts) {
10
10
  Logger.debug("Synthesizing stacks...");
11
11
  const { App } = await import("../constructs/App.js");
12
12
  const cxapi = await import("@aws-cdk/cx-api");
13
- const { Configuration } = await import("sst-aws-cdk/lib/cli/user-configuration.js");
13
+ const cdkToolkitUrl = await import.meta.resolve("@aws-cdk/toolkit-lib");
14
+ const cdkToolkitPath = new URL(cdkToolkitUrl).pathname;
15
+ const { IoHelper } = await import(path.resolve(cdkToolkitPath, "..", "api", "io", "private", "io-helper.js"));
16
+ const { PluginHost } = await import(path.resolve(cdkToolkitPath, "..", "api", "plugin", "plugin.js"));
17
+ const { provideContextValues } = await import(path.resolve(cdkToolkitPath, "..", "context-providers", "index.js"));
14
18
  const project = useProject();
15
19
  const cwd = process.cwd();
16
20
  process.chdir(project.paths.root);
@@ -65,8 +69,14 @@ export async function synth(opts) {
65
69
  throw new VisibleError(formatErrorMessage(next.join("")));
66
70
  Logger.debug("Looking up context for:", next, "Previous:", previous);
67
71
  previous = new Set(next);
68
- await contextproviders.provideContextValues(missing, cfg.context, provider);
69
- if (cfg.context.keys.length) {
72
+ const updates = await provideContextValues(missing, provider, new PluginHost(), IoHelper.fromActionAwareIoHost({
73
+ notify: (msg) => { },
74
+ requestResponse: (msg) => { },
75
+ }));
76
+ if (Object.keys(updates).length) {
77
+ for (const [key, value] of Object.entries(updates)) {
78
+ cfg.context.set(key, value);
79
+ }
70
80
  await cfg.saveContext();
71
81
  }
72
82
  continue;