sst 2.1.22 → 2.1.23
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/cloudformation-deployments.js +2 -1
- package/cdk/deploy-stack.js +2 -1
- package/cdk/util.d.ts +1 -0
- package/cdk/util.js +17 -0
- package/package.json +1 -1
- package/sst.mjs +28 -5
|
@@ -9,6 +9,7 @@ import { loadCurrentTemplateWithNestedStacks, loadCurrentTemplate, } from "aws-c
|
|
|
9
9
|
import { ToolkitInfo } from "aws-cdk/lib/api/toolkit-info.js";
|
|
10
10
|
import { CloudFormationStack, } from "aws-cdk/lib/api/util/cloudformation.js";
|
|
11
11
|
import { replaceEnvPlaceholders } from "aws-cdk/lib/api/util/placeholders.js";
|
|
12
|
+
import { callWithRetry } from "./util.js";
|
|
12
13
|
/**
|
|
13
14
|
* Try to use the bootstrap lookupRole. There are two scenarios that are handled here
|
|
14
15
|
* 1. The lookup role may not exist (it was added in bootstrap stack version 7)
|
|
@@ -119,7 +120,7 @@ export class CloudFormationDeployments {
|
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
122
|
const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await this.prepareSdkFor(options.stack, options.roleArn);
|
|
122
|
-
const toolkitInfo = await ToolkitInfo.lookup(resolvedEnvironment, stackSdk, options.toolkitStackName);
|
|
123
|
+
const toolkitInfo = await callWithRetry(() => ToolkitInfo.lookup(resolvedEnvironment, stackSdk, options.toolkitStackName));
|
|
123
124
|
// Publish any assets before doing the actual deploy (do not publish any assets on import operation)
|
|
124
125
|
if (options.resourcesToImport === undefined) {
|
|
125
126
|
await this.publishStackAssets(options.stack, toolkitInfo, {
|
package/cdk/deploy-stack.js
CHANGED
|
@@ -11,6 +11,7 @@ import { CfnEvaluationException } from "aws-cdk/lib/api/evaluate-cloudformation-
|
|
|
11
11
|
import { tryHotswapDeployment } from "aws-cdk/lib/api/hotswap-deployments.js";
|
|
12
12
|
import { changeSetHasNoChanges, CloudFormationStack, TemplateParameters, waitForChangeSet, waitForStackDeploy, waitForStackDelete, } from "aws-cdk/lib/api/util/cloudformation.js";
|
|
13
13
|
import { blue } from "colorette";
|
|
14
|
+
import { callWithRetry } from "./util.js";
|
|
14
15
|
const LARGE_TEMPLATE_SIZE_KB = 50;
|
|
15
16
|
export async function deployStack(options) {
|
|
16
17
|
const stackArtifact = options.stack;
|
|
@@ -18,7 +19,7 @@ export async function deployStack(options) {
|
|
|
18
19
|
options.sdk.appendCustomUserAgent(options.extraUserAgent);
|
|
19
20
|
const cfn = options.sdk.cloudFormation();
|
|
20
21
|
const deployName = options.deployName || stackArtifact.stackName;
|
|
21
|
-
let cloudFormationStack = await CloudFormationStack.lookup(cfn, deployName);
|
|
22
|
+
let cloudFormationStack = await callWithRetry(() => CloudFormationStack.lookup(cfn, deployName));
|
|
22
23
|
if (cloudFormationStack.stackStatus.isCreationFailure) {
|
|
23
24
|
debug(`Found existing stack ${deployName} that had previously failed creation. Deleting it before attempting to re-create it.`);
|
|
24
25
|
await cfn.deleteStack({ StackName: deployName }).promise();
|
package/cdk/util.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function callWithRetry<T>(cb: () => Promise<T>): Promise<T>;
|
package/cdk/util.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export async function callWithRetry(cb) {
|
|
2
|
+
try {
|
|
3
|
+
return await cb();
|
|
4
|
+
}
|
|
5
|
+
catch (e) {
|
|
6
|
+
if ((e.code === "ThrottlingException" && e.message === "Rate exceeded") ||
|
|
7
|
+
(e.code === "Throttling" && e.message === "Rate exceeded") ||
|
|
8
|
+
(e.code === "TooManyRequestsException" &&
|
|
9
|
+
e.message === "Too Many Requests") ||
|
|
10
|
+
e.code === "OperationAbortedException" ||
|
|
11
|
+
e.code === "TimeoutError" ||
|
|
12
|
+
e.code === "NetworkingError") {
|
|
13
|
+
return await callWithRetry(cb);
|
|
14
|
+
}
|
|
15
|
+
throw e;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/package.json
CHANGED
package/sst.mjs
CHANGED
|
@@ -3306,6 +3306,23 @@ var init_monitor = __esm({
|
|
|
3306
3306
|
}
|
|
3307
3307
|
});
|
|
3308
3308
|
|
|
3309
|
+
// src/cdk/util.ts
|
|
3310
|
+
async function callWithRetry(cb) {
|
|
3311
|
+
try {
|
|
3312
|
+
return await cb();
|
|
3313
|
+
} catch (e) {
|
|
3314
|
+
if (e.code === "ThrottlingException" && e.message === "Rate exceeded" || e.code === "Throttling" && e.message === "Rate exceeded" || e.code === "TooManyRequestsException" && e.message === "Too Many Requests" || e.code === "OperationAbortedException" || e.code === "TimeoutError" || e.code === "NetworkingError") {
|
|
3315
|
+
return await callWithRetry(cb);
|
|
3316
|
+
}
|
|
3317
|
+
throw e;
|
|
3318
|
+
}
|
|
3319
|
+
}
|
|
3320
|
+
var init_util = __esm({
|
|
3321
|
+
"src/cdk/util.ts"() {
|
|
3322
|
+
"use strict";
|
|
3323
|
+
}
|
|
3324
|
+
});
|
|
3325
|
+
|
|
3309
3326
|
// src/cdk/deploy-stack.ts
|
|
3310
3327
|
import * as cxapi from "@aws-cdk/cx-api";
|
|
3311
3328
|
import fs8 from "fs/promises";
|
|
@@ -3333,7 +3350,9 @@ async function deployStack(options) {
|
|
|
3333
3350
|
options.sdk.appendCustomUserAgent(options.extraUserAgent);
|
|
3334
3351
|
const cfn = options.sdk.cloudFormation();
|
|
3335
3352
|
const deployName = options.deployName || stackArtifact.stackName;
|
|
3336
|
-
let cloudFormationStack = await
|
|
3353
|
+
let cloudFormationStack = await callWithRetry(
|
|
3354
|
+
() => CloudFormationStack.lookup(cfn, deployName)
|
|
3355
|
+
);
|
|
3337
3356
|
if (cloudFormationStack.stackStatus.isCreationFailure) {
|
|
3338
3357
|
debug(
|
|
3339
3358
|
`Found existing stack ${deployName} that had previously failed creation. Deleting it before attempting to re-create it.`
|
|
@@ -3606,6 +3625,7 @@ var LARGE_TEMPLATE_SIZE_KB, FullCloudFormationDeployment;
|
|
|
3606
3625
|
var init_deploy_stack = __esm({
|
|
3607
3626
|
"src/cdk/deploy-stack.ts"() {
|
|
3608
3627
|
"use strict";
|
|
3628
|
+
init_util();
|
|
3609
3629
|
LARGE_TEMPLATE_SIZE_KB = 50;
|
|
3610
3630
|
FullCloudFormationDeployment = class {
|
|
3611
3631
|
constructor(options, cloudFormationStack, stackArtifact, stackParams, bodyParameter) {
|
|
@@ -3896,6 +3916,7 @@ var init_cloudformation_deployments = __esm({
|
|
|
3896
3916
|
"src/cdk/cloudformation-deployments.ts"() {
|
|
3897
3917
|
"use strict";
|
|
3898
3918
|
init_deploy_stack();
|
|
3919
|
+
init_util();
|
|
3899
3920
|
CloudFormationDeployments = class {
|
|
3900
3921
|
sdkProvider;
|
|
3901
3922
|
constructor(props) {
|
|
@@ -3959,10 +3980,12 @@ var init_cloudformation_deployments = __esm({
|
|
|
3959
3980
|
};
|
|
3960
3981
|
}
|
|
3961
3982
|
const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await this.prepareSdkFor(options.stack, options.roleArn);
|
|
3962
|
-
const toolkitInfo = await
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3983
|
+
const toolkitInfo = await callWithRetry(
|
|
3984
|
+
() => ToolkitInfo.lookup(
|
|
3985
|
+
resolvedEnvironment,
|
|
3986
|
+
stackSdk,
|
|
3987
|
+
options.toolkitStackName
|
|
3988
|
+
)
|
|
3966
3989
|
);
|
|
3967
3990
|
if (options.resourcesToImport === void 0) {
|
|
3968
3991
|
await this.publishStackAssets(options.stack, toolkitInfo, {
|