@go-to-k/cdkd 0.207.4 → 0.207.6
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/dist/cli.js +88 -41
- package/dist/cli.js.map +1 -1
- package/dist/{deploy-engine-ai3rix-L.js → deploy-engine-DMggQBl4.js} +44 -4
- package/dist/deploy-engine-DMggQBl4.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/deploy-engine-ai3rix-L.js.map +0 -1
|
@@ -7,7 +7,7 @@ import { AttachRolePolicyCommand, CreateRoleCommand, DeleteRoleCommand, DeleteRo
|
|
|
7
7
|
import { PublishCommand, SNSClient } from "@aws-sdk/client-sns";
|
|
8
8
|
import { GetFunctionUrlConfigCommand, InvokeCommand, LambdaClient, UpdateFunctionConfigurationCommand, waitUntilFunctionActiveV2, waitUntilFunctionUpdatedV2 } from "@aws-sdk/client-lambda";
|
|
9
9
|
import { AssumeRoleCommand, GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts";
|
|
10
|
-
import { DescribeAvailabilityZonesCommand, DescribeImagesCommand, DescribeLaunchTemplatesCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeVpcsCommand, DescribeVpnGatewaysCommand, EC2Client } from "@aws-sdk/client-ec2";
|
|
10
|
+
import { DescribeAvailabilityZonesCommand, DescribeImagesCommand, DescribeLaunchTemplatesCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeVpcsCommand, DescribeVpnGatewaysCommand, EC2Client, ModifyInstanceAttributeCommand } from "@aws-sdk/client-ec2";
|
|
11
11
|
import { DescribeTableCommand } from "@aws-sdk/client-dynamodb";
|
|
12
12
|
import { CloudFormationClient, CreateChangeSetCommand, DeleteStackCommand, DescribeChangeSetCommand, GetTemplateCommand, waitUntilChangeSetCreateComplete } from "@aws-sdk/client-cloudformation";
|
|
13
13
|
import { GetRestApiCommand } from "@aws-sdk/client-api-gateway";
|
|
@@ -7615,6 +7615,36 @@ var IntrinsicFunctionResolver = class {
|
|
|
7615
7615
|
}
|
|
7616
7616
|
};
|
|
7617
7617
|
|
|
7618
|
+
//#endregion
|
|
7619
|
+
//#region src/provisioning/ec2-termination-protection.ts
|
|
7620
|
+
/**
|
|
7621
|
+
* Flip `DisableApiTermination` off on an instance. Idempotent — EC2 accepts the
|
|
7622
|
+
* call when the attribute is already false. Non-fatal: a NotFound (already
|
|
7623
|
+
* gone) or any other error is swallowed at debug so the actual delete still
|
|
7624
|
+
* proceeds (it will surface the real failure if the instance truly cannot be
|
|
7625
|
+
* deleted).
|
|
7626
|
+
*/
|
|
7627
|
+
async function disableInstanceApiTermination(client, instanceId, logger) {
|
|
7628
|
+
try {
|
|
7629
|
+
await client.send(new ModifyInstanceAttributeCommand({
|
|
7630
|
+
InstanceId: instanceId,
|
|
7631
|
+
DisableApiTermination: { Value: false }
|
|
7632
|
+
}));
|
|
7633
|
+
logger.debug(`Disabled DisableApiTermination on EC2 Instance ${instanceId} before deletion`);
|
|
7634
|
+
} catch (flipError) {
|
|
7635
|
+
logger.debug(`Could not disable DisableApiTermination on ${instanceId}: ${flipError instanceof Error ? flipError.message : String(flipError)}`);
|
|
7636
|
+
}
|
|
7637
|
+
}
|
|
7638
|
+
/**
|
|
7639
|
+
* Does this error message indicate the terminate / delete raced the
|
|
7640
|
+
* `DisableApiTermination` flip-off propagation (so re-flipping + retrying is
|
|
7641
|
+
* the right move)? Matches both the SDK `TerminateInstances` 400 and the Cloud
|
|
7642
|
+
* Control `DeleteResource` wrapper of the same underlying EC2 error.
|
|
7643
|
+
*/
|
|
7644
|
+
function isTerminationProtectionPropagationError(message) {
|
|
7645
|
+
return /may not be terminated|disableApiTermination/i.test(message);
|
|
7646
|
+
}
|
|
7647
|
+
|
|
7618
7648
|
//#endregion
|
|
7619
7649
|
//#region src/provisioning/json-patch-generator.ts
|
|
7620
7650
|
/**
|
|
@@ -8096,7 +8126,10 @@ var CloudControlProvider = class {
|
|
|
8096
8126
|
*/
|
|
8097
8127
|
async delete(logicalId, physicalId, resourceType, _properties, context) {
|
|
8098
8128
|
this.logger.debug(`Deleting resource ${logicalId} (${resourceType}), physical ID: ${physicalId}`);
|
|
8099
|
-
|
|
8129
|
+
const isProtectedEc2Instance = context?.removeProtection === true && resourceType === "AWS::EC2::Instance";
|
|
8130
|
+
if (isProtectedEc2Instance) await disableInstanceApiTermination(getAwsClients().ec2, physicalId, this.logger);
|
|
8131
|
+
const maxAttempts = isProtectedEc2Instance ? 5 : 1;
|
|
8132
|
+
for (let attempt = 1;; attempt++) try {
|
|
8100
8133
|
const deleteResponse = await this.cloudControlClient.send(new DeleteResourceCommand({
|
|
8101
8134
|
TypeName: resourceType,
|
|
8102
8135
|
Identifier: physicalId
|
|
@@ -8105,6 +8138,7 @@ var CloudControlProvider = class {
|
|
|
8105
8138
|
this.logger.debug(`Delete request submitted for ${logicalId}, token: ${deleteResponse.ProgressEvent.RequestToken}`);
|
|
8106
8139
|
await this.waitForOperation(deleteResponse.ProgressEvent.RequestToken, logicalId, "DELETE");
|
|
8107
8140
|
this.logger.debug(`Deleted resource ${logicalId}`);
|
|
8141
|
+
return;
|
|
8108
8142
|
} catch (error) {
|
|
8109
8143
|
const err = error;
|
|
8110
8144
|
if (err.name === "ResourceNotFoundException" || err.message?.includes("does not exist") || err.message?.includes("not found") || err.message?.includes("NotFound")) {
|
|
@@ -8112,6 +8146,12 @@ var CloudControlProvider = class {
|
|
|
8112
8146
|
this.logger.debug(`Resource ${logicalId} already deleted (not found), treating as success`);
|
|
8113
8147
|
return;
|
|
8114
8148
|
}
|
|
8149
|
+
if (isProtectedEc2Instance && isTerminationProtectionPropagationError(err.message ?? "") && attempt < maxAttempts) {
|
|
8150
|
+
this.logger.debug(`Cloud Control delete of ${logicalId} raced the DisableApiTermination flip-off (attempt ${attempt}/${maxAttempts}); re-flipping and retrying`);
|
|
8151
|
+
await disableInstanceApiTermination(getAwsClients().ec2, physicalId, this.logger);
|
|
8152
|
+
await this.sleep(3e3 * attempt);
|
|
8153
|
+
continue;
|
|
8154
|
+
}
|
|
8115
8155
|
this.handleError(error, "DELETE", resourceType, logicalId, physicalId);
|
|
8116
8156
|
}
|
|
8117
8157
|
}
|
|
@@ -13706,5 +13746,5 @@ var DeployEngine = class {
|
|
|
13706
13746
|
};
|
|
13707
13747
|
|
|
13708
13748
|
//#endregion
|
|
13709
|
-
export {
|
|
13710
|
-
//# sourceMappingURL=deploy-engine-
|
|
13749
|
+
export { CFN_TEMPLATE_URL_LIMIT as $, DagBuilder as A, setLogger as At, getDockerCmd as B, CloudControlProvider as C, SynthesisError as Ct, IntrinsicFunctionResolver as D, withErrorHandling as Dt, isTerminationProtectionPropagationError as E, normalizeAwsError as Et, AssetPublisher as F, generateResourceName as Ft, getLegacyStateBucketName as G, runDockerStreaming as H, stringifyValue as I, generateResourceNameWithFallback as It, resolveSkipPrefix as J, resolveApp as K, WorkGraph as L, withSkipPrefix as Lt, LockManager as M, getLiveRenderer as Mt, S3StateBackend as N, PATTERN_B_NAME_PROPERTIES as Nt, applyRoleArnIfSet as O, ConsoleLogger as Ot, shouldRetainResource as P, PATTERN_B_RESOURCE_TYPES as Pt, CFN_TEMPLATE_BODY_LIMIT as Q, buildDockerImage as R, withStackName as Rt, findActionableSilentDrops as S, StateError as St, disableInstanceApiTermination as T, isCdkdError as Tt, Synthesizer as U, runDockerForeground as V, getDefaultStateBucketName as W, resolveStateBucketWithDefaultAndSource as X, resolveStateBucketWithDefault as Y, warnDeprecatedNoPrefixCliFlag as Z, CDK_PATH_TAG as _, ProvisioningError as _t, withRetry as a, resolveBucketRegion as at, resolveExplicitPhysicalId as b, StackHasActiveImportsError as bt, formatResourceLine as c, ConfigError as ct, gray as d, LocalMigrateError as dt, MIGRATE_TMP_PREFIX as et, green as f, LocalStartServiceError as ft, collectInlinePolicyNamesManagedBySiblings as g, PartialFailureError as gt, IAMRoleProvider as h, NestedStackChildDirectDestroyError as ht, withResourceDeadline as i, clearBucketRegionCache as it, TemplateParser as j, runStackBuffered as jt, DiffCalculator as k, getLogger as kt, bold as l, DependencyError as lt, yellow as m, MissingCdkCliError as mt, DEFAULT_RESOURCE_WARN_AFTER_MS as n, uploadCfnTemplate as nt, isRetryableTransientError as o, AssetError as ot, red as p, LockError as pt, resolveCaptureObservedState as q, DeployEngine as r, AssemblyReader as rt, IMPLICIT_DELETE_DEPENDENCIES as s, CdkdError as st, DEFAULT_RESOURCE_TIMEOUT_MS as t, findLargeInlineResources as tt, cyan as u, LocalInvokeBuildError as ut, matchesCdkPath as v, ResourceTimeoutError as vt, assertRegionMatch as w, formatError as wt, ProviderRegistry as x, StackTerminationProtectionError as xt, normalizeAwsTagsToCfn as y, ResourceUpdateNotSupportedError as yt, formatDockerLoginError as z };
|
|
13750
|
+
//# sourceMappingURL=deploy-engine-DMggQBl4.js.map
|