@go-to-k/cdkd 0.219.1 → 0.219.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/dist/cli.js +40 -9
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -33718,6 +33718,7 @@ var ECRProvider = class {
|
|
|
33718
33718
|
*/
|
|
33719
33719
|
var ASGProvider = class ASGProvider {
|
|
33720
33720
|
asgClient;
|
|
33721
|
+
ec2Client;
|
|
33721
33722
|
providerRegion = process.env["AWS_REGION"];
|
|
33722
33723
|
logger = getLogger().child("ASGProvider");
|
|
33723
33724
|
handledProperties = new Map([["AWS::AutoScaling::AutoScalingGroup", new Set([
|
|
@@ -33760,6 +33761,10 @@ var ASGProvider = class ASGProvider {
|
|
|
33760
33761
|
if (!this.asgClient) this.asgClient = new AutoScalingClient(this.providerRegion ? { region: this.providerRegion } : {});
|
|
33761
33762
|
return this.asgClient;
|
|
33762
33763
|
}
|
|
33764
|
+
getEc2Client() {
|
|
33765
|
+
if (!this.ec2Client) this.ec2Client = new EC2Client(this.providerRegion ? { region: this.providerRegion } : {});
|
|
33766
|
+
return this.ec2Client;
|
|
33767
|
+
}
|
|
33763
33768
|
async create(logicalId, resourceType, properties) {
|
|
33764
33769
|
if (resourceType !== "AWS::AutoScaling::AutoScalingGroup") throw new ProvisioningError(`Unsupported resource type: ${resourceType}`, resourceType, logicalId);
|
|
33765
33770
|
const groupName = properties["AutoScalingGroupName"] || generateResourceName(logicalId, { maxLength: 255 });
|
|
@@ -33878,14 +33883,17 @@ var ASGProvider = class ASGProvider {
|
|
|
33878
33883
|
}
|
|
33879
33884
|
async delete(logicalId, physicalId, resourceType, _properties, context) {
|
|
33880
33885
|
this.logger.debug(`Deleting AutoScalingGroup ${logicalId}: ${physicalId}`);
|
|
33881
|
-
if (context?.removeProtection === true)
|
|
33882
|
-
|
|
33883
|
-
|
|
33884
|
-
|
|
33885
|
-
|
|
33886
|
-
|
|
33887
|
-
|
|
33888
|
-
|
|
33886
|
+
if (context?.removeProtection === true) {
|
|
33887
|
+
try {
|
|
33888
|
+
await this.getClient().send(new UpdateAutoScalingGroupCommand({
|
|
33889
|
+
AutoScalingGroupName: physicalId,
|
|
33890
|
+
DeletionProtection: "none"
|
|
33891
|
+
}));
|
|
33892
|
+
this.logger.debug(`Disabled DeletionProtection on AutoScalingGroup ${logicalId} before delete`);
|
|
33893
|
+
} catch (flipError) {
|
|
33894
|
+
this.logger.debug(`Could not disable DeletionProtection on ${physicalId}: ${flipError instanceof Error ? flipError.message : String(flipError)}`);
|
|
33895
|
+
}
|
|
33896
|
+
await this.removeInstanceTerminationProtection(physicalId, logicalId);
|
|
33889
33897
|
}
|
|
33890
33898
|
try {
|
|
33891
33899
|
await this.getClient().send(new DeleteAutoScalingGroupCommand({
|
|
@@ -34059,6 +34067,29 @@ var ASGProvider = class ASGProvider {
|
|
|
34059
34067
|
async describeGroup(groupName) {
|
|
34060
34068
|
return (await this.getClient().send(new DescribeAutoScalingGroupsCommand({ AutoScalingGroupNames: [groupName] }))).AutoScalingGroups?.[0];
|
|
34061
34069
|
}
|
|
34070
|
+
/**
|
|
34071
|
+
* Flip EC2-level termination protection (`DisableApiTermination`) off on
|
|
34072
|
+
* every instance currently launched by the group, so the subsequent
|
|
34073
|
+
* `DeleteAutoScalingGroup(ForceDelete: true)` can actually terminate them
|
|
34074
|
+
* instead of orphaning the protected instances (issue #796). Best-effort:
|
|
34075
|
+
* a Describe failure or a per-instance flip failure is logged at debug and
|
|
34076
|
+
* does not block the delete (the modify WRITE lags the terminate READ, so
|
|
34077
|
+
* the shared helper swallows propagation errors the same way the EC2 path
|
|
34078
|
+
* does — the orphan, if any, surfaces as a leftover instance the caller
|
|
34079
|
+
* can clean up rather than a hard delete failure).
|
|
34080
|
+
*/
|
|
34081
|
+
async removeInstanceTerminationProtection(groupName, logicalId) {
|
|
34082
|
+
let instanceIds;
|
|
34083
|
+
try {
|
|
34084
|
+
instanceIds = ((await this.describeGroup(groupName))?.Instances ?? []).map((i) => i.InstanceId).filter((id) => typeof id === "string" && id.length > 0);
|
|
34085
|
+
} catch (describeError) {
|
|
34086
|
+
this.logger.debug(`Could not enumerate instances of AutoScalingGroup ${logicalId} for termination-protection removal: ${describeError instanceof Error ? describeError.message : String(describeError)}`);
|
|
34087
|
+
return;
|
|
34088
|
+
}
|
|
34089
|
+
if (instanceIds.length === 0) return;
|
|
34090
|
+
this.logger.debug(`Disabling EC2 termination protection on ${instanceIds.length} instance(s) of AutoScalingGroup ${logicalId} before force delete`);
|
|
34091
|
+
for (const instanceId of instanceIds) await disableInstanceApiTermination(this.getEc2Client(), instanceId, this.logger);
|
|
34092
|
+
}
|
|
34062
34093
|
async fetchArn(groupName) {
|
|
34063
34094
|
try {
|
|
34064
34095
|
return (await this.describeGroup(groupName))?.AutoScalingGroupARN;
|
|
@@ -53522,7 +53553,7 @@ function reorderArgs(argv) {
|
|
|
53522
53553
|
async function main() {
|
|
53523
53554
|
installPipeCloseHandler();
|
|
53524
53555
|
const program = new Command();
|
|
53525
|
-
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.219.
|
|
53556
|
+
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.219.2");
|
|
53526
53557
|
program.addCommand(createBootstrapCommand());
|
|
53527
53558
|
program.addCommand(createSynthCommand());
|
|
53528
53559
|
program.addCommand(createListCommand());
|