@go-to-k/cdkd 0.102.5 → 0.102.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 CHANGED
@@ -5017,42 +5017,52 @@ var SNSTopicProvider = class {
5017
5017
  };
5018
5018
  const topicArn = (await this.snsClient.send(new CreateTopicCommand(createParams))).TopicArn;
5019
5019
  if (!topicArn) throw new Error("CreateTopic did not return TopicArn");
5020
- if (properties["ArchivePolicy"]) {
5021
- const archivePolicy = typeof properties["ArchivePolicy"] === "string" ? properties["ArchivePolicy"] : JSON.stringify(properties["ArchivePolicy"]);
5022
- await this.snsClient.send(new SetTopicAttributesCommand({
5023
- TopicArn: topicArn,
5024
- AttributeName: "ArchivePolicy",
5025
- AttributeValue: archivePolicy
5026
- }));
5027
- }
5028
- if (properties["DataProtectionPolicy"]) {
5029
- const dataProtectionPolicy = typeof properties["DataProtectionPolicy"] === "string" ? properties["DataProtectionPolicy"] : JSON.stringify(properties["DataProtectionPolicy"]);
5030
- await this.snsClient.send(new SetTopicAttributesCommand({
5031
- TopicArn: topicArn,
5032
- AttributeName: "DataProtectionPolicy",
5033
- AttributeValue: dataProtectionPolicy
5034
- }));
5035
- }
5036
- if (properties["DeliveryStatusLogging"]) {
5037
- const loggingConfigs = properties["DeliveryStatusLogging"];
5038
- for (const config of loggingConfigs) {
5039
- const protocol = normalizeDeliveryStatusProtocolOrThrow(config["Protocol"], logicalId);
5040
- if (config["SuccessFeedbackRoleArn"]) await this.snsClient.send(new SetTopicAttributesCommand({
5041
- TopicArn: topicArn,
5042
- AttributeName: `${protocol}SuccessFeedbackRoleArn`,
5043
- AttributeValue: config["SuccessFeedbackRoleArn"]
5044
- }));
5045
- if (config["SuccessFeedbackSampleRate"]) await this.snsClient.send(new SetTopicAttributesCommand({
5020
+ try {
5021
+ if (properties["ArchivePolicy"]) {
5022
+ const archivePolicy = typeof properties["ArchivePolicy"] === "string" ? properties["ArchivePolicy"] : JSON.stringify(properties["ArchivePolicy"]);
5023
+ await this.snsClient.send(new SetTopicAttributesCommand({
5046
5024
  TopicArn: topicArn,
5047
- AttributeName: `${protocol}SuccessFeedbackSampleRate`,
5048
- AttributeValue: stringifyValue(config["SuccessFeedbackSampleRate"])
5025
+ AttributeName: "ArchivePolicy",
5026
+ AttributeValue: archivePolicy
5049
5027
  }));
5050
- if (config["FailureFeedbackRoleArn"]) await this.snsClient.send(new SetTopicAttributesCommand({
5028
+ }
5029
+ if (properties["DataProtectionPolicy"]) {
5030
+ const dataProtectionPolicy = typeof properties["DataProtectionPolicy"] === "string" ? properties["DataProtectionPolicy"] : JSON.stringify(properties["DataProtectionPolicy"]);
5031
+ await this.snsClient.send(new SetTopicAttributesCommand({
5051
5032
  TopicArn: topicArn,
5052
- AttributeName: `${protocol}FailureFeedbackRoleArn`,
5053
- AttributeValue: config["FailureFeedbackRoleArn"]
5033
+ AttributeName: "DataProtectionPolicy",
5034
+ AttributeValue: dataProtectionPolicy
5054
5035
  }));
5055
5036
  }
5037
+ if (properties["DeliveryStatusLogging"]) {
5038
+ const loggingConfigs = properties["DeliveryStatusLogging"];
5039
+ for (const config of loggingConfigs) {
5040
+ const protocol = normalizeDeliveryStatusProtocolOrThrow(config["Protocol"], logicalId);
5041
+ if (config["SuccessFeedbackRoleArn"]) await this.snsClient.send(new SetTopicAttributesCommand({
5042
+ TopicArn: topicArn,
5043
+ AttributeName: `${protocol}SuccessFeedbackRoleArn`,
5044
+ AttributeValue: config["SuccessFeedbackRoleArn"]
5045
+ }));
5046
+ if (config["SuccessFeedbackSampleRate"]) await this.snsClient.send(new SetTopicAttributesCommand({
5047
+ TopicArn: topicArn,
5048
+ AttributeName: `${protocol}SuccessFeedbackSampleRate`,
5049
+ AttributeValue: stringifyValue(config["SuccessFeedbackSampleRate"])
5050
+ }));
5051
+ if (config["FailureFeedbackRoleArn"]) await this.snsClient.send(new SetTopicAttributesCommand({
5052
+ TopicArn: topicArn,
5053
+ AttributeName: `${protocol}FailureFeedbackRoleArn`,
5054
+ AttributeValue: config["FailureFeedbackRoleArn"]
5055
+ }));
5056
+ }
5057
+ }
5058
+ } catch (innerError) {
5059
+ try {
5060
+ await this.snsClient.send(new DeleteTopicCommand({ TopicArn: topicArn }));
5061
+ this.logger.debug(`Cleaned up partially-created SNS topic ${logicalId} (${topicArn}) after wiring failure`);
5062
+ } catch (cleanupError) {
5063
+ this.logger.warn(`Failed to clean up partially-created SNS topic ${logicalId} (${topicArn}): ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}. Manual deletion may be required before the next deploy: aws sns delete-topic --topic-arn ${topicArn}`);
5064
+ }
5065
+ throw innerError;
5056
5066
  }
5057
5067
  this.logger.debug(`Successfully created SNS topic ${logicalId}: ${topicArn}`);
5058
5068
  return {
@@ -9118,13 +9128,36 @@ var EventBridgeRuleProvider = class {
9118
9128
  if (properties["Tags"]) putRuleParams["Tags"] = properties["Tags"];
9119
9129
  const ruleArn = (await this.eventBridgeClient.send(new PutRuleCommand(putRuleParams))).RuleArn;
9120
9130
  this.logger.debug(`Created EventBridge rule: ${ruleName} (${ruleArn})`);
9121
- if (targets && targets.length > 0) {
9122
- await this.eventBridgeClient.send(new PutTargetsCommand({
9123
- Rule: ruleName,
9124
- EventBusName: properties["EventBusName"],
9125
- Targets: targets
9126
- }));
9127
- this.logger.debug(`Added ${targets.length} targets to rule ${ruleName}`);
9131
+ const eventBusName = properties["EventBusName"];
9132
+ try {
9133
+ if (targets && targets.length > 0) {
9134
+ await this.eventBridgeClient.send(new PutTargetsCommand({
9135
+ Rule: ruleName,
9136
+ EventBusName: eventBusName,
9137
+ Targets: targets
9138
+ }));
9139
+ this.logger.debug(`Added ${targets.length} targets to rule ${ruleName}`);
9140
+ }
9141
+ } catch (innerError) {
9142
+ try {
9143
+ const targetIds = ((await this.eventBridgeClient.send(new ListTargetsByRuleCommand({
9144
+ Rule: ruleName,
9145
+ EventBusName: eventBusName
9146
+ }))).Targets || []).map((t) => t.Id).filter((id) => id !== void 0);
9147
+ if (targetIds.length > 0) await this.eventBridgeClient.send(new RemoveTargetsCommand({
9148
+ Rule: ruleName,
9149
+ EventBusName: eventBusName,
9150
+ Ids: targetIds
9151
+ }));
9152
+ await this.eventBridgeClient.send(new DeleteRuleCommand({
9153
+ Name: ruleName,
9154
+ EventBusName: eventBusName
9155
+ }));
9156
+ this.logger.debug(`Cleaned up partially-created EventBridge rule ${logicalId} (${ruleName}) after wiring failure`);
9157
+ } catch (cleanupError) {
9158
+ this.logger.warn(`Failed to clean up partially-created EventBridge rule ${logicalId} (${ruleName}): ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}. Manual deletion may be required before the next deploy: aws events list-targets-by-rule --rule ${ruleName}${eventBusName ? ` --event-bus-name ${eventBusName}` : ""} | jq -r '.Targets[].Id' | xargs aws events remove-targets --rule ${ruleName}${eventBusName ? ` --event-bus-name ${eventBusName}` : ""} --ids; aws events delete-rule --name ${ruleName}${eventBusName ? ` --event-bus-name ${eventBusName}` : ""}`);
9159
+ }
9160
+ throw innerError;
9128
9161
  }
9129
9162
  return {
9130
9163
  physicalId: ruleArn,
@@ -15916,25 +15949,36 @@ var ELBv2Provider = class {
15916
15949
  ...tags.length > 0 && { Tags: tags }
15917
15950
  }))).LoadBalancers?.[0];
15918
15951
  if (!lb || !lb.LoadBalancerArn) throw new Error("CreateLoadBalancer did not return LoadBalancer ARN");
15919
- this.logger.debug(`Successfully created LoadBalancer ${logicalId}: ${lb.LoadBalancerArn}`);
15920
- const lbAttributes = properties["LoadBalancerAttributes"];
15921
- if (lbAttributes && lbAttributes.length > 0) {
15922
- await this.getClient().send(new ModifyLoadBalancerAttributesCommand({
15923
- LoadBalancerArn: lb.LoadBalancerArn,
15924
- Attributes: lbAttributes.map((attr) => ({
15925
- Key: attr.Key,
15926
- Value: attr.Value
15927
- }))
15928
- }));
15929
- this.logger.debug(`Applied ${lbAttributes.length} LoadBalancer attributes for ${logicalId}`);
15952
+ const lbArn = lb.LoadBalancerArn;
15953
+ this.logger.debug(`Successfully created LoadBalancer ${logicalId}: ${lbArn}`);
15954
+ try {
15955
+ const lbAttributes = properties["LoadBalancerAttributes"];
15956
+ if (lbAttributes && lbAttributes.length > 0) {
15957
+ await this.getClient().send(new ModifyLoadBalancerAttributesCommand({
15958
+ LoadBalancerArn: lbArn,
15959
+ Attributes: lbAttributes.map((attr) => ({
15960
+ Key: attr.Key,
15961
+ Value: attr.Value
15962
+ }))
15963
+ }));
15964
+ this.logger.debug(`Applied ${lbAttributes.length} LoadBalancer attributes for ${logicalId}`);
15965
+ }
15966
+ } catch (innerError) {
15967
+ try {
15968
+ await this.getClient().send(new DeleteLoadBalancerCommand({ LoadBalancerArn: lbArn }));
15969
+ this.logger.debug(`Cleaned up partially-created LoadBalancer ${logicalId} (${lbArn}) after wiring failure`);
15970
+ } catch (cleanupError) {
15971
+ this.logger.warn(`Failed to clean up partially-created LoadBalancer ${logicalId} (${lbArn}): ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}. Manual deletion may be required before the next deploy: aws elbv2 delete-load-balancer --load-balancer-arn ${lbArn}`);
15972
+ }
15973
+ throw innerError;
15930
15974
  }
15931
15975
  return {
15932
- physicalId: lb.LoadBalancerArn,
15976
+ physicalId: lbArn,
15933
15977
  attributes: {
15934
15978
  DNSName: lb.DNSName,
15935
15979
  CanonicalHostedZoneID: lb.CanonicalHostedZoneId,
15936
- LoadBalancerArn: lb.LoadBalancerArn,
15937
- LoadBalancerFullName: lb.LoadBalancerArn?.split("/").slice(1).join("/"),
15980
+ LoadBalancerArn: lbArn,
15981
+ LoadBalancerFullName: lbArn.split("/").slice(1).join("/"),
15938
15982
  LoadBalancerName: lb.LoadBalancerName
15939
15983
  }
15940
15984
  };
@@ -42865,7 +42909,7 @@ function reorderArgs(argv) {
42865
42909
  */
42866
42910
  async function main() {
42867
42911
  const program = new Command();
42868
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.102.5");
42912
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.102.6");
42869
42913
  program.addCommand(createBootstrapCommand());
42870
42914
  program.addCommand(createSynthCommand());
42871
42915
  program.addCommand(createListCommand());