sst 2.15.0 → 2.16.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.
- package/cdk/deploy-stack.d.ts +2 -1
- package/cdk/deploy-stack.js +15 -4
- package/cdk/{cloudformation-deployments-wrapper.d.ts → deployments-wrapper.d.ts} +1 -1
- package/cdk/{cloudformation-deployments-wrapper.js → deployments-wrapper.js} +25 -8
- package/cdk/{cloudformation-deployments.d.ts → deployments.d.ts} +76 -44
- package/cdk/deployments.js +362 -0
- package/cli/commands/dev.js +2 -0
- package/constructs/App.d.ts +2 -2
- package/constructs/App.js +2 -2
- package/constructs/RDS.d.ts +11 -11
- package/constructs/RDS.js +31 -23
- package/constructs/Script.js +2 -3
- package/package.json +10 -10
- package/sst.mjs +266 -135
- package/stacks/deploy.js +3 -5
- package/stacks/synth.d.ts +1 -0
- package/stacks/synth.js +1 -0
- package/cdk/cloudformation-deployments.js +0 -267
package/cdk/deploy-stack.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as cxapi from "@aws-cdk/cx-api";
|
|
|
2
2
|
import { Tag } from "sst-aws-cdk/lib/cdk-toolkit.js";
|
|
3
3
|
import { AssetManifestBuilder } from "sst-aws-cdk/lib/util/asset-manifest-builder.js";
|
|
4
4
|
import { ISDK, SdkProvider } from "sst-aws-cdk/lib/api/aws-auth/index.js";
|
|
5
|
+
import { HotswapMode } from "sst-aws-cdk/lib/api/hotswap/common.js";
|
|
5
6
|
import { ToolkitInfo } from "sst-aws-cdk/lib/api/toolkit-info.js";
|
|
6
7
|
import { ResourcesToImport } from "sst-aws-cdk/lib/api/util/cloudformation.js";
|
|
7
8
|
import { StackActivityProgress } from "sst-aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.js";
|
|
@@ -142,7 +143,7 @@ export interface DeployStackOptions {
|
|
|
142
143
|
* @default true
|
|
143
144
|
*/
|
|
144
145
|
readonly rollback?: boolean;
|
|
145
|
-
readonly hotswap?:
|
|
146
|
+
readonly hotswap?: HotswapMode;
|
|
146
147
|
/**
|
|
147
148
|
* The extra string to append to the User-Agent header when performing AWS SDK calls.
|
|
148
149
|
*
|
package/cdk/deploy-stack.js
CHANGED
|
@@ -8,6 +8,7 @@ import { AssetManifestBuilder } from "sst-aws-cdk/lib/util/asset-manifest-builde
|
|
|
8
8
|
import { publishAssets } from "sst-aws-cdk/lib/util/asset-publishing.js";
|
|
9
9
|
import { contentHash } from "sst-aws-cdk/lib/util/content-hash.js";
|
|
10
10
|
import { CfnEvaluationException } from "sst-aws-cdk/lib/api/evaluate-cloudformation-template.js";
|
|
11
|
+
import { HotswapMode } from "sst-aws-cdk/lib/api/hotswap/common.js";
|
|
11
12
|
import { tryHotswapDeployment } from "sst-aws-cdk/lib/api/hotswap-deployments.js";
|
|
12
13
|
import { changeSetHasNoChanges, CloudFormationStack, TemplateParameters, waitForChangeSet, waitForStackDeploy, waitForStackDelete, } from "sst-aws-cdk/lib/api/util/cloudformation.js";
|
|
13
14
|
import { blue } from "colorette";
|
|
@@ -61,10 +62,11 @@ export async function deployStack(options) {
|
|
|
61
62
|
await publishAssets(legacyAssets.toManifest(stackArtifact.assembly.directory), options.sdkProvider, stackEnv, {
|
|
62
63
|
parallel: options.assetParallelism,
|
|
63
64
|
});
|
|
64
|
-
|
|
65
|
+
const hotswapMode = options.hotswap;
|
|
66
|
+
if (hotswapMode && hotswapMode !== HotswapMode.FULL_DEPLOYMENT) {
|
|
65
67
|
// attempt to short-circuit the deployment if possible
|
|
66
68
|
try {
|
|
67
|
-
const hotswapDeploymentResult = await tryHotswapDeployment(options.sdkProvider,
|
|
69
|
+
const hotswapDeploymentResult = await tryHotswapDeployment(options.sdkProvider, stackParams.values, cloudFormationStack, stackArtifact, hotswapMode);
|
|
68
70
|
if (hotswapDeploymentResult) {
|
|
69
71
|
return hotswapDeploymentResult;
|
|
70
72
|
}
|
|
@@ -76,8 +78,17 @@ export async function deployStack(options) {
|
|
|
76
78
|
}
|
|
77
79
|
print("Could not perform a hotswap deployment, because the CloudFormation template could not be resolved: %s", e.message);
|
|
78
80
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
if (hotswapMode === HotswapMode.FALL_BACK) {
|
|
82
|
+
print("Falling back to doing a full deployment");
|
|
83
|
+
options.sdk.appendCustomUserAgent("cdk-hotswap/fallback");
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return {
|
|
87
|
+
noOp: true,
|
|
88
|
+
stackArn: cloudFormationStack.stackId,
|
|
89
|
+
outputs: cloudFormationStack.outputs,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
81
92
|
}
|
|
82
93
|
// could not short-circuit the deployment, perform a full CFN deploy instead
|
|
83
94
|
const fullDeployment = new FullCloudFormationDeployment(options, cloudFormationStack, stackArtifact, stackParams, bodyParameter);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SdkProvider } from "sst-aws-cdk/lib/api/aws-auth/sdk-provider.js";
|
|
2
|
-
import { DeployStackOptions as PublishStackAssetsOptions } from "./
|
|
2
|
+
import { DeployStackOptions as PublishStackAssetsOptions } from "./deployments.js";
|
|
3
3
|
export declare function publishDeployAssets(sdkProvider: SdkProvider, options: PublishStackAssetsOptions): Promise<any>;
|
|
@@ -1,21 +1,38 @@
|
|
|
1
|
+
import * as cxapi from "@aws-cdk/cx-api";
|
|
2
|
+
import { AssetManifest } from "cdk-assets";
|
|
1
3
|
import { debug } from "sst-aws-cdk/lib/logging.js";
|
|
2
4
|
import { CloudFormationStack, TemplateParameters, waitForStackDelete, } from "sst-aws-cdk/lib/api/util/cloudformation.js";
|
|
5
|
+
import { Mode } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
|
|
3
6
|
import { ToolkitInfo } from "sst-aws-cdk/lib/api/toolkit-info.js";
|
|
4
7
|
import { addMetadataAssetsToManifest } from "sst-aws-cdk/lib/assets.js";
|
|
5
8
|
import { publishAssets } from "sst-aws-cdk/lib/util/asset-publishing.js";
|
|
6
9
|
import { AssetManifestBuilder } from "sst-aws-cdk/lib/util/asset-manifest-builder.js";
|
|
7
|
-
import {
|
|
10
|
+
import { Deployments, } from "./deployments.js";
|
|
8
11
|
import { makeBodyParameter } from "./deploy-stack.js";
|
|
9
12
|
import { Context } from "../context/context.js";
|
|
10
13
|
export async function publishDeployAssets(sdkProvider, options) {
|
|
11
14
|
const { deployment, toolkitInfo, stackSdk, resolvedEnvironment, cloudFormationRoleArn, } = await useDeployment().get(sdkProvider, options);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
// TODO
|
|
16
|
+
// old
|
|
17
|
+
//await deployment.publishStackAssets(options.stack, toolkitInfo, {
|
|
18
|
+
// buildAssets: options.buildAssets ?? true,
|
|
19
|
+
// publishOptions: {
|
|
20
|
+
// quiet: options.quiet,
|
|
21
|
+
// parallel: options.assetParallelism,
|
|
22
|
+
// },
|
|
23
|
+
//});
|
|
24
|
+
// new
|
|
25
|
+
const assetArtifacts = options.stack.dependencies.filter(cxapi.AssetManifestArtifact.isAssetManifestArtifact);
|
|
26
|
+
for (const asset of assetArtifacts) {
|
|
27
|
+
const manifest = AssetManifest.fromFile(asset.file);
|
|
28
|
+
//await buildAssets(manifest, sdkProvider, resolvedEnvironment, {
|
|
29
|
+
//});
|
|
30
|
+
await publishAssets(manifest, sdkProvider, resolvedEnvironment, {
|
|
31
|
+
buildAssets: true,
|
|
15
32
|
quiet: options.quiet,
|
|
16
33
|
parallel: options.assetParallelism,
|
|
17
|
-
}
|
|
18
|
-
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
19
36
|
return deployStack({
|
|
20
37
|
stack: options.stack,
|
|
21
38
|
noMonitor: true,
|
|
@@ -49,8 +66,8 @@ const useDeployment = Context.memo(() => {
|
|
|
49
66
|
async get(sdkProvider, options) {
|
|
50
67
|
const region = options.stack.environment.region;
|
|
51
68
|
if (!state.has(region)) {
|
|
52
|
-
const deployment = new
|
|
53
|
-
const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await deployment.prepareSdkFor(options.stack, options.roleArn);
|
|
69
|
+
const deployment = new Deployments({ sdkProvider });
|
|
70
|
+
const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await deployment.prepareSdkFor(options.stack, options.roleArn, Mode.ForWriting);
|
|
54
71
|
const toolkitInfo = await ToolkitInfo.lookup(resolvedEnvironment, stackSdk, options.toolkitStackName);
|
|
55
72
|
// Do a verification of the bootstrap stack version
|
|
56
73
|
await deployment.validateBootstrapStackVersion(options.stack.stackName, options.stack.requiresBootstrapStackVersion, options.stack.bootstrapStackVersionSsmParameter, toolkitInfo);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as cxapi from "@aws-cdk/cx-api";
|
|
2
|
+
import { AssetManifest, IManifestEntry } from "cdk-assets";
|
|
2
3
|
import { Tag } from "sst-aws-cdk/lib/cdk-toolkit.js";
|
|
3
4
|
import { BuildAssetsOptions, PublishAssetsOptions } from "sst-aws-cdk/lib/util/asset-publishing.js";
|
|
4
5
|
import { Mode } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
|
|
@@ -8,6 +9,7 @@ import { DeployStackResult, DeploymentMethod } from "./deploy-stack.js";
|
|
|
8
9
|
import { ToolkitInfo } from "sst-aws-cdk/lib/api/toolkit-info.js";
|
|
9
10
|
import { Template, ResourcesToImport, ResourceIdentifierSummaries } from "sst-aws-cdk/lib/api/util/cloudformation.js";
|
|
10
11
|
import { StackActivityProgress } from "sst-aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.js";
|
|
12
|
+
import { HotswapMode } from "sst-aws-cdk/lib/api/hotswap/common.js";
|
|
11
13
|
/**
|
|
12
14
|
* SDK obtained by assuming the lookup role
|
|
13
15
|
* for a given environment
|
|
@@ -30,25 +32,6 @@ export interface PreparedSdkWithLookupRoleForEnvironment {
|
|
|
30
32
|
*/
|
|
31
33
|
readonly didAssumeRole: boolean;
|
|
32
34
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Try to use the bootstrap lookupRole. There are two scenarios that are handled here
|
|
35
|
-
* 1. The lookup role may not exist (it was added in bootstrap stack version 7)
|
|
36
|
-
* 2. The lookup role may not have the correct permissions (ReadOnlyAccess was added in
|
|
37
|
-
* bootstrap stack version 8)
|
|
38
|
-
*
|
|
39
|
-
* In the case of 1 (lookup role doesn't exist) `forEnvironment` will either:
|
|
40
|
-
* 1. Return the default credentials if the default credentials are for the stack account
|
|
41
|
-
* 2. Throw an error if the default credentials are not for the stack account.
|
|
42
|
-
*
|
|
43
|
-
* If we successfully assume the lookup role we then proceed to 2 and check whether the bootstrap
|
|
44
|
-
* stack version is valid. If it is not we throw an error which should be handled in the calling
|
|
45
|
-
* function (and fallback to use a different role, etc)
|
|
46
|
-
*
|
|
47
|
-
* If we do not successfully assume the lookup role, but do get back the default credentials
|
|
48
|
-
* then return those and note that we are returning the default credentials. The calling
|
|
49
|
-
* function can then decide to use them or fallback to another role.
|
|
50
|
-
*/
|
|
51
|
-
export declare function prepareSdkWithLookupRoleFor(sdkProvider: SdkProvider, stack: cxapi.CloudFormationStackArtifact): Promise<PreparedSdkWithLookupRoleForEnvironment>;
|
|
52
35
|
export interface DeployStackOptions {
|
|
53
36
|
/**
|
|
54
37
|
* Stack to deploy
|
|
@@ -153,7 +136,7 @@ export interface DeployStackOptions {
|
|
|
153
136
|
* @default true
|
|
154
137
|
*/
|
|
155
138
|
readonly rollback?: boolean;
|
|
156
|
-
readonly hotswap?:
|
|
139
|
+
readonly hotswap?: HotswapMode;
|
|
157
140
|
/**
|
|
158
141
|
* The extra string to append to the User-Agent header when performing AWS SDK calls.
|
|
159
142
|
*
|
|
@@ -170,12 +153,6 @@ export interface DeployStackOptions {
|
|
|
170
153
|
* @default - Use the stored template
|
|
171
154
|
*/
|
|
172
155
|
readonly overrideTemplate?: any;
|
|
173
|
-
/**
|
|
174
|
-
* Whether to build assets before publishing.
|
|
175
|
-
*
|
|
176
|
-
* @default true To remain backward compatible.
|
|
177
|
-
*/
|
|
178
|
-
readonly buildAssets?: boolean;
|
|
179
156
|
/**
|
|
180
157
|
* Whether to build/publish assets in parallel
|
|
181
158
|
*
|
|
@@ -183,7 +160,7 @@ export interface DeployStackOptions {
|
|
|
183
160
|
*/
|
|
184
161
|
readonly assetParallelism?: boolean;
|
|
185
162
|
}
|
|
186
|
-
|
|
163
|
+
interface AssetOptions {
|
|
187
164
|
/**
|
|
188
165
|
* Stack with assets to build.
|
|
189
166
|
*/
|
|
@@ -200,22 +177,26 @@ export interface BuildStackAssetsOptions {
|
|
|
200
177
|
* @default - Current role
|
|
201
178
|
*/
|
|
202
179
|
readonly roleArn?: string;
|
|
180
|
+
}
|
|
181
|
+
export interface BuildStackAssetsOptions extends AssetOptions {
|
|
203
182
|
/**
|
|
204
183
|
* Options to pass on to `buildAsests()` function
|
|
205
184
|
*/
|
|
206
185
|
readonly buildOptions?: BuildAssetsOptions;
|
|
207
|
-
}
|
|
208
|
-
interface PublishStackAssetsOptions {
|
|
209
186
|
/**
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* @default true To remain backward compatible.
|
|
187
|
+
* Stack name this asset is for
|
|
213
188
|
*/
|
|
214
|
-
readonly
|
|
189
|
+
readonly stackName?: string;
|
|
190
|
+
}
|
|
191
|
+
interface PublishStackAssetsOptions extends AssetOptions {
|
|
215
192
|
/**
|
|
216
193
|
* Options to pass on to `publishAsests()` function
|
|
217
194
|
*/
|
|
218
195
|
readonly publishOptions?: Omit<PublishAssetsOptions, "buildAssets">;
|
|
196
|
+
/**
|
|
197
|
+
* Stack name this asset is for
|
|
198
|
+
*/
|
|
199
|
+
readonly stackName?: string;
|
|
219
200
|
}
|
|
220
201
|
export interface DestroyStackOptions {
|
|
221
202
|
stack: cxapi.CloudFormationStackArtifact;
|
|
@@ -229,8 +210,9 @@ export interface StackExistsOptions {
|
|
|
229
210
|
stack: cxapi.CloudFormationStackArtifact;
|
|
230
211
|
deployName?: string;
|
|
231
212
|
}
|
|
232
|
-
export interface
|
|
213
|
+
export interface DeploymentsProps {
|
|
233
214
|
sdkProvider: SdkProvider;
|
|
215
|
+
readonly quiet?: boolean;
|
|
234
216
|
}
|
|
235
217
|
/**
|
|
236
218
|
* SDK obtained by assuming the deploy role
|
|
@@ -254,14 +236,17 @@ export interface PreparedSdkForEnvironment {
|
|
|
254
236
|
readonly cloudFormationRoleArn?: string;
|
|
255
237
|
}
|
|
256
238
|
/**
|
|
257
|
-
*
|
|
239
|
+
* Scope for a single set of deployments from a set of Cloud Assembly Artifacts
|
|
258
240
|
*
|
|
259
|
-
*
|
|
260
|
-
* stack artifact.
|
|
241
|
+
* Manages lookup of SDKs, Bootstrap stacks, etc.
|
|
261
242
|
*/
|
|
262
|
-
export declare class
|
|
243
|
+
export declare class Deployments {
|
|
244
|
+
private readonly props;
|
|
263
245
|
private readonly sdkProvider;
|
|
264
|
-
|
|
246
|
+
private readonly toolkitInfoCache;
|
|
247
|
+
private readonly sdkCache;
|
|
248
|
+
private readonly publisherCache;
|
|
249
|
+
constructor(props: DeploymentsProps);
|
|
265
250
|
readCurrentTemplateWithNestedStacks(rootStackArtifact: cxapi.CloudFormationStackArtifact, retrieveProcessedTemplate?: boolean): Promise<Template>;
|
|
266
251
|
readCurrentTemplate(stackArtifact: cxapi.CloudFormationStackArtifact): Promise<Template>;
|
|
267
252
|
resourceIdentifierSummaries(stackArtifact: cxapi.CloudFormationStackArtifact, toolkitStackName?: string): Promise<ResourceIdentifierSummaries>;
|
|
@@ -278,18 +263,65 @@ export declare class CloudFormationDeployments {
|
|
|
278
263
|
* - SDK loaded with the right credentials for calling `CreateChangeSet`.
|
|
279
264
|
* - The Execution Role that should be passed to CloudFormation.
|
|
280
265
|
*/
|
|
281
|
-
prepareSdkFor(stack: cxapi.CloudFormationStackArtifact, roleArn
|
|
266
|
+
prepareSdkFor(stack: cxapi.CloudFormationStackArtifact, roleArn: string | undefined, mode: Mode): Promise<PreparedSdkForEnvironment>;
|
|
282
267
|
/**
|
|
283
|
-
*
|
|
268
|
+
* Try to use the bootstrap lookupRole. There are two scenarios that are handled here
|
|
269
|
+
* 1. The lookup role may not exist (it was added in bootstrap stack version 7)
|
|
270
|
+
* 2. The lookup role may not have the correct permissions (ReadOnlyAccess was added in
|
|
271
|
+
* bootstrap stack version 8)
|
|
272
|
+
*
|
|
273
|
+
* In the case of 1 (lookup role doesn't exist) `forEnvironment` will either:
|
|
274
|
+
* 1. Return the default credentials if the default credentials are for the stack account
|
|
275
|
+
* 2. Throw an error if the default credentials are not for the stack account.
|
|
276
|
+
*
|
|
277
|
+
* If we successfully assume the lookup role we then proceed to 2 and check whether the bootstrap
|
|
278
|
+
* stack version is valid. If it is not we throw an error which should be handled in the calling
|
|
279
|
+
* function (and fallback to use a different role, etc)
|
|
280
|
+
*
|
|
281
|
+
* If we do not successfully assume the lookup role, but do get back the default credentials
|
|
282
|
+
* then return those and note that we are returning the default credentials. The calling
|
|
283
|
+
* function can then decide to use them or fallback to another role.
|
|
284
284
|
*/
|
|
285
|
-
|
|
285
|
+
prepareSdkWithLookupRoleFor(stack: cxapi.CloudFormationStackArtifact): Promise<PreparedSdkWithLookupRoleForEnvironment>;
|
|
286
286
|
/**
|
|
287
|
-
*
|
|
287
|
+
* Look up the toolkit for a given environment, using a given SDK
|
|
288
|
+
*/
|
|
289
|
+
lookupToolkit(resolvedEnvironment: cxapi.Environment, sdk: ISDK, toolkitStackName?: string): Promise<ToolkitInfo>;
|
|
290
|
+
private prepareAndValidateAssets;
|
|
291
|
+
/**
|
|
292
|
+
* Build all assets in a manifest
|
|
293
|
+
*
|
|
294
|
+
* @deprecated Use `buildSingleAsset` instead
|
|
288
295
|
*/
|
|
289
|
-
|
|
296
|
+
buildAssets(asset: cxapi.AssetManifestArtifact, options: BuildStackAssetsOptions): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* Publish all assets in a manifest
|
|
299
|
+
*
|
|
300
|
+
* @deprecated Use `publishSingleAsset` instead
|
|
301
|
+
*/
|
|
302
|
+
publishAssets(asset: cxapi.AssetManifestArtifact, options: PublishStackAssetsOptions): Promise<void>;
|
|
303
|
+
/**
|
|
304
|
+
* Build a single asset from an asset manifest
|
|
305
|
+
*/
|
|
306
|
+
buildSingleAsset(assetArtifact: cxapi.AssetManifestArtifact, assetManifest: AssetManifest, asset: IManifestEntry, options: BuildStackAssetsOptions): Promise<void>;
|
|
307
|
+
/**
|
|
308
|
+
* Publish a single asset from an asset manifest
|
|
309
|
+
*/
|
|
310
|
+
publishSingleAsset(assetManifest: AssetManifest, asset: IManifestEntry, options: PublishStackAssetsOptions): Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Return whether a single asset has been published already
|
|
313
|
+
*/
|
|
314
|
+
isSingleAssetPublished(assetManifest: AssetManifest, asset: IManifestEntry, options: PublishStackAssetsOptions): Promise<boolean>;
|
|
290
315
|
/**
|
|
291
316
|
* Validate that the bootstrap stack has the right version for this stack
|
|
292
317
|
*/
|
|
293
318
|
validateBootstrapStackVersion(stackName: string, requiresBootstrapStackVersion: number | undefined, bootstrapStackVersionSsmParameter: string | undefined, toolkitInfo: ToolkitInfo): Promise<void>;
|
|
319
|
+
private cachedSdkForEnvironment;
|
|
320
|
+
private cachedPublisher;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* @deprecated Use 'Deployments' instead
|
|
324
|
+
*/
|
|
325
|
+
export declare class CloudFormationDeployments extends Deployments {
|
|
294
326
|
}
|
|
295
327
|
export {};
|