@go-to-k/cdkd 0.102.4 → 0.102.5
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 +106 -66
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9844,27 +9844,37 @@ var EC2Provider = class {
|
|
|
9844
9844
|
CidrBlock: cidrBlock,
|
|
9845
9845
|
InstanceTenancy: properties["InstanceTenancy"] ?? void 0
|
|
9846
9846
|
}))).Vpc.VpcId;
|
|
9847
|
-
if (properties["EnableDnsHostnames"] === true || properties["EnableDnsHostnames"] === "true") await this.ec2Client.send(new ModifyVpcAttributeCommand({
|
|
9848
|
-
VpcId: vpcId,
|
|
9849
|
-
EnableDnsHostnames: { Value: true }
|
|
9850
|
-
}));
|
|
9851
|
-
if (properties["EnableDnsSupport"] === false || properties["EnableDnsSupport"] === "false") await this.ec2Client.send(new ModifyVpcAttributeCommand({
|
|
9852
|
-
VpcId: vpcId,
|
|
9853
|
-
EnableDnsSupport: { Value: false }
|
|
9854
|
-
}));
|
|
9855
|
-
await this.applyTags(vpcId, properties, logicalId);
|
|
9856
|
-
await this.ec2Client.send(new DescribeVpcsCommand({ VpcIds: [vpcId] }));
|
|
9857
9847
|
let defaultSgId = "";
|
|
9858
9848
|
try {
|
|
9859
|
-
|
|
9860
|
-
|
|
9861
|
-
|
|
9862
|
-
}
|
|
9863
|
-
|
|
9864
|
-
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
this.
|
|
9849
|
+
if (properties["EnableDnsHostnames"] === true || properties["EnableDnsHostnames"] === "true") await this.ec2Client.send(new ModifyVpcAttributeCommand({
|
|
9850
|
+
VpcId: vpcId,
|
|
9851
|
+
EnableDnsHostnames: { Value: true }
|
|
9852
|
+
}));
|
|
9853
|
+
if (properties["EnableDnsSupport"] === false || properties["EnableDnsSupport"] === "false") await this.ec2Client.send(new ModifyVpcAttributeCommand({
|
|
9854
|
+
VpcId: vpcId,
|
|
9855
|
+
EnableDnsSupport: { Value: false }
|
|
9856
|
+
}));
|
|
9857
|
+
await this.applyTags(vpcId, properties, logicalId);
|
|
9858
|
+
await this.ec2Client.send(new DescribeVpcsCommand({ VpcIds: [vpcId] }));
|
|
9859
|
+
try {
|
|
9860
|
+
defaultSgId = (await this.ec2Client.send(new DescribeSecurityGroupsCommand({ Filters: [{
|
|
9861
|
+
Name: "vpc-id",
|
|
9862
|
+
Values: [vpcId]
|
|
9863
|
+
}, {
|
|
9864
|
+
Name: "group-name",
|
|
9865
|
+
Values: ["default"]
|
|
9866
|
+
}] }))).SecurityGroups?.[0]?.GroupId || "";
|
|
9867
|
+
} catch {
|
|
9868
|
+
this.logger.debug(`Failed to get default SG for VPC ${vpcId}`);
|
|
9869
|
+
}
|
|
9870
|
+
} catch (innerError) {
|
|
9871
|
+
try {
|
|
9872
|
+
await this.ec2Client.send(new DeleteVpcCommand({ VpcId: vpcId }));
|
|
9873
|
+
this.logger.debug(`Cleaned up partially-created VPC ${logicalId} (${vpcId}) after wiring failure`);
|
|
9874
|
+
} catch (cleanupError) {
|
|
9875
|
+
this.logger.warn(`Failed to clean up partially-created VPC ${logicalId} (${vpcId}): ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}. Manual deletion may be required before the next deploy: aws ec2 delete-vpc --vpc-id ${vpcId}`);
|
|
9876
|
+
}
|
|
9877
|
+
throw innerError;
|
|
9868
9878
|
}
|
|
9869
9879
|
this.logger.debug(`Successfully created VPC ${logicalId}: ${vpcId}`);
|
|
9870
9880
|
return {
|
|
@@ -9995,12 +10005,22 @@ var EC2Provider = class {
|
|
|
9995
10005
|
}));
|
|
9996
10006
|
const subnetId = response.Subnet.SubnetId;
|
|
9997
10007
|
const availabilityZone = response.Subnet.AvailabilityZone;
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10003
|
-
|
|
10008
|
+
try {
|
|
10009
|
+
await this.applyTags(subnetId, properties, logicalId);
|
|
10010
|
+
const mapPublicIp = properties["MapPublicIpOnLaunch"];
|
|
10011
|
+
if (mapPublicIp === true || mapPublicIp === "true") await this.ec2Client.send(new ModifySubnetAttributeCommand({
|
|
10012
|
+
SubnetId: subnetId,
|
|
10013
|
+
MapPublicIpOnLaunch: { Value: true }
|
|
10014
|
+
}));
|
|
10015
|
+
} catch (innerError) {
|
|
10016
|
+
try {
|
|
10017
|
+
await this.ec2Client.send(new DeleteSubnetCommand({ SubnetId: subnetId }));
|
|
10018
|
+
this.logger.debug(`Cleaned up partially-created Subnet ${logicalId} (${subnetId}) after wiring failure`);
|
|
10019
|
+
} catch (cleanupError) {
|
|
10020
|
+
this.logger.warn(`Failed to clean up partially-created Subnet ${logicalId} (${subnetId}): ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}. Manual deletion may be required before the next deploy: aws ec2 delete-subnet --subnet-id ${subnetId}`);
|
|
10021
|
+
}
|
|
10022
|
+
throw innerError;
|
|
10023
|
+
}
|
|
10004
10024
|
this.logger.debug(`Successfully created Subnet ${logicalId}: ${subnetId}`);
|
|
10005
10025
|
return {
|
|
10006
10026
|
physicalId: subnetId,
|
|
@@ -10379,29 +10399,39 @@ var EC2Provider = class {
|
|
|
10379
10399
|
Description: groupDescription,
|
|
10380
10400
|
VpcId: properties["VpcId"] ?? void 0
|
|
10381
10401
|
}))).GroupId;
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10402
|
+
try {
|
|
10403
|
+
await this.applyTags(groupId, properties, logicalId);
|
|
10404
|
+
const ingressRules = properties["SecurityGroupIngress"];
|
|
10405
|
+
if (ingressRules && Array.isArray(ingressRules)) for (const rule of ingressRules) await this.ec2Client.send(new AuthorizeSecurityGroupIngressCommand({
|
|
10406
|
+
GroupId: groupId,
|
|
10407
|
+
IpPermissions: [this.buildIpPermission(rule)]
|
|
10408
|
+
}));
|
|
10409
|
+
const egressRules = properties["SecurityGroupEgress"];
|
|
10410
|
+
if (egressRules && Array.isArray(egressRules)) {
|
|
10411
|
+
try {
|
|
10412
|
+
await this.ec2Client.send(new RevokeSecurityGroupEgressCommand({
|
|
10413
|
+
GroupId: groupId,
|
|
10414
|
+
IpPermissions: [{
|
|
10415
|
+
IpProtocol: "-1",
|
|
10416
|
+
IpRanges: [{ CidrIp: "0.0.0.0/0" }]
|
|
10417
|
+
}]
|
|
10418
|
+
}));
|
|
10419
|
+
} catch (error) {
|
|
10420
|
+
if (!this.isNotFoundError(error)) throw error;
|
|
10421
|
+
}
|
|
10422
|
+
for (const rule of egressRules) await this.ec2Client.send(new AuthorizeSecurityGroupEgressCommand({
|
|
10392
10423
|
GroupId: groupId,
|
|
10393
|
-
IpPermissions: [
|
|
10394
|
-
IpProtocol: "-1",
|
|
10395
|
-
IpRanges: [{ CidrIp: "0.0.0.0/0" }]
|
|
10396
|
-
}]
|
|
10424
|
+
IpPermissions: [this.buildIpPermission(rule, "egress")]
|
|
10397
10425
|
}));
|
|
10398
|
-
} catch (error) {
|
|
10399
|
-
if (!this.isNotFoundError(error)) throw error;
|
|
10400
10426
|
}
|
|
10401
|
-
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10427
|
+
} catch (innerError) {
|
|
10428
|
+
try {
|
|
10429
|
+
await this.ec2Client.send(new DeleteSecurityGroupCommand({ GroupId: groupId }));
|
|
10430
|
+
this.logger.debug(`Cleaned up partially-created SecurityGroup ${logicalId} (${groupId}) after wiring failure`);
|
|
10431
|
+
} catch (cleanupError) {
|
|
10432
|
+
this.logger.warn(`Failed to clean up partially-created SecurityGroup ${logicalId} (${groupId}): ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}. Manual deletion may be required before the next deploy: aws ec2 delete-security-group --group-id ${groupId}`);
|
|
10433
|
+
}
|
|
10434
|
+
throw innerError;
|
|
10405
10435
|
}
|
|
10406
10436
|
this.logger.debug(`Successfully created SecurityGroup ${logicalId}: ${groupId}`);
|
|
10407
10437
|
return {
|
|
@@ -10606,26 +10636,36 @@ var EC2Provider = class {
|
|
|
10606
10636
|
}))).Instances?.[0];
|
|
10607
10637
|
if (!instance?.InstanceId) throw new Error("No instance ID returned from RunInstances");
|
|
10608
10638
|
const instanceId = instance.InstanceId;
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10639
|
+
try {
|
|
10640
|
+
await this.applyTags(instanceId, properties, logicalId);
|
|
10641
|
+
this.logger.debug(`Waiting for instance ${instanceId} to be running...`);
|
|
10642
|
+
await waitUntilInstanceRunning({
|
|
10643
|
+
client: this.ec2Client,
|
|
10644
|
+
maxWaitTime: 300
|
|
10645
|
+
}, { InstanceIds: [instanceId] });
|
|
10646
|
+
const runningInstance = (await this.ec2Client.send(new DescribeInstancesCommand({ InstanceIds: [instanceId] }))).Reservations?.[0]?.Instances?.[0];
|
|
10647
|
+
const attributes = {
|
|
10648
|
+
InstanceId: instanceId,
|
|
10649
|
+
PrivateIp: runningInstance?.PrivateIpAddress ?? "",
|
|
10650
|
+
PublicIp: runningInstance?.PublicIpAddress ?? "",
|
|
10651
|
+
PrivateDnsName: runningInstance?.PrivateDnsName ?? "",
|
|
10652
|
+
PublicDnsName: runningInstance?.PublicDnsName ?? "",
|
|
10653
|
+
AvailabilityZone: runningInstance?.Placement?.AvailabilityZone ?? ""
|
|
10654
|
+
};
|
|
10655
|
+
this.logger.debug(`Successfully created EC2 Instance ${logicalId}: ${instanceId}`);
|
|
10656
|
+
return {
|
|
10657
|
+
physicalId: instanceId,
|
|
10658
|
+
attributes
|
|
10659
|
+
};
|
|
10660
|
+
} catch (innerError) {
|
|
10661
|
+
try {
|
|
10662
|
+
await this.ec2Client.send(new TerminateInstancesCommand({ InstanceIds: [instanceId] }));
|
|
10663
|
+
this.logger.debug(`Terminate requested for partially-created EC2 Instance ${logicalId} (${instanceId}) after wiring failure (not waiting for terminated state)`);
|
|
10664
|
+
} catch (cleanupError) {
|
|
10665
|
+
this.logger.warn(`Failed to terminate partially-created EC2 Instance ${logicalId} (${instanceId}): ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}. THE INSTANCE IS STILL RUNNING AND BILLING. Manual termination required: aws ec2 terminate-instances --instance-ids ${instanceId}`);
|
|
10666
|
+
}
|
|
10667
|
+
throw innerError;
|
|
10668
|
+
}
|
|
10629
10669
|
} catch (error) {
|
|
10630
10670
|
if (error instanceof ProvisioningError) throw error;
|
|
10631
10671
|
const cause = error instanceof Error ? error : void 0;
|
|
@@ -42825,7 +42865,7 @@ function reorderArgs(argv) {
|
|
|
42825
42865
|
*/
|
|
42826
42866
|
async function main() {
|
|
42827
42867
|
const program = new Command();
|
|
42828
|
-
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.102.
|
|
42868
|
+
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.102.5");
|
|
42829
42869
|
program.addCommand(createBootstrapCommand());
|
|
42830
42870
|
program.addCommand(createSynthCommand());
|
|
42831
42871
|
program.addCommand(createListCommand());
|