@go-to-k/cdkd 0.267.7 → 0.267.8

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.
@@ -1,4 +1,4 @@
1
- import { E as clearOnUpdateRemoval, L as normalizeAwsTagsToCfn, fn as __exportAll, j as disableInstanceApiTermination, rn as ResourceUpdateNotSupportedError, tn as ProvisioningError, z as assertRegionMatch } from "./deploy-engine-C5ZBU7Ci.js";
1
+ import { E as clearOnUpdateRemoval, L as normalizeAwsTagsToCfn, fn as __exportAll, j as disableInstanceApiTermination, rn as ResourceUpdateNotSupportedError, tn as ProvisioningError, z as assertRegionMatch } from "./deploy-engine-DPphskEY.js";
2
2
  import { n as getLogger, u as generateResourceName } from "./logger-BYMEE-BS.js";
3
3
  import { EC2Client } from "@aws-sdk/client-ec2";
4
4
  import { AttachLoadBalancerTargetGroupsCommand, AttachLoadBalancersCommand, AttachTrafficSourcesCommand, AutoScalingClient, CreateAutoScalingGroupCommand, CreateOrUpdateTagsCommand, DeleteAutoScalingGroupCommand, DeleteLifecycleHookCommand, DeleteNotificationConfigurationCommand, DeleteTagsCommand as DeleteTagsCommand$1, DescribeAutoScalingGroupsCommand, DescribeLifecycleHooksCommand, DescribeNotificationConfigurationsCommand, DescribeTrafficSourcesCommand, DetachLoadBalancerTargetGroupsCommand, DetachLoadBalancersCommand, DetachTrafficSourcesCommand, DisableMetricsCollectionCommand, EnableMetricsCollectionCommand, PutLifecycleHookCommand, PutNotificationConfigurationCommand, UpdateAutoScalingGroupCommand } from "@aws-sdk/client-auto-scaling";
@@ -810,4 +810,4 @@ function mapNotificationsToCfn(configurations) {
810
810
 
811
811
  //#endregion
812
812
  export { asg_provider_exports as n, ASGProvider as t };
813
- //# sourceMappingURL=asg-provider-D6491unb.js.map
813
+ //# sourceMappingURL=asg-provider-BQswANyu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"asg-provider-D6491unb.js","names":["DeleteTagsCommand"],"sources":["../src/provisioning/providers/asg-provider.ts"],"sourcesContent":["import {\n AutoScalingClient,\n CreateAutoScalingGroupCommand,\n UpdateAutoScalingGroupCommand,\n DeleteAutoScalingGroupCommand,\n DescribeAutoScalingGroupsCommand,\n type DescribeAutoScalingGroupsCommandOutput,\n DescribeLifecycleHooksCommand,\n DescribeTrafficSourcesCommand,\n DescribeNotificationConfigurationsCommand,\n EnableMetricsCollectionCommand,\n DisableMetricsCollectionCommand,\n PutLifecycleHookCommand,\n DeleteLifecycleHookCommand,\n AttachTrafficSourcesCommand,\n DetachTrafficSourcesCommand,\n PutNotificationConfigurationCommand,\n DeleteNotificationConfigurationCommand,\n CreateOrUpdateTagsCommand,\n DeleteTagsCommand,\n AttachLoadBalancersCommand,\n DetachLoadBalancersCommand,\n AttachLoadBalancerTargetGroupsCommand,\n DetachLoadBalancerTargetGroupsCommand,\n type Tag as ASGTag,\n type LaunchTemplateSpecification,\n type AvailabilityZoneDistribution,\n type CapacityReservationSpecification,\n type DeletionProtection,\n type InstanceMaintenancePolicy,\n} from '@aws-sdk/client-auto-scaling';\nimport { EC2Client } from '@aws-sdk/client-ec2';\nimport { getLogger } from '../../utils/logger.js';\nimport { ProvisioningError, ResourceUpdateNotSupportedError } from '../../utils/error-handler.js';\nimport { assertRegionMatch, type DeleteContext } from '../region-check.js';\nimport { disableInstanceApiTermination } from '../ec2-termination-protection.js';\nimport { generateResourceName } from '../resource-name.js';\nimport { normalizeAwsTagsToCfn } from '../import-helpers.js';\nimport type {\n ResourceProvider,\n ResourceCreateResult,\n ResourceUpdateResult,\n} from '../../types/resource.js';\nimport { clearOnUpdateRemoval } from '../update-removal.js';\n\n/**\n * AWS Auto Scaling Provider\n *\n * Implements resource provisioning for `AWS::AutoScaling::AutoScalingGroup`.\n *\n * WHY a dedicated SDK provider (instead of CC API fallback):\n * 1. Owns the `--remove-protection` flip-off: ASG protection has three\n * levels (`none` / `prevent-force-deletion` / `prevent-all-deletion`)\n * and the destroy path needs to (a) clear it via `UpdateAutoScalingGroup\n * ({DeletionProtection: 'none'})` before the actual delete and (b) set\n * `ForceDelete: true` on `DeleteAutoScalingGroup` so AWS terminates any\n * running instances as part of the delete (matches the user's \"I know\n * what I'm doing\" intent).\n * 2. Faster than CC API for the common case — direct Create/Update calls\n * with no eventual-consistency polling beyond what `DescribeAutoScaling\n * Groups` already provides.\n *\n * Update has narrower coverage than create: AWS does not support modifying\n * `AutoScalingGroupName` (immutable) — that diff still surfaces\n * `ResourceUpdateNotSupportedError` so the caller can `cdkd deploy\n * --replace`. The mutable fields handled in-place via\n * `UpdateAutoScalingGroup` include MinSize / MaxSize / DesiredCapacity /\n * VPCZoneIdentifier / HealthCheckType / HealthCheckGracePeriod /\n * DefaultCooldown / Cooldown / NewInstancesProtectedFromScaleIn /\n * MaxInstanceLifetime / TerminationPolicies / CapacityRebalance /\n * ServiceLinkedRoleARN / Context / DesiredCapacityType /\n * DefaultInstanceWarmup / AvailabilityZones / AvailabilityZoneDistribution\n * / AvailabilityZoneImpairmentPolicy / SkipZonalShiftValidation /\n * CapacityReservationSpecification / InstanceMaintenancePolicy /\n * DeletionProtection / MixedInstancesPolicy / LaunchTemplate.\n *\n * `UpdateAutoScalingGroup` has merge semantics (absent input field = \"no\n * change\"), so update() routes every optional mutable field through\n * `clearOnUpdateRemoval` — a property REMOVED from the template is reset to\n * its CFn default / SDK-documented clear sentinel, matching CloudFormation\n * (issue #1160).\n *\n * Sub-shape diffs are applied via dedicated AWS APIs before the main\n * `UpdateAutoScalingGroup` call:\n * - `Tags` → `CreateOrUpdateTags` / `DeleteTags` (#475)\n * - `LoadBalancerNames` → `AttachLoadBalancers` /\n * `DetachLoadBalancers` (#476)\n * - `TargetGroupARNs` → `AttachLoadBalancerTargetGroups` /\n * `DetachLoadBalancerTargetGroups` (#476)\n * - `MetricsCollection` → `EnableMetricsCollection` /\n * `DisableMetricsCollection`\n * - `LifecycleHookSpecificationList` → per-entry `PutLifecycleHook` /\n * `DeleteLifecycleHook`\n * - `TrafficSources` → `AttachTrafficSources` /\n * `DetachTrafficSources`\n * - `NotificationConfigurations` → per-topic\n * `PutNotificationConfiguration` /\n * `DeleteNotificationConfiguration`\n *\n * Each helper is a no-op when the before/after JSON is identical.\n */\nexport class ASGProvider implements ResourceProvider {\n private asgClient?: AutoScalingClient;\n private ec2Client?: EC2Client;\n private readonly providerRegion = process.env['AWS_REGION'];\n private logger = getLogger().child('ASGProvider');\n\n handledProperties = new Map<string, ReadonlySet<string>>([\n [\n 'AWS::AutoScaling::AutoScalingGroup',\n new Set([\n 'AutoScalingGroupName',\n 'LaunchTemplate',\n 'MinSize',\n 'MaxSize',\n 'DesiredCapacity',\n 'VPCZoneIdentifier',\n 'AvailabilityZones',\n 'HealthCheckType',\n 'HealthCheckGracePeriod',\n 'Cooldown',\n 'DefaultCooldown',\n 'Tags',\n 'TerminationPolicies',\n 'NewInstancesProtectedFromScaleIn',\n 'CapacityRebalance',\n 'ServiceLinkedRoleARN',\n 'MaxInstanceLifetime',\n 'LoadBalancerNames',\n 'TargetGroupARNs',\n 'MetricsCollection',\n 'LifecycleHookSpecificationList',\n 'MixedInstancesPolicy',\n 'Context',\n 'DesiredCapacityType',\n 'DefaultInstanceWarmup',\n 'TrafficSources',\n 'NotificationConfigurations',\n 'AvailabilityZoneDistribution',\n 'AvailabilityZoneImpairmentPolicy',\n 'SkipZonalShiftValidation',\n 'CapacityReservationSpecification',\n 'InstanceMaintenancePolicy',\n 'DeletionProtection',\n ]),\n ],\n ]);\n\n unhandledByDesign = new Map<string, ReadonlyMap<string, string>>([\n [\n 'AWS::AutoScaling::AutoScalingGroup',\n new Map<string, string>([\n [\n 'LaunchConfigurationName',\n 'AWS Launch Configurations end-of-life 2024-10; use LaunchTemplate instead',\n ],\n [\n 'NotificationConfiguration',\n 'Legacy singular form; use NotificationConfigurations (plural) which cdkd already wires',\n ],\n ]),\n ],\n ]);\n\n private getClient(): AutoScalingClient {\n if (!this.asgClient) {\n this.asgClient = new AutoScalingClient(\n this.providerRegion ? { region: this.providerRegion } : {}\n );\n }\n return this.asgClient;\n }\n\n private getEc2Client(): EC2Client {\n if (!this.ec2Client) {\n this.ec2Client = new EC2Client(this.providerRegion ? { region: this.providerRegion } : {});\n }\n return this.ec2Client;\n }\n\n // ─── Dispatch ─────────────────────────────────────────────────────\n\n async create(\n logicalId: string,\n resourceType: string,\n properties: Record<string, unknown>\n ): Promise<ResourceCreateResult> {\n if (resourceType !== 'AWS::AutoScaling::AutoScalingGroup') {\n throw new ProvisioningError(\n `Unsupported resource type: ${resourceType}`,\n resourceType,\n logicalId\n );\n }\n\n const groupName =\n (properties['AutoScalingGroupName'] as string | undefined) ||\n generateResourceName(logicalId, { maxLength: 255 });\n\n this.logger.debug(`Creating AutoScalingGroup ${logicalId}: ${groupName}`);\n\n try {\n const launchTemplate = this.buildLaunchTemplate(properties);\n const tags = this.buildTags(groupName, properties);\n const vpcZoneIdentifier = this.joinVpcZoneIdentifier(properties['VPCZoneIdentifier']);\n\n const minSize = properties['MinSize'] != null ? Number(properties['MinSize']) : 0;\n const maxSize = properties['MaxSize'] != null ? Number(properties['MaxSize']) : minSize;\n\n await this.getClient().send(\n new CreateAutoScalingGroupCommand({\n AutoScalingGroupName: groupName,\n MinSize: minSize,\n MaxSize: maxSize,\n ...(properties['DesiredCapacity'] != null && {\n DesiredCapacity: Number(properties['DesiredCapacity']),\n }),\n ...(launchTemplate && { LaunchTemplate: launchTemplate }),\n ...(properties['MixedInstancesPolicy'] !== undefined && {\n MixedInstancesPolicy: properties['MixedInstancesPolicy'] as never,\n }),\n ...(vpcZoneIdentifier !== undefined && { VPCZoneIdentifier: vpcZoneIdentifier }),\n ...(properties['AvailabilityZones'] !== undefined && {\n AvailabilityZones: properties['AvailabilityZones'] as string[],\n }),\n ...(properties['HealthCheckType'] !== undefined && {\n HealthCheckType: properties['HealthCheckType'] as string,\n }),\n ...(properties['HealthCheckGracePeriod'] != null && {\n HealthCheckGracePeriod: Number(properties['HealthCheckGracePeriod']),\n }),\n ...(properties['Cooldown'] != null && {\n DefaultCooldown: Number(properties['Cooldown']),\n }),\n ...(properties['DefaultCooldown'] != null && {\n DefaultCooldown: Number(properties['DefaultCooldown']),\n }),\n ...(properties['TerminationPolicies'] !== undefined && {\n TerminationPolicies: properties['TerminationPolicies'] as string[],\n }),\n ...(properties['NewInstancesProtectedFromScaleIn'] !== undefined && {\n NewInstancesProtectedFromScaleIn: properties[\n 'NewInstancesProtectedFromScaleIn'\n ] as boolean,\n }),\n ...(properties['CapacityRebalance'] !== undefined && {\n CapacityRebalance: properties['CapacityRebalance'] as boolean,\n }),\n ...(properties['ServiceLinkedRoleARN'] !== undefined && {\n ServiceLinkedRoleARN: properties['ServiceLinkedRoleARN'] as string,\n }),\n ...(properties['MaxInstanceLifetime'] != null && {\n MaxInstanceLifetime: Number(properties['MaxInstanceLifetime']),\n }),\n ...(properties['LoadBalancerNames'] !== undefined && {\n LoadBalancerNames: properties['LoadBalancerNames'] as string[],\n }),\n ...(properties['TargetGroupARNs'] !== undefined && {\n TargetGroupARNs: properties['TargetGroupARNs'] as string[],\n }),\n ...(properties['Context'] !== undefined && {\n Context: properties['Context'] as string,\n }),\n ...(properties['DesiredCapacityType'] !== undefined && {\n DesiredCapacityType: properties['DesiredCapacityType'] as string,\n }),\n ...(properties['DefaultInstanceWarmup'] != null && {\n DefaultInstanceWarmup: Number(properties['DefaultInstanceWarmup']),\n }),\n ...(properties['LifecycleHookSpecificationList'] !== undefined && {\n LifecycleHookSpecificationList: properties['LifecycleHookSpecificationList'] as never,\n }),\n ...(properties['TrafficSources'] !== undefined && {\n TrafficSources: properties['TrafficSources'] as never,\n }),\n ...(properties['AvailabilityZoneDistribution'] !== undefined && {\n AvailabilityZoneDistribution: properties['AvailabilityZoneDistribution'] as never,\n }),\n ...(properties['AvailabilityZoneImpairmentPolicy'] !== undefined && {\n AvailabilityZoneImpairmentPolicy: properties[\n 'AvailabilityZoneImpairmentPolicy'\n ] as never,\n }),\n ...(properties['SkipZonalShiftValidation'] !== undefined && {\n SkipZonalShiftValidation: properties['SkipZonalShiftValidation'] as boolean,\n }),\n ...(properties['CapacityReservationSpecification'] !== undefined && {\n CapacityReservationSpecification: properties[\n 'CapacityReservationSpecification'\n ] as never,\n }),\n ...(properties['InstanceMaintenancePolicy'] !== undefined && {\n InstanceMaintenancePolicy: properties['InstanceMaintenancePolicy'] as never,\n }),\n ...(properties['DeletionProtection'] !== undefined && {\n DeletionProtection: properties['DeletionProtection'] as never,\n }),\n ...(tags.length > 0 && { Tags: tags }),\n })\n );\n\n this.logger.debug(`Successfully created AutoScalingGroup ${logicalId}: ${groupName}`);\n\n const arn = await this.fetchArn(groupName);\n const attributes: Record<string, unknown> = {};\n if (arn) attributes['Arn'] = arn;\n if (launchTemplate?.LaunchTemplateId) {\n attributes['LaunchTemplateID'] = launchTemplate.LaunchTemplateId;\n }\n return { physicalId: groupName, attributes };\n } catch (error) {\n const cause = error instanceof Error ? error : undefined;\n throw new ProvisioningError(\n `Failed to create AutoScalingGroup ${logicalId}: ${error instanceof Error ? error.message : String(error)}`,\n resourceType,\n logicalId,\n groupName,\n cause\n );\n }\n }\n\n async update(\n logicalId: string,\n physicalId: string,\n resourceType: string,\n properties: Record<string, unknown>,\n previousProperties: Record<string, unknown>\n ): Promise<ResourceUpdateResult> {\n if (resourceType !== 'AWS::AutoScaling::AutoScalingGroup') {\n throw new ProvisioningError(\n `Unsupported resource type: ${resourceType}`,\n resourceType,\n logicalId,\n physicalId\n );\n }\n this.logger.debug(`Updating AutoScalingGroup ${logicalId}: ${physicalId}`);\n\n // Reject diffs on fields AWS does not support modifying via\n // UpdateAutoScalingGroup. The replacement-detection layer typically\n // catches AutoScalingGroupName changes earlier; this is defense-in-\n // depth + the only place to surface the equivalent error for\n // sub-resource fields the caller may reasonably expect to round-trip.\n const stringEq = (a: unknown, b: unknown): boolean => JSON.stringify(a) === JSON.stringify(b);\n if (!stringEq(properties['AutoScalingGroupName'], previousProperties['AutoScalingGroupName'])) {\n throw new ResourceUpdateNotSupportedError(\n resourceType,\n logicalId,\n 'AutoScalingGroupName is immutable on AWS — UpdateAutoScalingGroup does not accept a new name; the name is fixed at creation. Use cdkd deploy --replace to replace the group.'\n );\n }\n try {\n // Sub-shape diffs are applied via separate per-shape SDK calls\n // BEFORE the main UpdateAutoScalingGroup. AWS does not expose these\n // fields on UpdateAutoScalingGroup, so each one rides its own\n // dedicated API. Each per-shape helper is a no-op when the\n // before/after JSON is identical.\n await this.applyTagsDiff(physicalId, properties['Tags'], previousProperties['Tags']);\n await this.applyLoadBalancerNamesDiff(\n physicalId,\n properties['LoadBalancerNames'],\n previousProperties['LoadBalancerNames']\n );\n await this.applyTargetGroupArnsDiff(\n physicalId,\n properties['TargetGroupARNs'],\n previousProperties['TargetGroupARNs']\n );\n await this.applyMetricsCollectionDiff(\n physicalId,\n properties['MetricsCollection'],\n previousProperties['MetricsCollection']\n );\n await this.applyLifecycleHooksDiff(\n physicalId,\n properties['LifecycleHookSpecificationList'],\n previousProperties['LifecycleHookSpecificationList']\n );\n await this.applyTrafficSourcesDiff(\n physicalId,\n properties['TrafficSources'],\n previousProperties['TrafficSources']\n );\n await this.applyNotificationConfigurationsDiff(\n physicalId,\n properties['NotificationConfigurations'],\n previousProperties['NotificationConfigurations']\n );\n\n const launchTemplate = this.buildLaunchTemplate(properties);\n const vpcZoneIdentifier = this.joinVpcZoneIdentifier(properties['VPCZoneIdentifier']);\n\n // issue #1160: `UpdateAutoScalingGroup` has merge semantics — an absent\n // input field means \"no change\" — while CloudFormation resets a property\n // REMOVED from the template to its default. Resolve every optional\n // mutable field through `clearOnUpdateRemoval` so a removal sends the\n // explicit CFn default (or the SDK-documented clear sentinel) instead of\n // silently keeping the old live value. Each reset value's doc basis is\n // noted inline (models_0.d.ts = the AWS SDK command/model doc).\n //\n // Deliberately NOT reset on removal:\n // - DesiredCapacity: CFn leaves current capacity unmanaged when the\n // property is absent (scaling policies own it) — leaving it\n // unchanged IS the CFn-parity behavior.\n // - MinSize / MaxSize: required properties, never removable.\n // - LaunchTemplate vs MixedInstancesPolicy, VPCZoneIdentifier vs\n // AvailabilityZones: mutually-exclusive pairs — a \"removal\" is\n // really a switch to the other member, which the API applies by\n // presence; pure removal of both is an invalid template.\n // - ServiceLinkedRoleARN: no documented clear sentinel; the default\n // is an account-specific service-linked-role ARN — leave unchanged.\n // - Context: SDK doc says \"Reserved.\" — leave unchanged.\n // - SkipZonalShiftValidation: transient per-request validation flag,\n // not persisted group config — nothing to reset.\n // - AvailabilityZoneImpairmentPolicy: DEFERRED — the SDK model\n // documents no default for `ImpairedZoneHealthCheckBehavior` (and\n // none for `ZonalShiftEnabled`), so a reset shape cannot be derived\n // without guessing; removal currently keeps the live value.\n //\n // Sub-field removal inside a KEPT config object (issue #1225 — the\n // #1160 bug class one level down) is deliberately passed through\n // verbatim here:\n // - InstanceMaintenancePolicy: a kept-but-partial object (one of the\n // two percentages dropped) is REJECTED by AWS — the SDK doc requires\n // \"Both MinHealthyPercentage and MaxHealthyPercentage must be\n // specified\". CloudFormation submits the same partial object, so the\n // loud failure IS the CFn-parity behavior; there is no silent drop\n // to normalize away.\n // - CapacityReservationSpecification: whether AWS keeps or clears a\n // previously-set CapacityReservationTarget when only the preference\n // is re-sent is UNPROBED (a live probe needs a billed Capacity\n // Reservation); the kept-partial object passes through unchanged.\n // - AvailabilityZoneDistribution: single sub-field — no partial shape\n // exists.\n const healthCheckTypeInput = clearOnUpdateRemoval(\n properties['HealthCheckType'] as string | undefined,\n previousProperties['HealthCheckType'] as string | undefined,\n // SDK doc: \"EC2 is the default health check and cannot be disabled.\n // ... Only specify EC2 if you must clear a value that was previously\n // set.\"\n 'EC2'\n );\n const healthCheckGracePeriodInput = clearOnUpdateRemoval(\n properties['HealthCheckGracePeriod'] != null\n ? Number(properties['HealthCheckGracePeriod'])\n : undefined,\n previousProperties['HealthCheckGracePeriod'] != null\n ? Number(previousProperties['HealthCheckGracePeriod'])\n : undefined,\n // CFn default: 0 seconds.\n 0\n );\n // CFn's template key is `Cooldown`; cdkd also accepts the SDK-side\n // spelling `DefaultCooldown`. Treat the two keys as ONE logical field on\n // both sides so switching spellings is never misread as a removal.\n const cooldownRaw = properties['Cooldown'] ?? properties['DefaultCooldown'];\n const prevCooldownRaw =\n previousProperties['Cooldown'] ?? previousProperties['DefaultCooldown'];\n const defaultCooldownInput = clearOnUpdateRemoval(\n cooldownRaw != null ? Number(cooldownRaw) : undefined,\n prevCooldownRaw != null ? Number(prevCooldownRaw) : undefined,\n // CFn default: 300 seconds.\n 300\n );\n const terminationPoliciesInput = clearOnUpdateRemoval(\n properties['TerminationPolicies'] as string[] | undefined,\n previousProperties['TerminationPolicies'] as string[] | undefined,\n // CFn/API default termination policy.\n ['Default']\n );\n const newInstancesProtectedInput = clearOnUpdateRemoval(\n properties['NewInstancesProtectedFromScaleIn'] as boolean | undefined,\n previousProperties['NewInstancesProtectedFromScaleIn'] as boolean | undefined,\n false\n );\n const capacityRebalanceInput = clearOnUpdateRemoval(\n properties['CapacityRebalance'] as boolean | undefined,\n previousProperties['CapacityRebalance'] as boolean | undefined,\n false\n );\n const maxInstanceLifetimeInput = clearOnUpdateRemoval(\n properties['MaxInstanceLifetime'] != null\n ? Number(properties['MaxInstanceLifetime'])\n : undefined,\n previousProperties['MaxInstanceLifetime'] != null\n ? Number(previousProperties['MaxInstanceLifetime'])\n : undefined,\n // SDK doc: \"To clear a previously set value, specify a new value of 0.\"\n 0\n );\n const desiredCapacityTypeInput = clearOnUpdateRemoval(\n properties['DesiredCapacityType'] as string | undefined,\n previousProperties['DesiredCapacityType'] as string | undefined,\n // SDK doc: \"By default, Amazon EC2 Auto Scaling specifies units\".\n 'units'\n );\n const defaultInstanceWarmupInput = clearOnUpdateRemoval(\n properties['DefaultInstanceWarmup'] != null\n ? Number(properties['DefaultInstanceWarmup'])\n : undefined,\n previousProperties['DefaultInstanceWarmup'] != null\n ? Number(previousProperties['DefaultInstanceWarmup'])\n : undefined,\n // SDK doc: \"To remove a value that you previously set, include the\n // property but specify -1 for the value.\"\n -1\n );\n const instanceMaintenancePolicyInput = clearOnUpdateRemoval(\n properties['InstanceMaintenancePolicy'] as InstanceMaintenancePolicy | undefined,\n previousProperties['InstanceMaintenancePolicy'] as InstanceMaintenancePolicy | undefined,\n // SDK doc (both sub-fields): \"To clear a previously set value,\n // specify a value of -1.\"\n { MinHealthyPercentage: -1, MaxHealthyPercentage: -1 }\n );\n const capacityReservationSpecInput = clearOnUpdateRemoval(\n properties['CapacityReservationSpecification'] as\n | CapacityReservationSpecification\n | undefined,\n previousProperties['CapacityReservationSpecification'] as\n | CapacityReservationSpecification\n | undefined,\n // SDK doc: \"default - Auto Scaling uses the Capacity Reservation\n // preference from your launch template or an open Capacity\n // Reservation.\" — the behavior of a group that never set the field.\n { CapacityReservationPreference: 'default' }\n );\n const availabilityZoneDistributionInput = clearOnUpdateRemoval(\n properties['AvailabilityZoneDistribution'] as AvailabilityZoneDistribution | undefined,\n previousProperties['AvailabilityZoneDistribution'] as\n | AvailabilityZoneDistribution\n | undefined,\n // SDK doc: \"The default is balanced-best-effort.\"\n { CapacityDistributionStrategy: 'balanced-best-effort' }\n );\n const deletionProtectionInput = clearOnUpdateRemoval(\n properties['DeletionProtection'] as DeletionProtection | undefined,\n previousProperties['DeletionProtection'] as DeletionProtection | undefined,\n // SDK doc: \"Default: none\" — also the flip-off value delete() uses.\n 'none'\n );\n\n await this.getClient().send(\n new UpdateAutoScalingGroupCommand({\n AutoScalingGroupName: physicalId,\n ...(properties['MinSize'] != null && { MinSize: Number(properties['MinSize']) }),\n ...(properties['MaxSize'] != null && { MaxSize: Number(properties['MaxSize']) }),\n ...(properties['DesiredCapacity'] != null && {\n DesiredCapacity: Number(properties['DesiredCapacity']),\n }),\n ...(launchTemplate && { LaunchTemplate: launchTemplate }),\n ...(properties['MixedInstancesPolicy'] !== undefined && {\n MixedInstancesPolicy: properties['MixedInstancesPolicy'] as never,\n }),\n ...(vpcZoneIdentifier !== undefined && { VPCZoneIdentifier: vpcZoneIdentifier }),\n ...(properties['AvailabilityZones'] !== undefined && {\n AvailabilityZones: properties['AvailabilityZones'] as string[],\n }),\n ...(healthCheckTypeInput !== undefined && {\n HealthCheckType: healthCheckTypeInput,\n }),\n ...(healthCheckGracePeriodInput !== undefined && {\n HealthCheckGracePeriod: healthCheckGracePeriodInput,\n }),\n ...(defaultCooldownInput !== undefined && {\n DefaultCooldown: defaultCooldownInput,\n }),\n ...(terminationPoliciesInput !== undefined && {\n TerminationPolicies: terminationPoliciesInput,\n }),\n ...(newInstancesProtectedInput !== undefined && {\n NewInstancesProtectedFromScaleIn: newInstancesProtectedInput,\n }),\n ...(capacityRebalanceInput !== undefined && {\n CapacityRebalance: capacityRebalanceInput,\n }),\n ...(properties['ServiceLinkedRoleARN'] !== undefined && {\n ServiceLinkedRoleARN: properties['ServiceLinkedRoleARN'] as string,\n }),\n ...(maxInstanceLifetimeInput !== undefined && {\n MaxInstanceLifetime: maxInstanceLifetimeInput,\n }),\n ...(properties['Context'] !== undefined && {\n Context: properties['Context'] as string,\n }),\n ...(desiredCapacityTypeInput !== undefined && {\n DesiredCapacityType: desiredCapacityTypeInput,\n }),\n ...(defaultInstanceWarmupInput !== undefined && {\n DefaultInstanceWarmup: defaultInstanceWarmupInput,\n }),\n ...(availabilityZoneDistributionInput !== undefined && {\n AvailabilityZoneDistribution: availabilityZoneDistributionInput,\n }),\n // Removal reset DEFERRED (no SDK-documented default for the\n // sub-fields) — see the comment block above.\n ...(properties['AvailabilityZoneImpairmentPolicy'] !== undefined && {\n AvailabilityZoneImpairmentPolicy: properties[\n 'AvailabilityZoneImpairmentPolicy'\n ] as never,\n }),\n ...(properties['SkipZonalShiftValidation'] !== undefined && {\n SkipZonalShiftValidation: properties['SkipZonalShiftValidation'] as boolean,\n }),\n ...(capacityReservationSpecInput !== undefined && {\n CapacityReservationSpecification: capacityReservationSpecInput,\n }),\n ...(instanceMaintenancePolicyInput !== undefined && {\n InstanceMaintenancePolicy: instanceMaintenancePolicyInput,\n }),\n ...(deletionProtectionInput !== undefined && {\n DeletionProtection: deletionProtectionInput,\n }),\n })\n );\n\n this.logger.debug(`Successfully updated AutoScalingGroup ${logicalId}`);\n\n const arn = await this.fetchArn(physicalId);\n const attributes: Record<string, unknown> = {};\n if (arn) attributes['Arn'] = arn;\n if (launchTemplate?.LaunchTemplateId) {\n attributes['LaunchTemplateID'] = launchTemplate.LaunchTemplateId;\n }\n return { physicalId, wasReplaced: false, attributes };\n } catch (error) {\n if (error instanceof ResourceUpdateNotSupportedError) throw error;\n const cause = error instanceof Error ? error : undefined;\n throw new ProvisioningError(\n `Failed to update AutoScalingGroup ${logicalId}: ${error instanceof Error ? error.message : String(error)}`,\n resourceType,\n logicalId,\n physicalId,\n cause\n );\n }\n }\n\n async delete(\n logicalId: string,\n physicalId: string,\n resourceType: string,\n _properties?: Record<string, unknown>,\n context?: DeleteContext\n ): Promise<void> {\n this.logger.debug(`Deleting AutoScalingGroup ${logicalId}: ${physicalId}`);\n\n // `--remove-protection`: clear DeletionProtection in-place before the\n // actual delete, then set ForceDelete=true so AWS terminates running\n // instances as part of the delete (matches the \"I know what I'm doing\"\n // intent of the flag). Without `removeProtection`, ForceDelete stays\n // false and AWS rejects the delete on a group with running instances\n // or DeletionProtection set, surfacing as ProvisioningError. The\n // flip-off is idempotent — AWS accepts UpdateAutoScalingGroup\n // (DeletionProtection: 'none') even when protection is already\n // disabled, so we always issue it under the flag.\n if (context?.removeProtection === true) {\n try {\n await this.getClient().send(\n new UpdateAutoScalingGroupCommand({\n AutoScalingGroupName: physicalId,\n DeletionProtection: 'none' as never,\n })\n );\n this.logger.debug(\n `Disabled DeletionProtection on AutoScalingGroup ${logicalId} before delete`\n );\n } catch (flipError) {\n // Non-fatal: log and proceed. The actual delete below surfaces\n // any real error.\n this.logger.debug(\n `Could not disable DeletionProtection on ${physicalId}: ${flipError instanceof Error ? flipError.message : String(flipError)}`\n );\n }\n\n // ASG-level DeletionProtection + ForceDelete only governs the GROUP and\n // its scale-in protection. If the group's launch template sets\n // EC2-level termination protection (DisableApiTermination), the\n // ForceDelete below still cannot terminate those instances and they\n // ORPHAN after the group is gone (issue #796). Enumerate the group's\n // current instances and flip each one's DisableApiTermination off first,\n // mirroring the EC2Provider `--remove-protection` path.\n await this.removeInstanceTerminationProtection(physicalId, logicalId);\n }\n\n try {\n await this.getClient().send(\n new DeleteAutoScalingGroupCommand({\n AutoScalingGroupName: physicalId,\n ForceDelete: context?.removeProtection === true,\n })\n );\n\n this.logger.debug(`Successfully initiated deletion of AutoScalingGroup ${logicalId}`);\n\n // Wait for the group to be fully gone. ASG delete is asynchronous —\n // returning immediately would leave dependent EC2 / IAM / SG\n // resources blocked on the lingering group.\n await this.waitForGroupDeleted(physicalId);\n } catch (error) {\n if (this.isNotFoundError(error)) {\n const clientRegion = await this.getClient().config.region();\n assertRegionMatch(\n clientRegion,\n context?.expectedRegion,\n resourceType,\n logicalId,\n physicalId\n );\n this.logger.debug(`AutoScalingGroup ${physicalId} does not exist, skipping deletion`);\n return;\n }\n const cause = error instanceof Error ? error : undefined;\n throw new ProvisioningError(\n `Failed to delete AutoScalingGroup ${logicalId}: ${error instanceof Error ? error.message : String(error)}`,\n resourceType,\n logicalId,\n physicalId,\n cause\n );\n }\n }\n\n async getAttribute(\n physicalId: string,\n _resourceType: string,\n attributeName: string\n ): Promise<unknown> {\n const group = await this.describeGroup(physicalId);\n if (!group) {\n throw new ProvisioningError(\n `AutoScalingGroup ${physicalId} not found while resolving attribute ${attributeName}`,\n 'AWS::AutoScaling::AutoScalingGroup',\n physicalId,\n physicalId\n );\n }\n switch (attributeName) {\n case 'Arn':\n case 'AutoScalingGroupARN':\n return group.AutoScalingGroupARN ?? '';\n case 'LaunchConfigurationName':\n return group.LaunchConfigurationName ?? '';\n case 'LaunchTemplateID':\n case 'LaunchTemplateId':\n return group.LaunchTemplate?.LaunchTemplateId ?? '';\n default:\n return '';\n }\n }\n\n /**\n * Read the AWS-current AutoScalingGroup configuration in CFn-property shape.\n *\n * Surfaces the user-controllable subset of `DescribeAutoScalingGroups`,\n * with always-emit placeholders on user-controllable top-level keys per\n * the cdkd PR #145 always-emit convention so that v3 `observedProperties`\n * baseline catches console-side ADDs to fields a clean deploy did not\n * template (e.g. a console-set `DeletionProtection: 'prevent-force-deletion'`\n * on a group originally created without it).\n *\n * Sub-shapes (LifecycleHookSpecificationList / TrafficSources /\n * NotificationConfigurations) are surfaced via three parallel Describe\n * calls fired alongside the primary `DescribeAutoScalingGroups`. Each is\n * best-effort: a per-call failure (e.g. permissions gap on\n * `autoscaling:DescribeLifecycleHooks`) is logged at debug and the\n * matching key falls back to its always-emit `[]` placeholder rather\n * than aborting the whole drift read.\n *\n * `MetricsCollection` is reverse-mapped from `EnabledMetrics` (already\n * present on the primary `DescribeAutoScalingGroups` response, so no\n * extra call is needed).\n *\n * Returns `undefined` when the group is gone.\n */\n async readCurrentState(\n physicalId: string,\n _logicalId: string,\n _resourceType: string\n ): Promise<Record<string, unknown> | undefined> {\n // Fire the four reads in parallel. Sub-shape failures are best-effort\n // so a single permission gap does not break the whole drift read.\n const groupPromise = (async () => {\n try {\n return await this.describeGroup(physicalId);\n } catch (err) {\n if (this.isNotFoundError(err)) return undefined;\n throw err;\n }\n })();\n\n const lifecycleHooksPromise = this.getClient()\n .send(new DescribeLifecycleHooksCommand({ AutoScalingGroupName: physicalId }))\n .then((r) => r.LifecycleHooks ?? [])\n .catch((err) => {\n this.logger.debug(\n `DescribeLifecycleHooks(${physicalId}) failed: ${err instanceof Error ? err.message : String(err)}`\n );\n return [];\n });\n\n const trafficSourcesPromise = this.getClient()\n .send(new DescribeTrafficSourcesCommand({ AutoScalingGroupName: physicalId }))\n .then((r) => r.TrafficSources ?? [])\n .catch((err) => {\n this.logger.debug(\n `DescribeTrafficSources(${physicalId}) failed: ${err instanceof Error ? err.message : String(err)}`\n );\n return [];\n });\n\n const notificationsPromise = this.getClient()\n .send(new DescribeNotificationConfigurationsCommand({ AutoScalingGroupNames: [physicalId] }))\n .then((r) => r.NotificationConfigurations ?? [])\n .catch((err) => {\n this.logger.debug(\n `DescribeNotificationConfigurations(${physicalId}) failed: ${err instanceof Error ? err.message : String(err)}`\n );\n return [];\n });\n\n const [group, lifecycleHooks, trafficSources, notifications] = await Promise.all([\n groupPromise,\n lifecycleHooksPromise,\n trafficSourcesPromise,\n notificationsPromise,\n ]);\n\n if (!group) return undefined;\n\n const result: Record<string, unknown> = {};\n if (group.AutoScalingGroupName !== undefined) {\n result['AutoScalingGroupName'] = group.AutoScalingGroupName;\n }\n if (group.LaunchTemplate) {\n const lt: Record<string, unknown> = {};\n if (group.LaunchTemplate.LaunchTemplateId !== undefined) {\n lt['LaunchTemplateId'] = group.LaunchTemplate.LaunchTemplateId;\n }\n if (group.LaunchTemplate.LaunchTemplateName !== undefined) {\n lt['LaunchTemplateName'] = group.LaunchTemplate.LaunchTemplateName;\n }\n if (group.LaunchTemplate.Version !== undefined) {\n lt['Version'] = group.LaunchTemplate.Version;\n }\n result['LaunchTemplate'] = lt;\n }\n result['MinSize'] = group.MinSize ?? 0;\n result['MaxSize'] = group.MaxSize ?? 0;\n if (group.DesiredCapacity !== undefined) result['DesiredCapacity'] = group.DesiredCapacity;\n // VPCZoneIdentifier round-trips back to the CFn list shape so the\n // comparator sees the same array the template emitted, not the\n // SDK-side comma-joined string.\n if (group.VPCZoneIdentifier !== undefined && group.VPCZoneIdentifier !== '') {\n result['VPCZoneIdentifier'] = group.VPCZoneIdentifier.split(',').map((s) => s.trim());\n } else {\n result['VPCZoneIdentifier'] = [];\n }\n result['AvailabilityZones'] = group.AvailabilityZones ?? [];\n if (group.HealthCheckType !== undefined) result['HealthCheckType'] = group.HealthCheckType;\n if (group.HealthCheckGracePeriod !== undefined) {\n result['HealthCheckGracePeriod'] = group.HealthCheckGracePeriod;\n }\n if (group.DefaultCooldown !== undefined) {\n // CFn template field is `Cooldown`; SDK / Describe response calls it\n // `DefaultCooldown`. Surface under the CFn name so the comparator\n // matches state directly.\n result['Cooldown'] = group.DefaultCooldown;\n }\n result['NewInstancesProtectedFromScaleIn'] = group.NewInstancesProtectedFromScaleIn ?? false;\n result['TerminationPolicies'] = group.TerminationPolicies ?? [];\n result['CapacityRebalance'] = group.CapacityRebalance ?? false;\n if (group.ServiceLinkedRoleARN !== undefined) {\n result['ServiceLinkedRoleARN'] = group.ServiceLinkedRoleARN;\n }\n if (group.MaxInstanceLifetime !== undefined) {\n result['MaxInstanceLifetime'] = group.MaxInstanceLifetime;\n }\n result['LoadBalancerNames'] = group.LoadBalancerNames ?? [];\n result['TargetGroupARNs'] = group.TargetGroupARNs ?? [];\n if (group.Context !== undefined) result['Context'] = group.Context;\n if (group.DesiredCapacityType !== undefined) {\n result['DesiredCapacityType'] = group.DesiredCapacityType;\n }\n if (group.DefaultInstanceWarmup !== undefined) {\n result['DefaultInstanceWarmup'] = group.DefaultInstanceWarmup;\n }\n if (group.MixedInstancesPolicy !== undefined) {\n result['MixedInstancesPolicy'] = group.MixedInstancesPolicy;\n }\n if (group.AvailabilityZoneDistribution !== undefined) {\n result['AvailabilityZoneDistribution'] = group.AvailabilityZoneDistribution;\n }\n if (group.AvailabilityZoneImpairmentPolicy !== undefined) {\n result['AvailabilityZoneImpairmentPolicy'] = group.AvailabilityZoneImpairmentPolicy;\n }\n if (group.CapacityReservationSpecification !== undefined) {\n result['CapacityReservationSpecification'] = group.CapacityReservationSpecification;\n }\n if (group.InstanceMaintenancePolicy !== undefined) {\n result['InstanceMaintenancePolicy'] = group.InstanceMaintenancePolicy;\n }\n if (group.DeletionProtection !== undefined) {\n result['DeletionProtection'] = group.DeletionProtection;\n } else {\n // AWS reports `undefined` when the group has the AWS-side default\n // (`'none'`). Always-emit placeholder so the v3 `observedProperties`\n // baseline catches a console-side flip to `prevent-force-deletion`\n // / `prevent-all-deletion`.\n result['DeletionProtection'] = 'none';\n }\n // Tags: filter aws:* prefix and normalize to CFn shape sorted by Key.\n // ASG returns Tags inside the AutoScalingGroup record (already populated\n // by DescribeAutoScalingGroups — no separate ListTagsForResource call).\n result['Tags'] = normalizeAwsTagsToCfn(group.Tags);\n\n // Sub-shapes — reverse-map AWS responses to CFn template shape and\n // always-emit `[]` placeholders so the v3 `observedProperties` baseline\n // catches console-side ADDs to a previously-empty list.\n result['MetricsCollection'] = mapEnabledMetricsToCfn(group.EnabledMetrics);\n result['LifecycleHookSpecificationList'] = mapLifecycleHooksToCfn(lifecycleHooks);\n // Strip ALL elbv2 / elb entries from TrafficSources — the canonical\n // attachment state for these types lives in TargetGroupARNs /\n // LoadBalancerNames. TrafficSources is meant for attachment types\n // without a dedicated CFn property (VPC Lattice, VPC Endpoint\n // Service). Filtering unconditionally avoids two failure modes\n // surfaced by tests/integration/drift-revert-vpc (PR #547):\n // double-attach/detach on revert, and stale TS entries from AWS's\n // eventual-consistency window after Attach/Detach surfacing as\n // false drift on the next read.\n const dedupedTrafficSources = trafficSources.filter((t) => {\n if (t.Identifier === undefined) return false;\n if (t.Type === 'elbv2' || t.Type === 'elb') return false;\n return true;\n });\n result['TrafficSources'] = mapTrafficSourcesToCfn(dedupedTrafficSources);\n result['NotificationConfigurations'] = mapNotificationsToCfn(notifications);\n\n return result;\n }\n\n // ─── Helpers ──────────────────────────────────────────────────────\n\n private buildLaunchTemplate(\n properties: Record<string, unknown>\n ): LaunchTemplateSpecification | undefined {\n const lt = properties['LaunchTemplate'] as\n | { LaunchTemplateId?: string; LaunchTemplateName?: string; Version?: string | number }\n | undefined;\n if (!lt) return undefined;\n const out: LaunchTemplateSpecification = {};\n // AWS UpdateAutoScalingGroup rejects when both LaunchTemplateId and\n // LaunchTemplateName are present in the same LaunchTemplate object\n // (\"Valid requests must contain either launchTemplateId or\n // LaunchTemplateName\"). DescribeAutoScalingGroups returns both, so\n // a straight readCurrentState → update round-trip on `drift --revert`\n // would hit this. Prefer the ID (canonical, doesn't change on LT\n // rename) and only fall back to Name when ID is absent.\n if (lt.LaunchTemplateId !== undefined) {\n out.LaunchTemplateId = lt.LaunchTemplateId;\n if (lt.LaunchTemplateName !== undefined) {\n // User templated BOTH — AWS would reject the resulting Create /\n // Update otherwise; we silently prefer the ID. Surface the\n // choice in --verbose so a user wondering why their Name didn't\n // take effect has an auditable signal.\n this.logger.debug(\n `buildLaunchTemplate: both LaunchTemplateId (${lt.LaunchTemplateId}) and LaunchTemplateName (${lt.LaunchTemplateName}) templated; dropping Name (#551)`\n );\n }\n } else if (lt.LaunchTemplateName !== undefined) {\n out.LaunchTemplateName = lt.LaunchTemplateName;\n }\n if (lt.Version !== undefined) {\n // Defensive coercion: AWS SDK `LaunchTemplateSpecification.Version`\n // is `string` and AWS rejects non-string forms with `Invalid\n // launch template version: either '$Default', '$Latest', or a\n // numeric version are allowed.`. cdkd's `IntrinsicResolver`\n // resolves `Fn::GetAtt <LaunchTemplate>.LatestVersionNumber`\n // through a per-type lookup; intermediate cases could surface\n // numeric values, so we coerce defensively.\n out.Version = String(lt.Version);\n }\n if (out.LaunchTemplateId === undefined && out.LaunchTemplateName === undefined) {\n return undefined;\n }\n return out;\n }\n\n /**\n * CFn `Tags` is `[{Key, Value, PropagateAtLaunch?}]`. AWS expects each\n * tag to also carry `ResourceId: <groupName>` and `ResourceType:\n * 'auto-scaling-group'`. We tack those on at create time so the SDK\n * input shape matches without forcing the user to template them.\n */\n private buildTags(groupName: string, properties: Record<string, unknown>): ASGTag[] {\n const raw = properties['Tags'] as\n | Array<{ Key?: string; Value?: string; PropagateAtLaunch?: boolean }>\n | undefined;\n if (!raw) return [];\n return raw\n .filter((t) => t.Key !== undefined)\n .map((t) => ({\n ResourceId: groupName,\n ResourceType: 'auto-scaling-group',\n Key: t.Key as string,\n Value: t.Value ?? '',\n PropagateAtLaunch: t.PropagateAtLaunch ?? false,\n }));\n }\n\n /**\n * CFn `VPCZoneIdentifier` is a list of subnet ids; the AWS SDK input\n * field is a comma-joined string.\n */\n private joinVpcZoneIdentifier(value: unknown): string | undefined {\n if (value === undefined || value === null) return undefined;\n if (Array.isArray(value)) {\n const cleaned = value.map((v) => String(v).trim()).filter((v) => v.length > 0);\n if (cleaned.length === 0) return undefined;\n return cleaned.join(',');\n }\n if (typeof value === 'string') return value;\n return undefined;\n }\n\n private async describeGroup(groupName: string) {\n const response = await this.getClient().send(\n new DescribeAutoScalingGroupsCommand({\n AutoScalingGroupNames: [groupName],\n })\n );\n return response.AutoScalingGroups?.[0];\n }\n\n /**\n * Flip EC2-level termination protection (`DisableApiTermination`) off on\n * every instance currently launched by the group, so the subsequent\n * `DeleteAutoScalingGroup(ForceDelete: true)` can actually terminate them\n * instead of orphaning the protected instances (issue #796). Best-effort:\n * a Describe failure or a per-instance flip failure is logged at debug and\n * does not block the delete (the modify WRITE lags the terminate READ, so\n * the shared helper swallows propagation errors the same way the EC2 path\n * does — the orphan, if any, surfaces as a leftover instance the caller\n * can clean up rather than a hard delete failure).\n */\n private async removeInstanceTerminationProtection(\n groupName: string,\n logicalId: string\n ): Promise<void> {\n let instanceIds: string[];\n try {\n const group = await this.describeGroup(groupName);\n instanceIds = (group?.Instances ?? [])\n .map((i) => i.InstanceId)\n .filter((id): id is string => typeof id === 'string' && id.length > 0);\n } catch (describeError) {\n this.logger.debug(\n `Could not enumerate instances of AutoScalingGroup ${logicalId} for termination-protection removal: ${describeError instanceof Error ? describeError.message : String(describeError)}`\n );\n return;\n }\n\n if (instanceIds.length === 0) return;\n\n this.logger.debug(\n `Disabling EC2 termination protection on ${instanceIds.length} instance(s) of AutoScalingGroup ${logicalId} before force delete`\n );\n for (const instanceId of instanceIds) {\n await disableInstanceApiTermination(this.getEc2Client(), instanceId, this.logger);\n }\n }\n\n private async fetchArn(groupName: string): Promise<string | undefined> {\n try {\n const group = await this.describeGroup(groupName);\n return group?.AutoScalingGroupARN;\n } catch (err) {\n this.logger.debug(\n `DescribeAutoScalingGroups(${groupName}) failed: ${err instanceof Error ? err.message : String(err)}`\n );\n return undefined;\n }\n }\n\n private isNotFoundError(error: unknown): boolean {\n if (!(error instanceof Error)) return false;\n const name = (error as { name?: string }).name ?? '';\n const message = error.message.toLowerCase();\n // ASG returns ValidationError with message \"AutoScalingGroup name not\n // found\" rather than a typed NotFound exception; cover both shapes.\n return (\n name === 'ValidationError' &&\n (message.includes('autoscalinggroup name not found') ||\n message.includes('not found') ||\n message.includes('does not exist'))\n );\n }\n\n private async waitForGroupDeleted(groupName: string, maxWaitMs = 900_000): Promise<void> {\n const startTime = Date.now();\n let delay = 5_000;\n\n while (Date.now() - startTime < maxWaitMs) {\n try {\n const group = await this.describeGroup(groupName);\n if (!group) return;\n } catch (error) {\n if (this.isNotFoundError(error)) return;\n throw error;\n }\n\n await this.sleep(delay);\n delay = Math.min(delay * 2, 10_000);\n }\n\n throw new Error(\n `Timed out waiting for AutoScalingGroup ${groupName} to be deleted (15 minute cap)`\n );\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n // ─── Sub-shape diff helpers ───────────────────────────────────────\n // Each helper is a no-op when before/after JSON is identical (the cheap\n // structural-equality check happens first; we only build SDK calls for\n // genuine diffs). Identity is positional within the array per CFn shape:\n // `MetricsCollection` keyed on `Granularity`, `LifecycleHookSpecification\n // List` on `LifecycleHookName`, `TrafficSources` on `Identifier`,\n // `NotificationConfigurations` on `TopicARN`.\n\n /**\n * Diff and apply changes to the ASG's `Tags` property via the\n * `CreateOrUpdateTags` / `DeleteTags` AWS APIs (#475). CFn Tags shape is\n * `[{Key, Value, PropagateAtLaunch}]`; AWS Tag input adds `ResourceId`\n * (= the ASG name) and `ResourceType: 'auto-scaling-group'`.\n *\n * Diff semantics:\n * - Removed keys → `DeleteTags`.\n * - Added keys → `CreateOrUpdateTags`.\n * - Modified value or `PropagateAtLaunch` flag → `CreateOrUpdateTags`\n * (the AWS API upserts by `(ResourceId, ResourceType, Key)` tuple, so\n * a single upsert call replaces the old value).\n *\n * No-op when before/after JSON is identical.\n */\n private async applyTagsDiff(physicalId: string, next: unknown, prev: unknown): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n type CfnTag = { Key?: string; Value?: string; PropagateAtLaunch?: boolean };\n const nextEntries = (Array.isArray(next) ? next : []) as CfnTag[];\n const prevEntries = (Array.isArray(prev) ? prev : []) as CfnTag[];\n const nextByKey = new Map<string, CfnTag>();\n for (const t of nextEntries) {\n if (t.Key) nextByKey.set(t.Key, t);\n }\n const prevByKey = new Map<string, CfnTag>();\n for (const t of prevEntries) {\n if (t.Key) prevByKey.set(t.Key, t);\n }\n // Delete keys removed from `next`.\n const toDelete: CfnTag[] = [];\n for (const [key, tag] of prevByKey) {\n if (!nextByKey.has(key)) toDelete.push(tag);\n }\n if (toDelete.length > 0) {\n await this.getClient().send(\n new DeleteTagsCommand({\n // DeleteTags is keyed only by (ResourceId, ResourceType, Key).\n // Intentionally omit `Value` / `PropagateAtLaunch`: AWS treats\n // those as additional match constraints, so passing the\n // cdkd-recorded values would silently no-op when a console-side\n // edit drifted them between deploys. cdkd owns the tag, so\n // delete-by-key matches the \"we own the resource\" intent.\n Tags: toDelete.map((t) => ({\n ResourceId: physicalId,\n ResourceType: 'auto-scaling-group',\n Key: t.Key as string,\n })),\n })\n );\n }\n // Upsert keys whose value / propagate-flag differs.\n const toUpsert: CfnTag[] = [];\n for (const [key, tag] of nextByKey) {\n const before = prevByKey.get(key);\n if (JSON.stringify(before) === JSON.stringify(tag)) continue;\n toUpsert.push(tag);\n }\n if (toUpsert.length > 0) {\n await this.getClient().send(\n new CreateOrUpdateTagsCommand({\n Tags: toUpsert.map((t) => ({\n ResourceId: physicalId,\n ResourceType: 'auto-scaling-group',\n Key: t.Key as string,\n ...(t.Value !== undefined && { Value: t.Value }),\n ...(t.PropagateAtLaunch !== undefined && {\n PropagateAtLaunch: t.PropagateAtLaunch,\n }),\n })),\n })\n );\n }\n }\n\n /**\n * Diff `LoadBalancerNames` (Classic Load Balancers) and issue\n * `AttachLoadBalancers` / `DetachLoadBalancers` for the delta (#476).\n * Names are opaque strings; AWS allows N attached LBs per ASG so this\n * helper batches every add into one Attach call and every remove into\n * one Detach call. No-op when before/after JSON is identical.\n */\n private async applyLoadBalancerNamesDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n const nextNames = (Array.isArray(next) ? next : []).filter(\n (n): n is string => typeof n === 'string'\n );\n const prevNames = (Array.isArray(prev) ? prev : []).filter(\n (n): n is string => typeof n === 'string'\n );\n const nextSet = new Set(nextNames);\n const prevSet = new Set(prevNames);\n const toAttach = nextNames.filter((n) => !prevSet.has(n));\n const toDetach = prevNames.filter((n) => !nextSet.has(n));\n if (toDetach.length > 0) {\n await this.getClient().send(\n new DetachLoadBalancersCommand({\n AutoScalingGroupName: physicalId,\n LoadBalancerNames: toDetach,\n })\n );\n }\n if (toAttach.length > 0) {\n await this.getClient().send(\n new AttachLoadBalancersCommand({\n AutoScalingGroupName: physicalId,\n LoadBalancerNames: toAttach,\n })\n );\n }\n }\n\n /**\n * Diff `TargetGroupARNs` (ALB / NLB target groups) and issue\n * `AttachLoadBalancerTargetGroups` /\n * `DetachLoadBalancerTargetGroups` for the delta (#476). Target-group\n * ARNs are opaque strings; same per-call batching pattern as\n * `applyLoadBalancerNamesDiff`. No-op when before/after JSON is\n * identical.\n */\n private async applyTargetGroupArnsDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n const nextArns = (Array.isArray(next) ? next : []).filter(\n (a): a is string => typeof a === 'string'\n );\n const prevArns = (Array.isArray(prev) ? prev : []).filter(\n (a): a is string => typeof a === 'string'\n );\n const nextSet = new Set(nextArns);\n const prevSet = new Set(prevArns);\n const toAttach = nextArns.filter((a) => !prevSet.has(a));\n const toDetach = prevArns.filter((a) => !nextSet.has(a));\n if (toDetach.length > 0) {\n await this.getClient().send(\n new DetachLoadBalancerTargetGroupsCommand({\n AutoScalingGroupName: physicalId,\n TargetGroupARNs: toDetach,\n })\n );\n }\n if (toAttach.length > 0) {\n await this.getClient().send(\n new AttachLoadBalancerTargetGroupsCommand({\n AutoScalingGroupName: physicalId,\n TargetGroupARNs: toAttach,\n })\n );\n }\n // AttachLoadBalancerTargetGroups is async — the target group starts in\n // 'Adding' state and only becomes visible in\n // DescribeAutoScalingGroups.TargetGroupARNs after AWS internal\n // propagation. A subsequent `cdkd drift` read right after the call\n // returns can otherwise see a stale snapshot and report drift\n // against the AWS-side empty list (surfaced by tests/integration/\n // drift-revert-vpc's step-6 \"drift again\" check). Bounded poll to\n // confirm the post-state matches the intent before returning so the\n // caller's next read is consistent.\n if (toDetach.length > 0 || toAttach.length > 0) {\n await this.waitForTargetGroupArnsConvergence(physicalId, new Set(nextArns));\n }\n }\n\n private static readonly TG_CONVERGENCE_TIMEOUT_MS = 30_000;\n private static readonly TG_CONVERGENCE_POLL_INTERVAL_MS = 1_000;\n\n private async waitForTargetGroupArnsConvergence(\n physicalId: string,\n expected: Set<string>\n ): Promise<void> {\n const deadlineMs = Date.now() + ASGProvider.TG_CONVERGENCE_TIMEOUT_MS;\n let lastObserved: Set<string> = new Set();\n while (Date.now() < deadlineMs) {\n let resp: DescribeAutoScalingGroupsCommandOutput | undefined;\n try {\n resp = await this.getClient().send(\n new DescribeAutoScalingGroupsCommand({ AutoScalingGroupNames: [physicalId] })\n );\n } catch (err) {\n // Transient throttle / network blip during the 30s window must\n // not throw out of applyTargetGroupArnsDiff — the Attach/Detach\n // already succeeded, and propagating would fail the whole\n // update path. Log + retry; the loop will fall through to the\n // timeout-warn path if the API is genuinely down.\n this.logger.debug(\n `applyTargetGroupArnsDiff convergence poll: transient error, retrying — ${\n err instanceof Error ? err.message : String(err)\n }`\n );\n await new Promise((r) => setTimeout(r, ASGProvider.TG_CONVERGENCE_POLL_INTERVAL_MS));\n continue;\n }\n lastObserved = new Set(resp.AutoScalingGroups?.[0]?.TargetGroupARNs ?? []);\n if (lastObserved.size === expected.size && [...expected].every((a) => lastObserved.has(a))) {\n return;\n }\n await new Promise((r) => setTimeout(r, ASGProvider.TG_CONVERGENCE_POLL_INTERVAL_MS));\n }\n // Timeout — surface as a warning rather than failure so the caller\n // still sees the SDK-side success; drift can re-report if the\n // propagation is still stuck. Includes observed vs expected so\n // post-mortem doesn't need a re-deploy.\n // Sort both sides before stringify for visual symmetry — expected\n // comes from the caller's insertion order, observed from AWS-side\n // order; eyeballing the diff in logs is easier when both are sorted.\n const expectedSorted = [...expected].sort();\n const observedSorted = [...lastObserved].sort();\n this.logger.warn(\n `applyTargetGroupArnsDiff: TG set did not converge within ${ASGProvider.TG_CONVERGENCE_TIMEOUT_MS}ms for ASG ${physicalId}. expected=${JSON.stringify(expectedSorted)} observed=${JSON.stringify(observedSorted)}`\n );\n }\n\n private async applyMetricsCollectionDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n const nextEntries = (Array.isArray(next) ? next : []) as Array<{\n Granularity?: string;\n Metrics?: string[];\n }>;\n const prevEntries = (Array.isArray(prev) ? prev : []) as Array<{\n Granularity?: string;\n Metrics?: string[];\n }>;\n const prevByGranularity = new Map<string, string[] | undefined>();\n for (const e of prevEntries) {\n if (e.Granularity) prevByGranularity.set(e.Granularity, e.Metrics);\n }\n const nextByGranularity = new Map<string, string[] | undefined>();\n for (const e of nextEntries) {\n if (e.Granularity) nextByGranularity.set(e.Granularity, e.Metrics);\n }\n // Disable removed granularities first, then issue Enable for the\n // intended state of every Granularity in `next`. AWS treats Enable as\n // additive within a Granularity, so a remove-then-add pattern works\n // even when the Metrics list shrinks.\n for (const [granularity, metrics] of prevByGranularity) {\n if (!nextByGranularity.has(granularity)) {\n await this.getClient().send(\n new DisableMetricsCollectionCommand({\n AutoScalingGroupName: physicalId,\n ...(metrics && metrics.length > 0 ? { Metrics: metrics } : {}),\n })\n );\n }\n }\n for (const [granularity, metrics] of nextByGranularity) {\n const before = prevByGranularity.get(granularity);\n if (JSON.stringify(before ?? null) === JSON.stringify(metrics ?? null)) continue;\n // If the Metrics list shrunk, disable the removed metrics first\n // (AWS Enable is additive). When `metrics` is undefined or empty,\n // AWS treats that as \"all metrics\" — disable any prior subset\n // before re-enabling the full set.\n if (before && before.length > 0) {\n const removed = metrics ? before.filter((m) => !metrics.includes(m)) : [];\n if (removed.length > 0) {\n await this.getClient().send(\n new DisableMetricsCollectionCommand({\n AutoScalingGroupName: physicalId,\n Metrics: removed,\n })\n );\n }\n }\n await this.getClient().send(\n new EnableMetricsCollectionCommand({\n AutoScalingGroupName: physicalId,\n Granularity: granularity,\n ...(metrics && metrics.length > 0 ? { Metrics: metrics } : {}),\n })\n );\n }\n }\n\n private async applyLifecycleHooksDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n const nextEntries = (Array.isArray(next) ? next : []) as Array<{\n LifecycleHookName?: string;\n LifecycleTransition?: string;\n RoleARN?: string;\n NotificationTargetARN?: string;\n NotificationMetadata?: string;\n HeartbeatTimeout?: number;\n DefaultResult?: string;\n }>;\n const prevEntries = (Array.isArray(prev) ? prev : []) as Array<{\n LifecycleHookName?: string;\n }>;\n const nextNames = new Set(\n nextEntries.map((e) => e.LifecycleHookName).filter((n): n is string => !!n)\n );\n // Delete hooks no longer in `next`.\n for (const e of prevEntries) {\n if (e.LifecycleHookName && !nextNames.has(e.LifecycleHookName)) {\n await this.getClient().send(\n new DeleteLifecycleHookCommand({\n AutoScalingGroupName: physicalId,\n LifecycleHookName: e.LifecycleHookName,\n })\n );\n }\n }\n // PutLifecycleHook is upsert — issue for every hook in `next` whose\n // shape differs from the matching `prev` entry.\n const prevByName = new Map<string, unknown>();\n for (const e of prevEntries) {\n if (e.LifecycleHookName) prevByName.set(e.LifecycleHookName, e);\n }\n for (const e of nextEntries) {\n if (!e.LifecycleHookName) continue;\n const prevHook = prevByName.get(e.LifecycleHookName);\n if (JSON.stringify(prevHook) === JSON.stringify(e)) continue;\n await this.getClient().send(\n new PutLifecycleHookCommand({\n AutoScalingGroupName: physicalId,\n LifecycleHookName: e.LifecycleHookName,\n ...(e.LifecycleTransition !== undefined && {\n LifecycleTransition: e.LifecycleTransition,\n }),\n ...(e.RoleARN !== undefined && { RoleARN: e.RoleARN }),\n ...(e.NotificationTargetARN !== undefined && {\n NotificationTargetARN: e.NotificationTargetARN,\n }),\n ...(e.NotificationMetadata !== undefined && {\n NotificationMetadata: e.NotificationMetadata,\n }),\n ...(e.HeartbeatTimeout !== undefined && { HeartbeatTimeout: e.HeartbeatTimeout }),\n ...(e.DefaultResult !== undefined && { DefaultResult: e.DefaultResult }),\n })\n );\n }\n }\n\n private async applyTrafficSourcesDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n const nextEntries = (Array.isArray(next) ? next : []) as Array<{\n Identifier?: string;\n Type?: string;\n }>;\n const prevEntries = (Array.isArray(prev) ? prev : []) as Array<{\n Identifier?: string;\n Type?: string;\n }>;\n const nextIds = new Set(nextEntries.map((e) => e.Identifier).filter((i): i is string => !!i));\n const prevIds = new Set(prevEntries.map((e) => e.Identifier).filter((i): i is string => !!i));\n const toDetach = prevEntries.filter((e) => e.Identifier && !nextIds.has(e.Identifier));\n const toAttach = nextEntries.filter((e) => e.Identifier && !prevIds.has(e.Identifier));\n if (toDetach.length > 0) {\n await this.getClient().send(\n new DetachTrafficSourcesCommand({\n AutoScalingGroupName: physicalId,\n TrafficSources: toDetach.map((e) => ({\n Identifier: e.Identifier as string,\n ...(e.Type !== undefined && { Type: e.Type }),\n })),\n })\n );\n }\n if (toAttach.length > 0) {\n await this.getClient().send(\n new AttachTrafficSourcesCommand({\n AutoScalingGroupName: physicalId,\n TrafficSources: toAttach.map((e) => ({\n Identifier: e.Identifier as string,\n ...(e.Type !== undefined && { Type: e.Type }),\n })),\n })\n );\n }\n }\n\n private async applyNotificationConfigurationsDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n // CFn `NotificationConfigurations` is an array of `{TopicARN,\n // NotificationTypes[]}`; AWS `PutNotificationConfiguration` is keyed\n // by TopicARN — one call per topic. AWS reports each notification\n // type as a separate response entry (one row per `(asgName, topicArn,\n // notificationType)` triple), but cdkd state stores the CFn shape, so\n // both sides of the diff share the per-topic key.\n const nextEntries = (Array.isArray(next) ? next : []) as Array<{\n TopicARN?: string;\n NotificationTypes?: string[];\n }>;\n const prevEntries = (Array.isArray(prev) ? prev : []) as Array<{\n TopicARN?: string;\n NotificationTypes?: string[];\n }>;\n const nextByTopic = new Map<string, string[] | undefined>();\n for (const e of nextEntries) {\n if (e.TopicARN) nextByTopic.set(e.TopicARN, e.NotificationTypes);\n }\n const prevByTopic = new Map<string, string[] | undefined>();\n for (const e of prevEntries) {\n if (e.TopicARN) prevByTopic.set(e.TopicARN, e.NotificationTypes);\n }\n for (const topic of prevByTopic.keys()) {\n if (!nextByTopic.has(topic)) {\n await this.getClient().send(\n new DeleteNotificationConfigurationCommand({\n AutoScalingGroupName: physicalId,\n TopicARN: topic,\n })\n );\n }\n }\n for (const [topic, types] of nextByTopic) {\n const before = prevByTopic.get(topic);\n if (JSON.stringify(before ?? null) === JSON.stringify(types ?? null)) continue;\n await this.getClient().send(\n new PutNotificationConfigurationCommand({\n AutoScalingGroupName: physicalId,\n TopicARN: topic,\n NotificationTypes: types ?? [],\n })\n );\n }\n }\n}\n\n// ─── File-level reverse-mappers (CFn template shape) ────────────────\n\n/**\n * Reverse-map AWS `EnabledMetrics: [{Metric, Granularity}]` (flat list,\n * one row per enabled metric) back to the CFn array shape\n * `[{Granularity, Metrics?[]}]`. Metrics with the same Granularity are\n * grouped together; the resulting Metrics list is sorted alphabetically\n * for stable positional compare in the drift comparator.\n *\n * Always returns a placeholder `[]` per the cdkd PR #145 always-emit\n * convention so a console-side EnableMetricsCollection on a previously-\n * empty group surfaces as drift on the v3 `observedProperties` baseline.\n */\nfunction mapEnabledMetricsToCfn(\n enabledMetrics:\n | Array<{ Metric?: string | undefined; Granularity?: string | undefined }>\n | undefined\n): Array<{ Granularity: string; Metrics?: string[] }> {\n if (!enabledMetrics || enabledMetrics.length === 0) return [];\n const byGranularity = new Map<string, Set<string>>();\n for (const e of enabledMetrics) {\n const g = e.Granularity;\n if (!g) continue;\n let set = byGranularity.get(g);\n if (!set) {\n set = new Set();\n byGranularity.set(g, set);\n }\n if (e.Metric) set.add(e.Metric);\n }\n const result: Array<{ Granularity: string; Metrics?: string[] }> = [];\n // Sort by Granularity for stable positional compare.\n for (const granularity of Array.from(byGranularity.keys()).sort()) {\n const metrics = Array.from(byGranularity.get(granularity) ?? []).sort();\n result.push(\n metrics.length > 0\n ? { Granularity: granularity, Metrics: metrics }\n : { Granularity: granularity }\n );\n }\n return result;\n}\n\n/**\n * Reverse-map AWS `DescribeLifecycleHooks` response to the CFn\n * `LifecycleHookSpecificationList` shape. Each hook is surfaced under the\n * exact CFn property name. AWS-side fields cdkd state never carried\n * (`AutoScalingGroupName` — duplicated on every hook by AWS,\n * `GlobalTimeout` — AWS-derived) are filtered out. Sorted by\n * LifecycleHookName for stable positional compare.\n */\nfunction mapLifecycleHooksToCfn(\n hooks: Array<{\n LifecycleHookName?: string | undefined;\n LifecycleTransition?: string | undefined;\n NotificationTargetARN?: string | undefined;\n RoleARN?: string | undefined;\n NotificationMetadata?: string | undefined;\n HeartbeatTimeout?: number | undefined;\n DefaultResult?: string | undefined;\n }>\n): Array<Record<string, unknown>> {\n if (!hooks || hooks.length === 0) return [];\n const result: Array<Record<string, unknown>> = [];\n for (const h of hooks) {\n if (!h.LifecycleHookName) continue;\n const entry: Record<string, unknown> = { LifecycleHookName: h.LifecycleHookName };\n if (h.LifecycleTransition !== undefined) entry['LifecycleTransition'] = h.LifecycleTransition;\n if (h.RoleARN !== undefined) entry['RoleARN'] = h.RoleARN;\n if (h.NotificationTargetARN !== undefined) {\n entry['NotificationTargetARN'] = h.NotificationTargetARN;\n }\n if (h.NotificationMetadata !== undefined) {\n entry['NotificationMetadata'] = h.NotificationMetadata;\n }\n if (h.HeartbeatTimeout !== undefined) entry['HeartbeatTimeout'] = h.HeartbeatTimeout;\n if (h.DefaultResult !== undefined) entry['DefaultResult'] = h.DefaultResult;\n result.push(entry);\n }\n result.sort((a, b) =>\n String(a['LifecycleHookName']).localeCompare(String(b['LifecycleHookName']))\n );\n return result;\n}\n\n/**\n * Reverse-map AWS `DescribeTrafficSources` response to the CFn\n * `TrafficSources` shape `[{Identifier, Type?}]`. AWS-side runtime fields\n * (`State`, the deprecated `TrafficSource` alias) are filtered out.\n * Sorted by Identifier for stable positional compare.\n */\nfunction mapTrafficSourcesToCfn(\n trafficSources: Array<{ Identifier?: string | undefined; Type?: string | undefined }>\n): Array<Record<string, unknown>> {\n if (!trafficSources || trafficSources.length === 0) return [];\n const result: Array<Record<string, unknown>> = [];\n for (const t of trafficSources) {\n if (!t.Identifier) continue;\n const entry: Record<string, unknown> = { Identifier: t.Identifier };\n if (t.Type !== undefined) entry['Type'] = t.Type;\n result.push(entry);\n }\n result.sort((a, b) => String(a['Identifier']).localeCompare(String(b['Identifier'])));\n return result;\n}\n\n/**\n * Reverse-map AWS `DescribeNotificationConfigurations` (a flat list, one\n * row per `(topicArn, notificationType)`) into the CFn shape\n * `[{TopicARN, NotificationTypes[]}]`. NotificationTypes are grouped per\n * TopicARN and sorted alphabetically for stable positional compare.\n */\nfunction mapNotificationsToCfn(\n configurations: Array<{ TopicARN?: string | undefined; NotificationType?: string | undefined }>\n): Array<Record<string, unknown>> {\n if (!configurations || configurations.length === 0) return [];\n const byTopic = new Map<string, Set<string>>();\n for (const c of configurations) {\n if (!c.TopicARN) continue;\n let set = byTopic.get(c.TopicARN);\n if (!set) {\n set = new Set();\n byTopic.set(c.TopicARN, set);\n }\n if (c.NotificationType) set.add(c.NotificationType);\n }\n const result: Array<Record<string, unknown>> = [];\n for (const topic of Array.from(byTopic.keys()).sort()) {\n const types = Array.from(byTopic.get(topic) ?? []).sort();\n result.push({ TopicARN: topic, NotificationTypes: types });\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,IAAa,cAAb,MAAa,YAAwC;CACnD,AAAQ;CACR,AAAQ;CACR,AAAiB,iBAAiB,QAAQ,IAAI;CAC9C,AAAQ,SAAS,UAAU,CAAC,CAAC,MAAM,aAAa;CAEhD,oCAAoB,IAAI,IAAiC,CACvD,CACE,sDACA,IAAI,IAAI;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CACH,CACF,CAAC;CAED,oCAAoB,IAAI,IAAyC,CAC/D,CACE,sDACA,IAAI,IAAoB,CACtB,CACE,2BACA,2EACF,GACA,CACE,6BACA,wFACF,CACF,CAAC,CACH,CACF,CAAC;CAED,AAAQ,YAA+B;EACrC,IAAI,CAAC,KAAK,WACR,KAAK,YAAY,IAAI,kBACnB,KAAK,iBAAiB,EAAE,QAAQ,KAAK,eAAe,IAAI,CAAC,CAC3D;EAEF,OAAO,KAAK;CACd;CAEA,AAAQ,eAA0B;EAChC,IAAI,CAAC,KAAK,WACR,KAAK,YAAY,IAAI,UAAU,KAAK,iBAAiB,EAAE,QAAQ,KAAK,eAAe,IAAI,CAAC,CAAC;EAE3F,OAAO,KAAK;CACd;CAIA,MAAM,OACJ,WACA,cACA,YAC+B;EAC/B,IAAI,iBAAiB,sCACnB,MAAM,IAAI,kBACR,8BAA8B,gBAC9B,cACA,SACF;EAGF,MAAM,YACH,WAAW,2BACZ,qBAAqB,WAAW,EAAE,WAAW,IAAI,CAAC;EAEpD,KAAK,OAAO,MAAM,6BAA6B,U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AAK,CAAC,CAAC,CAAC,CAAC,KAAK;EACxD,OAAO,KAAK;GAAE,UAAU;GAAO,mBAAmB;EAAM,CAAC;CAC3D;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"asg-provider-BQswANyu.js","names":["DeleteTagsCommand"],"sources":["../src/provisioning/providers/asg-provider.ts"],"sourcesContent":["import {\n AutoScalingClient,\n CreateAutoScalingGroupCommand,\n UpdateAutoScalingGroupCommand,\n DeleteAutoScalingGroupCommand,\n DescribeAutoScalingGroupsCommand,\n type DescribeAutoScalingGroupsCommandOutput,\n DescribeLifecycleHooksCommand,\n DescribeTrafficSourcesCommand,\n DescribeNotificationConfigurationsCommand,\n EnableMetricsCollectionCommand,\n DisableMetricsCollectionCommand,\n PutLifecycleHookCommand,\n DeleteLifecycleHookCommand,\n AttachTrafficSourcesCommand,\n DetachTrafficSourcesCommand,\n PutNotificationConfigurationCommand,\n DeleteNotificationConfigurationCommand,\n CreateOrUpdateTagsCommand,\n DeleteTagsCommand,\n AttachLoadBalancersCommand,\n DetachLoadBalancersCommand,\n AttachLoadBalancerTargetGroupsCommand,\n DetachLoadBalancerTargetGroupsCommand,\n type Tag as ASGTag,\n type LaunchTemplateSpecification,\n type AvailabilityZoneDistribution,\n type CapacityReservationSpecification,\n type DeletionProtection,\n type InstanceMaintenancePolicy,\n} from '@aws-sdk/client-auto-scaling';\nimport { EC2Client } from '@aws-sdk/client-ec2';\nimport { getLogger } from '../../utils/logger.js';\nimport { ProvisioningError, ResourceUpdateNotSupportedError } from '../../utils/error-handler.js';\nimport { assertRegionMatch, type DeleteContext } from '../region-check.js';\nimport { disableInstanceApiTermination } from '../ec2-termination-protection.js';\nimport { generateResourceName } from '../resource-name.js';\nimport { normalizeAwsTagsToCfn } from '../import-helpers.js';\nimport type {\n ResourceProvider,\n ResourceCreateResult,\n ResourceUpdateResult,\n} from '../../types/resource.js';\nimport { clearOnUpdateRemoval } from '../update-removal.js';\n\n/**\n * AWS Auto Scaling Provider\n *\n * Implements resource provisioning for `AWS::AutoScaling::AutoScalingGroup`.\n *\n * WHY a dedicated SDK provider (instead of CC API fallback):\n * 1. Owns the `--remove-protection` flip-off: ASG protection has three\n * levels (`none` / `prevent-force-deletion` / `prevent-all-deletion`)\n * and the destroy path needs to (a) clear it via `UpdateAutoScalingGroup\n * ({DeletionProtection: 'none'})` before the actual delete and (b) set\n * `ForceDelete: true` on `DeleteAutoScalingGroup` so AWS terminates any\n * running instances as part of the delete (matches the user's \"I know\n * what I'm doing\" intent).\n * 2. Faster than CC API for the common case — direct Create/Update calls\n * with no eventual-consistency polling beyond what `DescribeAutoScaling\n * Groups` already provides.\n *\n * Update has narrower coverage than create: AWS does not support modifying\n * `AutoScalingGroupName` (immutable) — that diff still surfaces\n * `ResourceUpdateNotSupportedError` so the caller can `cdkd deploy\n * --replace`. The mutable fields handled in-place via\n * `UpdateAutoScalingGroup` include MinSize / MaxSize / DesiredCapacity /\n * VPCZoneIdentifier / HealthCheckType / HealthCheckGracePeriod /\n * DefaultCooldown / Cooldown / NewInstancesProtectedFromScaleIn /\n * MaxInstanceLifetime / TerminationPolicies / CapacityRebalance /\n * ServiceLinkedRoleARN / Context / DesiredCapacityType /\n * DefaultInstanceWarmup / AvailabilityZones / AvailabilityZoneDistribution\n * / AvailabilityZoneImpairmentPolicy / SkipZonalShiftValidation /\n * CapacityReservationSpecification / InstanceMaintenancePolicy /\n * DeletionProtection / MixedInstancesPolicy / LaunchTemplate.\n *\n * `UpdateAutoScalingGroup` has merge semantics (absent input field = \"no\n * change\"), so update() routes every optional mutable field through\n * `clearOnUpdateRemoval` — a property REMOVED from the template is reset to\n * its CFn default / SDK-documented clear sentinel, matching CloudFormation\n * (issue #1160).\n *\n * Sub-shape diffs are applied via dedicated AWS APIs before the main\n * `UpdateAutoScalingGroup` call:\n * - `Tags` → `CreateOrUpdateTags` / `DeleteTags` (#475)\n * - `LoadBalancerNames` → `AttachLoadBalancers` /\n * `DetachLoadBalancers` (#476)\n * - `TargetGroupARNs` → `AttachLoadBalancerTargetGroups` /\n * `DetachLoadBalancerTargetGroups` (#476)\n * - `MetricsCollection` → `EnableMetricsCollection` /\n * `DisableMetricsCollection`\n * - `LifecycleHookSpecificationList` → per-entry `PutLifecycleHook` /\n * `DeleteLifecycleHook`\n * - `TrafficSources` → `AttachTrafficSources` /\n * `DetachTrafficSources`\n * - `NotificationConfigurations` → per-topic\n * `PutNotificationConfiguration` /\n * `DeleteNotificationConfiguration`\n *\n * Each helper is a no-op when the before/after JSON is identical.\n */\nexport class ASGProvider implements ResourceProvider {\n private asgClient?: AutoScalingClient;\n private ec2Client?: EC2Client;\n private readonly providerRegion = process.env['AWS_REGION'];\n private logger = getLogger().child('ASGProvider');\n\n handledProperties = new Map<string, ReadonlySet<string>>([\n [\n 'AWS::AutoScaling::AutoScalingGroup',\n new Set([\n 'AutoScalingGroupName',\n 'LaunchTemplate',\n 'MinSize',\n 'MaxSize',\n 'DesiredCapacity',\n 'VPCZoneIdentifier',\n 'AvailabilityZones',\n 'HealthCheckType',\n 'HealthCheckGracePeriod',\n 'Cooldown',\n 'DefaultCooldown',\n 'Tags',\n 'TerminationPolicies',\n 'NewInstancesProtectedFromScaleIn',\n 'CapacityRebalance',\n 'ServiceLinkedRoleARN',\n 'MaxInstanceLifetime',\n 'LoadBalancerNames',\n 'TargetGroupARNs',\n 'MetricsCollection',\n 'LifecycleHookSpecificationList',\n 'MixedInstancesPolicy',\n 'Context',\n 'DesiredCapacityType',\n 'DefaultInstanceWarmup',\n 'TrafficSources',\n 'NotificationConfigurations',\n 'AvailabilityZoneDistribution',\n 'AvailabilityZoneImpairmentPolicy',\n 'SkipZonalShiftValidation',\n 'CapacityReservationSpecification',\n 'InstanceMaintenancePolicy',\n 'DeletionProtection',\n ]),\n ],\n ]);\n\n unhandledByDesign = new Map<string, ReadonlyMap<string, string>>([\n [\n 'AWS::AutoScaling::AutoScalingGroup',\n new Map<string, string>([\n [\n 'LaunchConfigurationName',\n 'AWS Launch Configurations end-of-life 2024-10; use LaunchTemplate instead',\n ],\n [\n 'NotificationConfiguration',\n 'Legacy singular form; use NotificationConfigurations (plural) which cdkd already wires',\n ],\n ]),\n ],\n ]);\n\n private getClient(): AutoScalingClient {\n if (!this.asgClient) {\n this.asgClient = new AutoScalingClient(\n this.providerRegion ? { region: this.providerRegion } : {}\n );\n }\n return this.asgClient;\n }\n\n private getEc2Client(): EC2Client {\n if (!this.ec2Client) {\n this.ec2Client = new EC2Client(this.providerRegion ? { region: this.providerRegion } : {});\n }\n return this.ec2Client;\n }\n\n // ─── Dispatch ─────────────────────────────────────────────────────\n\n async create(\n logicalId: string,\n resourceType: string,\n properties: Record<string, unknown>\n ): Promise<ResourceCreateResult> {\n if (resourceType !== 'AWS::AutoScaling::AutoScalingGroup') {\n throw new ProvisioningError(\n `Unsupported resource type: ${resourceType}`,\n resourceType,\n logicalId\n );\n }\n\n const groupName =\n (properties['AutoScalingGroupName'] as string | undefined) ||\n generateResourceName(logicalId, { maxLength: 255 });\n\n this.logger.debug(`Creating AutoScalingGroup ${logicalId}: ${groupName}`);\n\n try {\n const launchTemplate = this.buildLaunchTemplate(properties);\n const tags = this.buildTags(groupName, properties);\n const vpcZoneIdentifier = this.joinVpcZoneIdentifier(properties['VPCZoneIdentifier']);\n\n const minSize = properties['MinSize'] != null ? Number(properties['MinSize']) : 0;\n const maxSize = properties['MaxSize'] != null ? Number(properties['MaxSize']) : minSize;\n\n await this.getClient().send(\n new CreateAutoScalingGroupCommand({\n AutoScalingGroupName: groupName,\n MinSize: minSize,\n MaxSize: maxSize,\n ...(properties['DesiredCapacity'] != null && {\n DesiredCapacity: Number(properties['DesiredCapacity']),\n }),\n ...(launchTemplate && { LaunchTemplate: launchTemplate }),\n ...(properties['MixedInstancesPolicy'] !== undefined && {\n MixedInstancesPolicy: properties['MixedInstancesPolicy'] as never,\n }),\n ...(vpcZoneIdentifier !== undefined && { VPCZoneIdentifier: vpcZoneIdentifier }),\n ...(properties['AvailabilityZones'] !== undefined && {\n AvailabilityZones: properties['AvailabilityZones'] as string[],\n }),\n ...(properties['HealthCheckType'] !== undefined && {\n HealthCheckType: properties['HealthCheckType'] as string,\n }),\n ...(properties['HealthCheckGracePeriod'] != null && {\n HealthCheckGracePeriod: Number(properties['HealthCheckGracePeriod']),\n }),\n ...(properties['Cooldown'] != null && {\n DefaultCooldown: Number(properties['Cooldown']),\n }),\n ...(properties['DefaultCooldown'] != null && {\n DefaultCooldown: Number(properties['DefaultCooldown']),\n }),\n ...(properties['TerminationPolicies'] !== undefined && {\n TerminationPolicies: properties['TerminationPolicies'] as string[],\n }),\n ...(properties['NewInstancesProtectedFromScaleIn'] !== undefined && {\n NewInstancesProtectedFromScaleIn: properties[\n 'NewInstancesProtectedFromScaleIn'\n ] as boolean,\n }),\n ...(properties['CapacityRebalance'] !== undefined && {\n CapacityRebalance: properties['CapacityRebalance'] as boolean,\n }),\n ...(properties['ServiceLinkedRoleARN'] !== undefined && {\n ServiceLinkedRoleARN: properties['ServiceLinkedRoleARN'] as string,\n }),\n ...(properties['MaxInstanceLifetime'] != null && {\n MaxInstanceLifetime: Number(properties['MaxInstanceLifetime']),\n }),\n ...(properties['LoadBalancerNames'] !== undefined && {\n LoadBalancerNames: properties['LoadBalancerNames'] as string[],\n }),\n ...(properties['TargetGroupARNs'] !== undefined && {\n TargetGroupARNs: properties['TargetGroupARNs'] as string[],\n }),\n ...(properties['Context'] !== undefined && {\n Context: properties['Context'] as string,\n }),\n ...(properties['DesiredCapacityType'] !== undefined && {\n DesiredCapacityType: properties['DesiredCapacityType'] as string,\n }),\n ...(properties['DefaultInstanceWarmup'] != null && {\n DefaultInstanceWarmup: Number(properties['DefaultInstanceWarmup']),\n }),\n ...(properties['LifecycleHookSpecificationList'] !== undefined && {\n LifecycleHookSpecificationList: properties['LifecycleHookSpecificationList'] as never,\n }),\n ...(properties['TrafficSources'] !== undefined && {\n TrafficSources: properties['TrafficSources'] as never,\n }),\n ...(properties['AvailabilityZoneDistribution'] !== undefined && {\n AvailabilityZoneDistribution: properties['AvailabilityZoneDistribution'] as never,\n }),\n ...(properties['AvailabilityZoneImpairmentPolicy'] !== undefined && {\n AvailabilityZoneImpairmentPolicy: properties[\n 'AvailabilityZoneImpairmentPolicy'\n ] as never,\n }),\n ...(properties['SkipZonalShiftValidation'] !== undefined && {\n SkipZonalShiftValidation: properties['SkipZonalShiftValidation'] as boolean,\n }),\n ...(properties['CapacityReservationSpecification'] !== undefined && {\n CapacityReservationSpecification: properties[\n 'CapacityReservationSpecification'\n ] as never,\n }),\n ...(properties['InstanceMaintenancePolicy'] !== undefined && {\n InstanceMaintenancePolicy: properties['InstanceMaintenancePolicy'] as never,\n }),\n ...(properties['DeletionProtection'] !== undefined && {\n DeletionProtection: properties['DeletionProtection'] as never,\n }),\n ...(tags.length > 0 && { Tags: tags }),\n })\n );\n\n this.logger.debug(`Successfully created AutoScalingGroup ${logicalId}: ${groupName}`);\n\n const arn = await this.fetchArn(groupName);\n const attributes: Record<string, unknown> = {};\n if (arn) attributes['Arn'] = arn;\n if (launchTemplate?.LaunchTemplateId) {\n attributes['LaunchTemplateID'] = launchTemplate.LaunchTemplateId;\n }\n return { physicalId: groupName, attributes };\n } catch (error) {\n const cause = error instanceof Error ? error : undefined;\n throw new ProvisioningError(\n `Failed to create AutoScalingGroup ${logicalId}: ${error instanceof Error ? error.message : String(error)}`,\n resourceType,\n logicalId,\n groupName,\n cause\n );\n }\n }\n\n async update(\n logicalId: string,\n physicalId: string,\n resourceType: string,\n properties: Record<string, unknown>,\n previousProperties: Record<string, unknown>\n ): Promise<ResourceUpdateResult> {\n if (resourceType !== 'AWS::AutoScaling::AutoScalingGroup') {\n throw new ProvisioningError(\n `Unsupported resource type: ${resourceType}`,\n resourceType,\n logicalId,\n physicalId\n );\n }\n this.logger.debug(`Updating AutoScalingGroup ${logicalId}: ${physicalId}`);\n\n // Reject diffs on fields AWS does not support modifying via\n // UpdateAutoScalingGroup. The replacement-detection layer typically\n // catches AutoScalingGroupName changes earlier; this is defense-in-\n // depth + the only place to surface the equivalent error for\n // sub-resource fields the caller may reasonably expect to round-trip.\n const stringEq = (a: unknown, b: unknown): boolean => JSON.stringify(a) === JSON.stringify(b);\n if (!stringEq(properties['AutoScalingGroupName'], previousProperties['AutoScalingGroupName'])) {\n throw new ResourceUpdateNotSupportedError(\n resourceType,\n logicalId,\n 'AutoScalingGroupName is immutable on AWS — UpdateAutoScalingGroup does not accept a new name; the name is fixed at creation. Use cdkd deploy --replace to replace the group.'\n );\n }\n try {\n // Sub-shape diffs are applied via separate per-shape SDK calls\n // BEFORE the main UpdateAutoScalingGroup. AWS does not expose these\n // fields on UpdateAutoScalingGroup, so each one rides its own\n // dedicated API. Each per-shape helper is a no-op when the\n // before/after JSON is identical.\n await this.applyTagsDiff(physicalId, properties['Tags'], previousProperties['Tags']);\n await this.applyLoadBalancerNamesDiff(\n physicalId,\n properties['LoadBalancerNames'],\n previousProperties['LoadBalancerNames']\n );\n await this.applyTargetGroupArnsDiff(\n physicalId,\n properties['TargetGroupARNs'],\n previousProperties['TargetGroupARNs']\n );\n await this.applyMetricsCollectionDiff(\n physicalId,\n properties['MetricsCollection'],\n previousProperties['MetricsCollection']\n );\n await this.applyLifecycleHooksDiff(\n physicalId,\n properties['LifecycleHookSpecificationList'],\n previousProperties['LifecycleHookSpecificationList']\n );\n await this.applyTrafficSourcesDiff(\n physicalId,\n properties['TrafficSources'],\n previousProperties['TrafficSources']\n );\n await this.applyNotificationConfigurationsDiff(\n physicalId,\n properties['NotificationConfigurations'],\n previousProperties['NotificationConfigurations']\n );\n\n const launchTemplate = this.buildLaunchTemplate(properties);\n const vpcZoneIdentifier = this.joinVpcZoneIdentifier(properties['VPCZoneIdentifier']);\n\n // issue #1160: `UpdateAutoScalingGroup` has merge semantics — an absent\n // input field means \"no change\" — while CloudFormation resets a property\n // REMOVED from the template to its default. Resolve every optional\n // mutable field through `clearOnUpdateRemoval` so a removal sends the\n // explicit CFn default (or the SDK-documented clear sentinel) instead of\n // silently keeping the old live value. Each reset value's doc basis is\n // noted inline (models_0.d.ts = the AWS SDK command/model doc).\n //\n // Deliberately NOT reset on removal:\n // - DesiredCapacity: CFn leaves current capacity unmanaged when the\n // property is absent (scaling policies own it) — leaving it\n // unchanged IS the CFn-parity behavior.\n // - MinSize / MaxSize: required properties, never removable.\n // - LaunchTemplate vs MixedInstancesPolicy, VPCZoneIdentifier vs\n // AvailabilityZones: mutually-exclusive pairs — a \"removal\" is\n // really a switch to the other member, which the API applies by\n // presence; pure removal of both is an invalid template.\n // - ServiceLinkedRoleARN: no documented clear sentinel; the default\n // is an account-specific service-linked-role ARN — leave unchanged.\n // - Context: SDK doc says \"Reserved.\" — leave unchanged.\n // - SkipZonalShiftValidation: transient per-request validation flag,\n // not persisted group config — nothing to reset.\n // - AvailabilityZoneImpairmentPolicy: DEFERRED — the SDK model\n // documents no default for `ImpairedZoneHealthCheckBehavior` (and\n // none for `ZonalShiftEnabled`), so a reset shape cannot be derived\n // without guessing; removal currently keeps the live value.\n //\n // Sub-field removal inside a KEPT config object (issue #1225 — the\n // #1160 bug class one level down) is deliberately passed through\n // verbatim here:\n // - InstanceMaintenancePolicy: a kept-but-partial object (one of the\n // two percentages dropped) is REJECTED by AWS — the SDK doc requires\n // \"Both MinHealthyPercentage and MaxHealthyPercentage must be\n // specified\". CloudFormation submits the same partial object, so the\n // loud failure IS the CFn-parity behavior; there is no silent drop\n // to normalize away.\n // - CapacityReservationSpecification: whether AWS keeps or clears a\n // previously-set CapacityReservationTarget when only the preference\n // is re-sent is UNPROBED (a live probe needs a billed Capacity\n // Reservation); the kept-partial object passes through unchanged.\n // - AvailabilityZoneDistribution: single sub-field — no partial shape\n // exists.\n const healthCheckTypeInput = clearOnUpdateRemoval(\n properties['HealthCheckType'] as string | undefined,\n previousProperties['HealthCheckType'] as string | undefined,\n // SDK doc: \"EC2 is the default health check and cannot be disabled.\n // ... Only specify EC2 if you must clear a value that was previously\n // set.\"\n 'EC2'\n );\n const healthCheckGracePeriodInput = clearOnUpdateRemoval(\n properties['HealthCheckGracePeriod'] != null\n ? Number(properties['HealthCheckGracePeriod'])\n : undefined,\n previousProperties['HealthCheckGracePeriod'] != null\n ? Number(previousProperties['HealthCheckGracePeriod'])\n : undefined,\n // CFn default: 0 seconds.\n 0\n );\n // CFn's template key is `Cooldown`; cdkd also accepts the SDK-side\n // spelling `DefaultCooldown`. Treat the two keys as ONE logical field on\n // both sides so switching spellings is never misread as a removal.\n const cooldownRaw = properties['Cooldown'] ?? properties['DefaultCooldown'];\n const prevCooldownRaw =\n previousProperties['Cooldown'] ?? previousProperties['DefaultCooldown'];\n const defaultCooldownInput = clearOnUpdateRemoval(\n cooldownRaw != null ? Number(cooldownRaw) : undefined,\n prevCooldownRaw != null ? Number(prevCooldownRaw) : undefined,\n // CFn default: 300 seconds.\n 300\n );\n const terminationPoliciesInput = clearOnUpdateRemoval(\n properties['TerminationPolicies'] as string[] | undefined,\n previousProperties['TerminationPolicies'] as string[] | undefined,\n // CFn/API default termination policy.\n ['Default']\n );\n const newInstancesProtectedInput = clearOnUpdateRemoval(\n properties['NewInstancesProtectedFromScaleIn'] as boolean | undefined,\n previousProperties['NewInstancesProtectedFromScaleIn'] as boolean | undefined,\n false\n );\n const capacityRebalanceInput = clearOnUpdateRemoval(\n properties['CapacityRebalance'] as boolean | undefined,\n previousProperties['CapacityRebalance'] as boolean | undefined,\n false\n );\n const maxInstanceLifetimeInput = clearOnUpdateRemoval(\n properties['MaxInstanceLifetime'] != null\n ? Number(properties['MaxInstanceLifetime'])\n : undefined,\n previousProperties['MaxInstanceLifetime'] != null\n ? Number(previousProperties['MaxInstanceLifetime'])\n : undefined,\n // SDK doc: \"To clear a previously set value, specify a new value of 0.\"\n 0\n );\n const desiredCapacityTypeInput = clearOnUpdateRemoval(\n properties['DesiredCapacityType'] as string | undefined,\n previousProperties['DesiredCapacityType'] as string | undefined,\n // SDK doc: \"By default, Amazon EC2 Auto Scaling specifies units\".\n 'units'\n );\n const defaultInstanceWarmupInput = clearOnUpdateRemoval(\n properties['DefaultInstanceWarmup'] != null\n ? Number(properties['DefaultInstanceWarmup'])\n : undefined,\n previousProperties['DefaultInstanceWarmup'] != null\n ? Number(previousProperties['DefaultInstanceWarmup'])\n : undefined,\n // SDK doc: \"To remove a value that you previously set, include the\n // property but specify -1 for the value.\"\n -1\n );\n const instanceMaintenancePolicyInput = clearOnUpdateRemoval(\n properties['InstanceMaintenancePolicy'] as InstanceMaintenancePolicy | undefined,\n previousProperties['InstanceMaintenancePolicy'] as InstanceMaintenancePolicy | undefined,\n // SDK doc (both sub-fields): \"To clear a previously set value,\n // specify a value of -1.\"\n { MinHealthyPercentage: -1, MaxHealthyPercentage: -1 }\n );\n const capacityReservationSpecInput = clearOnUpdateRemoval(\n properties['CapacityReservationSpecification'] as\n | CapacityReservationSpecification\n | undefined,\n previousProperties['CapacityReservationSpecification'] as\n | CapacityReservationSpecification\n | undefined,\n // SDK doc: \"default - Auto Scaling uses the Capacity Reservation\n // preference from your launch template or an open Capacity\n // Reservation.\" — the behavior of a group that never set the field.\n { CapacityReservationPreference: 'default' }\n );\n const availabilityZoneDistributionInput = clearOnUpdateRemoval(\n properties['AvailabilityZoneDistribution'] as AvailabilityZoneDistribution | undefined,\n previousProperties['AvailabilityZoneDistribution'] as\n | AvailabilityZoneDistribution\n | undefined,\n // SDK doc: \"The default is balanced-best-effort.\"\n { CapacityDistributionStrategy: 'balanced-best-effort' }\n );\n const deletionProtectionInput = clearOnUpdateRemoval(\n properties['DeletionProtection'] as DeletionProtection | undefined,\n previousProperties['DeletionProtection'] as DeletionProtection | undefined,\n // SDK doc: \"Default: none\" — also the flip-off value delete() uses.\n 'none'\n );\n\n await this.getClient().send(\n new UpdateAutoScalingGroupCommand({\n AutoScalingGroupName: physicalId,\n ...(properties['MinSize'] != null && { MinSize: Number(properties['MinSize']) }),\n ...(properties['MaxSize'] != null && { MaxSize: Number(properties['MaxSize']) }),\n ...(properties['DesiredCapacity'] != null && {\n DesiredCapacity: Number(properties['DesiredCapacity']),\n }),\n ...(launchTemplate && { LaunchTemplate: launchTemplate }),\n ...(properties['MixedInstancesPolicy'] !== undefined && {\n MixedInstancesPolicy: properties['MixedInstancesPolicy'] as never,\n }),\n ...(vpcZoneIdentifier !== undefined && { VPCZoneIdentifier: vpcZoneIdentifier }),\n ...(properties['AvailabilityZones'] !== undefined && {\n AvailabilityZones: properties['AvailabilityZones'] as string[],\n }),\n ...(healthCheckTypeInput !== undefined && {\n HealthCheckType: healthCheckTypeInput,\n }),\n ...(healthCheckGracePeriodInput !== undefined && {\n HealthCheckGracePeriod: healthCheckGracePeriodInput,\n }),\n ...(defaultCooldownInput !== undefined && {\n DefaultCooldown: defaultCooldownInput,\n }),\n ...(terminationPoliciesInput !== undefined && {\n TerminationPolicies: terminationPoliciesInput,\n }),\n ...(newInstancesProtectedInput !== undefined && {\n NewInstancesProtectedFromScaleIn: newInstancesProtectedInput,\n }),\n ...(capacityRebalanceInput !== undefined && {\n CapacityRebalance: capacityRebalanceInput,\n }),\n ...(properties['ServiceLinkedRoleARN'] !== undefined && {\n ServiceLinkedRoleARN: properties['ServiceLinkedRoleARN'] as string,\n }),\n ...(maxInstanceLifetimeInput !== undefined && {\n MaxInstanceLifetime: maxInstanceLifetimeInput,\n }),\n ...(properties['Context'] !== undefined && {\n Context: properties['Context'] as string,\n }),\n ...(desiredCapacityTypeInput !== undefined && {\n DesiredCapacityType: desiredCapacityTypeInput,\n }),\n ...(defaultInstanceWarmupInput !== undefined && {\n DefaultInstanceWarmup: defaultInstanceWarmupInput,\n }),\n ...(availabilityZoneDistributionInput !== undefined && {\n AvailabilityZoneDistribution: availabilityZoneDistributionInput,\n }),\n // Removal reset DEFERRED (no SDK-documented default for the\n // sub-fields) — see the comment block above.\n ...(properties['AvailabilityZoneImpairmentPolicy'] !== undefined && {\n AvailabilityZoneImpairmentPolicy: properties[\n 'AvailabilityZoneImpairmentPolicy'\n ] as never,\n }),\n ...(properties['SkipZonalShiftValidation'] !== undefined && {\n SkipZonalShiftValidation: properties['SkipZonalShiftValidation'] as boolean,\n }),\n ...(capacityReservationSpecInput !== undefined && {\n CapacityReservationSpecification: capacityReservationSpecInput,\n }),\n ...(instanceMaintenancePolicyInput !== undefined && {\n InstanceMaintenancePolicy: instanceMaintenancePolicyInput,\n }),\n ...(deletionProtectionInput !== undefined && {\n DeletionProtection: deletionProtectionInput,\n }),\n })\n );\n\n this.logger.debug(`Successfully updated AutoScalingGroup ${logicalId}`);\n\n const arn = await this.fetchArn(physicalId);\n const attributes: Record<string, unknown> = {};\n if (arn) attributes['Arn'] = arn;\n if (launchTemplate?.LaunchTemplateId) {\n attributes['LaunchTemplateID'] = launchTemplate.LaunchTemplateId;\n }\n return { physicalId, wasReplaced: false, attributes };\n } catch (error) {\n if (error instanceof ResourceUpdateNotSupportedError) throw error;\n const cause = error instanceof Error ? error : undefined;\n throw new ProvisioningError(\n `Failed to update AutoScalingGroup ${logicalId}: ${error instanceof Error ? error.message : String(error)}`,\n resourceType,\n logicalId,\n physicalId,\n cause\n );\n }\n }\n\n async delete(\n logicalId: string,\n physicalId: string,\n resourceType: string,\n _properties?: Record<string, unknown>,\n context?: DeleteContext\n ): Promise<void> {\n this.logger.debug(`Deleting AutoScalingGroup ${logicalId}: ${physicalId}`);\n\n // `--remove-protection`: clear DeletionProtection in-place before the\n // actual delete, then set ForceDelete=true so AWS terminates running\n // instances as part of the delete (matches the \"I know what I'm doing\"\n // intent of the flag). Without `removeProtection`, ForceDelete stays\n // false and AWS rejects the delete on a group with running instances\n // or DeletionProtection set, surfacing as ProvisioningError. The\n // flip-off is idempotent — AWS accepts UpdateAutoScalingGroup\n // (DeletionProtection: 'none') even when protection is already\n // disabled, so we always issue it under the flag.\n if (context?.removeProtection === true) {\n try {\n await this.getClient().send(\n new UpdateAutoScalingGroupCommand({\n AutoScalingGroupName: physicalId,\n DeletionProtection: 'none' as never,\n })\n );\n this.logger.debug(\n `Disabled DeletionProtection on AutoScalingGroup ${logicalId} before delete`\n );\n } catch (flipError) {\n // Non-fatal: log and proceed. The actual delete below surfaces\n // any real error.\n this.logger.debug(\n `Could not disable DeletionProtection on ${physicalId}: ${flipError instanceof Error ? flipError.message : String(flipError)}`\n );\n }\n\n // ASG-level DeletionProtection + ForceDelete only governs the GROUP and\n // its scale-in protection. If the group's launch template sets\n // EC2-level termination protection (DisableApiTermination), the\n // ForceDelete below still cannot terminate those instances and they\n // ORPHAN after the group is gone (issue #796). Enumerate the group's\n // current instances and flip each one's DisableApiTermination off first,\n // mirroring the EC2Provider `--remove-protection` path.\n await this.removeInstanceTerminationProtection(physicalId, logicalId);\n }\n\n try {\n await this.getClient().send(\n new DeleteAutoScalingGroupCommand({\n AutoScalingGroupName: physicalId,\n ForceDelete: context?.removeProtection === true,\n })\n );\n\n this.logger.debug(`Successfully initiated deletion of AutoScalingGroup ${logicalId}`);\n\n // Wait for the group to be fully gone. ASG delete is asynchronous —\n // returning immediately would leave dependent EC2 / IAM / SG\n // resources blocked on the lingering group.\n await this.waitForGroupDeleted(physicalId);\n } catch (error) {\n if (this.isNotFoundError(error)) {\n const clientRegion = await this.getClient().config.region();\n assertRegionMatch(\n clientRegion,\n context?.expectedRegion,\n resourceType,\n logicalId,\n physicalId\n );\n this.logger.debug(`AutoScalingGroup ${physicalId} does not exist, skipping deletion`);\n return;\n }\n const cause = error instanceof Error ? error : undefined;\n throw new ProvisioningError(\n `Failed to delete AutoScalingGroup ${logicalId}: ${error instanceof Error ? error.message : String(error)}`,\n resourceType,\n logicalId,\n physicalId,\n cause\n );\n }\n }\n\n async getAttribute(\n physicalId: string,\n _resourceType: string,\n attributeName: string\n ): Promise<unknown> {\n const group = await this.describeGroup(physicalId);\n if (!group) {\n throw new ProvisioningError(\n `AutoScalingGroup ${physicalId} not found while resolving attribute ${attributeName}`,\n 'AWS::AutoScaling::AutoScalingGroup',\n physicalId,\n physicalId\n );\n }\n switch (attributeName) {\n case 'Arn':\n case 'AutoScalingGroupARN':\n return group.AutoScalingGroupARN ?? '';\n case 'LaunchConfigurationName':\n return group.LaunchConfigurationName ?? '';\n case 'LaunchTemplateID':\n case 'LaunchTemplateId':\n return group.LaunchTemplate?.LaunchTemplateId ?? '';\n default:\n return '';\n }\n }\n\n /**\n * Read the AWS-current AutoScalingGroup configuration in CFn-property shape.\n *\n * Surfaces the user-controllable subset of `DescribeAutoScalingGroups`,\n * with always-emit placeholders on user-controllable top-level keys per\n * the cdkd PR #145 always-emit convention so that v3 `observedProperties`\n * baseline catches console-side ADDs to fields a clean deploy did not\n * template (e.g. a console-set `DeletionProtection: 'prevent-force-deletion'`\n * on a group originally created without it).\n *\n * Sub-shapes (LifecycleHookSpecificationList / TrafficSources /\n * NotificationConfigurations) are surfaced via three parallel Describe\n * calls fired alongside the primary `DescribeAutoScalingGroups`. Each is\n * best-effort: a per-call failure (e.g. permissions gap on\n * `autoscaling:DescribeLifecycleHooks`) is logged at debug and the\n * matching key falls back to its always-emit `[]` placeholder rather\n * than aborting the whole drift read.\n *\n * `MetricsCollection` is reverse-mapped from `EnabledMetrics` (already\n * present on the primary `DescribeAutoScalingGroups` response, so no\n * extra call is needed).\n *\n * Returns `undefined` when the group is gone.\n */\n async readCurrentState(\n physicalId: string,\n _logicalId: string,\n _resourceType: string\n ): Promise<Record<string, unknown> | undefined> {\n // Fire the four reads in parallel. Sub-shape failures are best-effort\n // so a single permission gap does not break the whole drift read.\n const groupPromise = (async () => {\n try {\n return await this.describeGroup(physicalId);\n } catch (err) {\n if (this.isNotFoundError(err)) return undefined;\n throw err;\n }\n })();\n\n const lifecycleHooksPromise = this.getClient()\n .send(new DescribeLifecycleHooksCommand({ AutoScalingGroupName: physicalId }))\n .then((r) => r.LifecycleHooks ?? [])\n .catch((err) => {\n this.logger.debug(\n `DescribeLifecycleHooks(${physicalId}) failed: ${err instanceof Error ? err.message : String(err)}`\n );\n return [];\n });\n\n const trafficSourcesPromise = this.getClient()\n .send(new DescribeTrafficSourcesCommand({ AutoScalingGroupName: physicalId }))\n .then((r) => r.TrafficSources ?? [])\n .catch((err) => {\n this.logger.debug(\n `DescribeTrafficSources(${physicalId}) failed: ${err instanceof Error ? err.message : String(err)}`\n );\n return [];\n });\n\n const notificationsPromise = this.getClient()\n .send(new DescribeNotificationConfigurationsCommand({ AutoScalingGroupNames: [physicalId] }))\n .then((r) => r.NotificationConfigurations ?? [])\n .catch((err) => {\n this.logger.debug(\n `DescribeNotificationConfigurations(${physicalId}) failed: ${err instanceof Error ? err.message : String(err)}`\n );\n return [];\n });\n\n const [group, lifecycleHooks, trafficSources, notifications] = await Promise.all([\n groupPromise,\n lifecycleHooksPromise,\n trafficSourcesPromise,\n notificationsPromise,\n ]);\n\n if (!group) return undefined;\n\n const result: Record<string, unknown> = {};\n if (group.AutoScalingGroupName !== undefined) {\n result['AutoScalingGroupName'] = group.AutoScalingGroupName;\n }\n if (group.LaunchTemplate) {\n const lt: Record<string, unknown> = {};\n if (group.LaunchTemplate.LaunchTemplateId !== undefined) {\n lt['LaunchTemplateId'] = group.LaunchTemplate.LaunchTemplateId;\n }\n if (group.LaunchTemplate.LaunchTemplateName !== undefined) {\n lt['LaunchTemplateName'] = group.LaunchTemplate.LaunchTemplateName;\n }\n if (group.LaunchTemplate.Version !== undefined) {\n lt['Version'] = group.LaunchTemplate.Version;\n }\n result['LaunchTemplate'] = lt;\n }\n result['MinSize'] = group.MinSize ?? 0;\n result['MaxSize'] = group.MaxSize ?? 0;\n if (group.DesiredCapacity !== undefined) result['DesiredCapacity'] = group.DesiredCapacity;\n // VPCZoneIdentifier round-trips back to the CFn list shape so the\n // comparator sees the same array the template emitted, not the\n // SDK-side comma-joined string.\n if (group.VPCZoneIdentifier !== undefined && group.VPCZoneIdentifier !== '') {\n result['VPCZoneIdentifier'] = group.VPCZoneIdentifier.split(',').map((s) => s.trim());\n } else {\n result['VPCZoneIdentifier'] = [];\n }\n result['AvailabilityZones'] = group.AvailabilityZones ?? [];\n if (group.HealthCheckType !== undefined) result['HealthCheckType'] = group.HealthCheckType;\n if (group.HealthCheckGracePeriod !== undefined) {\n result['HealthCheckGracePeriod'] = group.HealthCheckGracePeriod;\n }\n if (group.DefaultCooldown !== undefined) {\n // CFn template field is `Cooldown`; SDK / Describe response calls it\n // `DefaultCooldown`. Surface under the CFn name so the comparator\n // matches state directly.\n result['Cooldown'] = group.DefaultCooldown;\n }\n result['NewInstancesProtectedFromScaleIn'] = group.NewInstancesProtectedFromScaleIn ?? false;\n result['TerminationPolicies'] = group.TerminationPolicies ?? [];\n result['CapacityRebalance'] = group.CapacityRebalance ?? false;\n if (group.ServiceLinkedRoleARN !== undefined) {\n result['ServiceLinkedRoleARN'] = group.ServiceLinkedRoleARN;\n }\n if (group.MaxInstanceLifetime !== undefined) {\n result['MaxInstanceLifetime'] = group.MaxInstanceLifetime;\n }\n result['LoadBalancerNames'] = group.LoadBalancerNames ?? [];\n result['TargetGroupARNs'] = group.TargetGroupARNs ?? [];\n if (group.Context !== undefined) result['Context'] = group.Context;\n if (group.DesiredCapacityType !== undefined) {\n result['DesiredCapacityType'] = group.DesiredCapacityType;\n }\n if (group.DefaultInstanceWarmup !== undefined) {\n result['DefaultInstanceWarmup'] = group.DefaultInstanceWarmup;\n }\n if (group.MixedInstancesPolicy !== undefined) {\n result['MixedInstancesPolicy'] = group.MixedInstancesPolicy;\n }\n if (group.AvailabilityZoneDistribution !== undefined) {\n result['AvailabilityZoneDistribution'] = group.AvailabilityZoneDistribution;\n }\n if (group.AvailabilityZoneImpairmentPolicy !== undefined) {\n result['AvailabilityZoneImpairmentPolicy'] = group.AvailabilityZoneImpairmentPolicy;\n }\n if (group.CapacityReservationSpecification !== undefined) {\n result['CapacityReservationSpecification'] = group.CapacityReservationSpecification;\n }\n if (group.InstanceMaintenancePolicy !== undefined) {\n result['InstanceMaintenancePolicy'] = group.InstanceMaintenancePolicy;\n }\n if (group.DeletionProtection !== undefined) {\n result['DeletionProtection'] = group.DeletionProtection;\n } else {\n // AWS reports `undefined` when the group has the AWS-side default\n // (`'none'`). Always-emit placeholder so the v3 `observedProperties`\n // baseline catches a console-side flip to `prevent-force-deletion`\n // / `prevent-all-deletion`.\n result['DeletionProtection'] = 'none';\n }\n // Tags: filter aws:* prefix and normalize to CFn shape sorted by Key.\n // ASG returns Tags inside the AutoScalingGroup record (already populated\n // by DescribeAutoScalingGroups — no separate ListTagsForResource call).\n result['Tags'] = normalizeAwsTagsToCfn(group.Tags);\n\n // Sub-shapes — reverse-map AWS responses to CFn template shape and\n // always-emit `[]` placeholders so the v3 `observedProperties` baseline\n // catches console-side ADDs to a previously-empty list.\n result['MetricsCollection'] = mapEnabledMetricsToCfn(group.EnabledMetrics);\n result['LifecycleHookSpecificationList'] = mapLifecycleHooksToCfn(lifecycleHooks);\n // Strip ALL elbv2 / elb entries from TrafficSources — the canonical\n // attachment state for these types lives in TargetGroupARNs /\n // LoadBalancerNames. TrafficSources is meant for attachment types\n // without a dedicated CFn property (VPC Lattice, VPC Endpoint\n // Service). Filtering unconditionally avoids two failure modes\n // surfaced by tests/integration/drift-revert-vpc (PR #547):\n // double-attach/detach on revert, and stale TS entries from AWS's\n // eventual-consistency window after Attach/Detach surfacing as\n // false drift on the next read.\n const dedupedTrafficSources = trafficSources.filter((t) => {\n if (t.Identifier === undefined) return false;\n if (t.Type === 'elbv2' || t.Type === 'elb') return false;\n return true;\n });\n result['TrafficSources'] = mapTrafficSourcesToCfn(dedupedTrafficSources);\n result['NotificationConfigurations'] = mapNotificationsToCfn(notifications);\n\n return result;\n }\n\n // ─── Helpers ──────────────────────────────────────────────────────\n\n private buildLaunchTemplate(\n properties: Record<string, unknown>\n ): LaunchTemplateSpecification | undefined {\n const lt = properties['LaunchTemplate'] as\n | { LaunchTemplateId?: string; LaunchTemplateName?: string; Version?: string | number }\n | undefined;\n if (!lt) return undefined;\n const out: LaunchTemplateSpecification = {};\n // AWS UpdateAutoScalingGroup rejects when both LaunchTemplateId and\n // LaunchTemplateName are present in the same LaunchTemplate object\n // (\"Valid requests must contain either launchTemplateId or\n // LaunchTemplateName\"). DescribeAutoScalingGroups returns both, so\n // a straight readCurrentState → update round-trip on `drift --revert`\n // would hit this. Prefer the ID (canonical, doesn't change on LT\n // rename) and only fall back to Name when ID is absent.\n if (lt.LaunchTemplateId !== undefined) {\n out.LaunchTemplateId = lt.LaunchTemplateId;\n if (lt.LaunchTemplateName !== undefined) {\n // User templated BOTH — AWS would reject the resulting Create /\n // Update otherwise; we silently prefer the ID. Surface the\n // choice in --verbose so a user wondering why their Name didn't\n // take effect has an auditable signal.\n this.logger.debug(\n `buildLaunchTemplate: both LaunchTemplateId (${lt.LaunchTemplateId}) and LaunchTemplateName (${lt.LaunchTemplateName}) templated; dropping Name (#551)`\n );\n }\n } else if (lt.LaunchTemplateName !== undefined) {\n out.LaunchTemplateName = lt.LaunchTemplateName;\n }\n if (lt.Version !== undefined) {\n // Defensive coercion: AWS SDK `LaunchTemplateSpecification.Version`\n // is `string` and AWS rejects non-string forms with `Invalid\n // launch template version: either '$Default', '$Latest', or a\n // numeric version are allowed.`. cdkd's `IntrinsicResolver`\n // resolves `Fn::GetAtt <LaunchTemplate>.LatestVersionNumber`\n // through a per-type lookup; intermediate cases could surface\n // numeric values, so we coerce defensively.\n out.Version = String(lt.Version);\n }\n if (out.LaunchTemplateId === undefined && out.LaunchTemplateName === undefined) {\n return undefined;\n }\n return out;\n }\n\n /**\n * CFn `Tags` is `[{Key, Value, PropagateAtLaunch?}]`. AWS expects each\n * tag to also carry `ResourceId: <groupName>` and `ResourceType:\n * 'auto-scaling-group'`. We tack those on at create time so the SDK\n * input shape matches without forcing the user to template them.\n */\n private buildTags(groupName: string, properties: Record<string, unknown>): ASGTag[] {\n const raw = properties['Tags'] as\n | Array<{ Key?: string; Value?: string; PropagateAtLaunch?: boolean }>\n | undefined;\n if (!raw) return [];\n return raw\n .filter((t) => t.Key !== undefined)\n .map((t) => ({\n ResourceId: groupName,\n ResourceType: 'auto-scaling-group',\n Key: t.Key as string,\n Value: t.Value ?? '',\n PropagateAtLaunch: t.PropagateAtLaunch ?? false,\n }));\n }\n\n /**\n * CFn `VPCZoneIdentifier` is a list of subnet ids; the AWS SDK input\n * field is a comma-joined string.\n */\n private joinVpcZoneIdentifier(value: unknown): string | undefined {\n if (value === undefined || value === null) return undefined;\n if (Array.isArray(value)) {\n const cleaned = value.map((v) => String(v).trim()).filter((v) => v.length > 0);\n if (cleaned.length === 0) return undefined;\n return cleaned.join(',');\n }\n if (typeof value === 'string') return value;\n return undefined;\n }\n\n private async describeGroup(groupName: string) {\n const response = await this.getClient().send(\n new DescribeAutoScalingGroupsCommand({\n AutoScalingGroupNames: [groupName],\n })\n );\n return response.AutoScalingGroups?.[0];\n }\n\n /**\n * Flip EC2-level termination protection (`DisableApiTermination`) off on\n * every instance currently launched by the group, so the subsequent\n * `DeleteAutoScalingGroup(ForceDelete: true)` can actually terminate them\n * instead of orphaning the protected instances (issue #796). Best-effort:\n * a Describe failure or a per-instance flip failure is logged at debug and\n * does not block the delete (the modify WRITE lags the terminate READ, so\n * the shared helper swallows propagation errors the same way the EC2 path\n * does — the orphan, if any, surfaces as a leftover instance the caller\n * can clean up rather than a hard delete failure).\n */\n private async removeInstanceTerminationProtection(\n groupName: string,\n logicalId: string\n ): Promise<void> {\n let instanceIds: string[];\n try {\n const group = await this.describeGroup(groupName);\n instanceIds = (group?.Instances ?? [])\n .map((i) => i.InstanceId)\n .filter((id): id is string => typeof id === 'string' && id.length > 0);\n } catch (describeError) {\n this.logger.debug(\n `Could not enumerate instances of AutoScalingGroup ${logicalId} for termination-protection removal: ${describeError instanceof Error ? describeError.message : String(describeError)}`\n );\n return;\n }\n\n if (instanceIds.length === 0) return;\n\n this.logger.debug(\n `Disabling EC2 termination protection on ${instanceIds.length} instance(s) of AutoScalingGroup ${logicalId} before force delete`\n );\n for (const instanceId of instanceIds) {\n await disableInstanceApiTermination(this.getEc2Client(), instanceId, this.logger);\n }\n }\n\n private async fetchArn(groupName: string): Promise<string | undefined> {\n try {\n const group = await this.describeGroup(groupName);\n return group?.AutoScalingGroupARN;\n } catch (err) {\n this.logger.debug(\n `DescribeAutoScalingGroups(${groupName}) failed: ${err instanceof Error ? err.message : String(err)}`\n );\n return undefined;\n }\n }\n\n private isNotFoundError(error: unknown): boolean {\n if (!(error instanceof Error)) return false;\n const name = (error as { name?: string }).name ?? '';\n const message = error.message.toLowerCase();\n // ASG returns ValidationError with message \"AutoScalingGroup name not\n // found\" rather than a typed NotFound exception; cover both shapes.\n return (\n name === 'ValidationError' &&\n (message.includes('autoscalinggroup name not found') ||\n message.includes('not found') ||\n message.includes('does not exist'))\n );\n }\n\n private async waitForGroupDeleted(groupName: string, maxWaitMs = 900_000): Promise<void> {\n const startTime = Date.now();\n let delay = 5_000;\n\n while (Date.now() - startTime < maxWaitMs) {\n try {\n const group = await this.describeGroup(groupName);\n if (!group) return;\n } catch (error) {\n if (this.isNotFoundError(error)) return;\n throw error;\n }\n\n await this.sleep(delay);\n delay = Math.min(delay * 2, 10_000);\n }\n\n throw new Error(\n `Timed out waiting for AutoScalingGroup ${groupName} to be deleted (15 minute cap)`\n );\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n // ─── Sub-shape diff helpers ───────────────────────────────────────\n // Each helper is a no-op when before/after JSON is identical (the cheap\n // structural-equality check happens first; we only build SDK calls for\n // genuine diffs). Identity is positional within the array per CFn shape:\n // `MetricsCollection` keyed on `Granularity`, `LifecycleHookSpecification\n // List` on `LifecycleHookName`, `TrafficSources` on `Identifier`,\n // `NotificationConfigurations` on `TopicARN`.\n\n /**\n * Diff and apply changes to the ASG's `Tags` property via the\n * `CreateOrUpdateTags` / `DeleteTags` AWS APIs (#475). CFn Tags shape is\n * `[{Key, Value, PropagateAtLaunch}]`; AWS Tag input adds `ResourceId`\n * (= the ASG name) and `ResourceType: 'auto-scaling-group'`.\n *\n * Diff semantics:\n * - Removed keys → `DeleteTags`.\n * - Added keys → `CreateOrUpdateTags`.\n * - Modified value or `PropagateAtLaunch` flag → `CreateOrUpdateTags`\n * (the AWS API upserts by `(ResourceId, ResourceType, Key)` tuple, so\n * a single upsert call replaces the old value).\n *\n * No-op when before/after JSON is identical.\n */\n private async applyTagsDiff(physicalId: string, next: unknown, prev: unknown): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n type CfnTag = { Key?: string; Value?: string; PropagateAtLaunch?: boolean };\n const nextEntries = (Array.isArray(next) ? next : []) as CfnTag[];\n const prevEntries = (Array.isArray(prev) ? prev : []) as CfnTag[];\n const nextByKey = new Map<string, CfnTag>();\n for (const t of nextEntries) {\n if (t.Key) nextByKey.set(t.Key, t);\n }\n const prevByKey = new Map<string, CfnTag>();\n for (const t of prevEntries) {\n if (t.Key) prevByKey.set(t.Key, t);\n }\n // Delete keys removed from `next`.\n const toDelete: CfnTag[] = [];\n for (const [key, tag] of prevByKey) {\n if (!nextByKey.has(key)) toDelete.push(tag);\n }\n if (toDelete.length > 0) {\n await this.getClient().send(\n new DeleteTagsCommand({\n // DeleteTags is keyed only by (ResourceId, ResourceType, Key).\n // Intentionally omit `Value` / `PropagateAtLaunch`: AWS treats\n // those as additional match constraints, so passing the\n // cdkd-recorded values would silently no-op when a console-side\n // edit drifted them between deploys. cdkd owns the tag, so\n // delete-by-key matches the \"we own the resource\" intent.\n Tags: toDelete.map((t) => ({\n ResourceId: physicalId,\n ResourceType: 'auto-scaling-group',\n Key: t.Key as string,\n })),\n })\n );\n }\n // Upsert keys whose value / propagate-flag differs.\n const toUpsert: CfnTag[] = [];\n for (const [key, tag] of nextByKey) {\n const before = prevByKey.get(key);\n if (JSON.stringify(before) === JSON.stringify(tag)) continue;\n toUpsert.push(tag);\n }\n if (toUpsert.length > 0) {\n await this.getClient().send(\n new CreateOrUpdateTagsCommand({\n Tags: toUpsert.map((t) => ({\n ResourceId: physicalId,\n ResourceType: 'auto-scaling-group',\n Key: t.Key as string,\n ...(t.Value !== undefined && { Value: t.Value }),\n ...(t.PropagateAtLaunch !== undefined && {\n PropagateAtLaunch: t.PropagateAtLaunch,\n }),\n })),\n })\n );\n }\n }\n\n /**\n * Diff `LoadBalancerNames` (Classic Load Balancers) and issue\n * `AttachLoadBalancers` / `DetachLoadBalancers` for the delta (#476).\n * Names are opaque strings; AWS allows N attached LBs per ASG so this\n * helper batches every add into one Attach call and every remove into\n * one Detach call. No-op when before/after JSON is identical.\n */\n private async applyLoadBalancerNamesDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n const nextNames = (Array.isArray(next) ? next : []).filter(\n (n): n is string => typeof n === 'string'\n );\n const prevNames = (Array.isArray(prev) ? prev : []).filter(\n (n): n is string => typeof n === 'string'\n );\n const nextSet = new Set(nextNames);\n const prevSet = new Set(prevNames);\n const toAttach = nextNames.filter((n) => !prevSet.has(n));\n const toDetach = prevNames.filter((n) => !nextSet.has(n));\n if (toDetach.length > 0) {\n await this.getClient().send(\n new DetachLoadBalancersCommand({\n AutoScalingGroupName: physicalId,\n LoadBalancerNames: toDetach,\n })\n );\n }\n if (toAttach.length > 0) {\n await this.getClient().send(\n new AttachLoadBalancersCommand({\n AutoScalingGroupName: physicalId,\n LoadBalancerNames: toAttach,\n })\n );\n }\n }\n\n /**\n * Diff `TargetGroupARNs` (ALB / NLB target groups) and issue\n * `AttachLoadBalancerTargetGroups` /\n * `DetachLoadBalancerTargetGroups` for the delta (#476). Target-group\n * ARNs are opaque strings; same per-call batching pattern as\n * `applyLoadBalancerNamesDiff`. No-op when before/after JSON is\n * identical.\n */\n private async applyTargetGroupArnsDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n const nextArns = (Array.isArray(next) ? next : []).filter(\n (a): a is string => typeof a === 'string'\n );\n const prevArns = (Array.isArray(prev) ? prev : []).filter(\n (a): a is string => typeof a === 'string'\n );\n const nextSet = new Set(nextArns);\n const prevSet = new Set(prevArns);\n const toAttach = nextArns.filter((a) => !prevSet.has(a));\n const toDetach = prevArns.filter((a) => !nextSet.has(a));\n if (toDetach.length > 0) {\n await this.getClient().send(\n new DetachLoadBalancerTargetGroupsCommand({\n AutoScalingGroupName: physicalId,\n TargetGroupARNs: toDetach,\n })\n );\n }\n if (toAttach.length > 0) {\n await this.getClient().send(\n new AttachLoadBalancerTargetGroupsCommand({\n AutoScalingGroupName: physicalId,\n TargetGroupARNs: toAttach,\n })\n );\n }\n // AttachLoadBalancerTargetGroups is async — the target group starts in\n // 'Adding' state and only becomes visible in\n // DescribeAutoScalingGroups.TargetGroupARNs after AWS internal\n // propagation. A subsequent `cdkd drift` read right after the call\n // returns can otherwise see a stale snapshot and report drift\n // against the AWS-side empty list (surfaced by tests/integration/\n // drift-revert-vpc's step-6 \"drift again\" check). Bounded poll to\n // confirm the post-state matches the intent before returning so the\n // caller's next read is consistent.\n if (toDetach.length > 0 || toAttach.length > 0) {\n await this.waitForTargetGroupArnsConvergence(physicalId, new Set(nextArns));\n }\n }\n\n private static readonly TG_CONVERGENCE_TIMEOUT_MS = 30_000;\n private static readonly TG_CONVERGENCE_POLL_INTERVAL_MS = 1_000;\n\n private async waitForTargetGroupArnsConvergence(\n physicalId: string,\n expected: Set<string>\n ): Promise<void> {\n const deadlineMs = Date.now() + ASGProvider.TG_CONVERGENCE_TIMEOUT_MS;\n let lastObserved: Set<string> = new Set();\n while (Date.now() < deadlineMs) {\n let resp: DescribeAutoScalingGroupsCommandOutput | undefined;\n try {\n resp = await this.getClient().send(\n new DescribeAutoScalingGroupsCommand({ AutoScalingGroupNames: [physicalId] })\n );\n } catch (err) {\n // Transient throttle / network blip during the 30s window must\n // not throw out of applyTargetGroupArnsDiff — the Attach/Detach\n // already succeeded, and propagating would fail the whole\n // update path. Log + retry; the loop will fall through to the\n // timeout-warn path if the API is genuinely down.\n this.logger.debug(\n `applyTargetGroupArnsDiff convergence poll: transient error, retrying — ${\n err instanceof Error ? err.message : String(err)\n }`\n );\n await new Promise((r) => setTimeout(r, ASGProvider.TG_CONVERGENCE_POLL_INTERVAL_MS));\n continue;\n }\n lastObserved = new Set(resp.AutoScalingGroups?.[0]?.TargetGroupARNs ?? []);\n if (lastObserved.size === expected.size && [...expected].every((a) => lastObserved.has(a))) {\n return;\n }\n await new Promise((r) => setTimeout(r, ASGProvider.TG_CONVERGENCE_POLL_INTERVAL_MS));\n }\n // Timeout — surface as a warning rather than failure so the caller\n // still sees the SDK-side success; drift can re-report if the\n // propagation is still stuck. Includes observed vs expected so\n // post-mortem doesn't need a re-deploy.\n // Sort both sides before stringify for visual symmetry — expected\n // comes from the caller's insertion order, observed from AWS-side\n // order; eyeballing the diff in logs is easier when both are sorted.\n const expectedSorted = [...expected].sort();\n const observedSorted = [...lastObserved].sort();\n this.logger.warn(\n `applyTargetGroupArnsDiff: TG set did not converge within ${ASGProvider.TG_CONVERGENCE_TIMEOUT_MS}ms for ASG ${physicalId}. expected=${JSON.stringify(expectedSorted)} observed=${JSON.stringify(observedSorted)}`\n );\n }\n\n private async applyMetricsCollectionDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n const nextEntries = (Array.isArray(next) ? next : []) as Array<{\n Granularity?: string;\n Metrics?: string[];\n }>;\n const prevEntries = (Array.isArray(prev) ? prev : []) as Array<{\n Granularity?: string;\n Metrics?: string[];\n }>;\n const prevByGranularity = new Map<string, string[] | undefined>();\n for (const e of prevEntries) {\n if (e.Granularity) prevByGranularity.set(e.Granularity, e.Metrics);\n }\n const nextByGranularity = new Map<string, string[] | undefined>();\n for (const e of nextEntries) {\n if (e.Granularity) nextByGranularity.set(e.Granularity, e.Metrics);\n }\n // Disable removed granularities first, then issue Enable for the\n // intended state of every Granularity in `next`. AWS treats Enable as\n // additive within a Granularity, so a remove-then-add pattern works\n // even when the Metrics list shrinks.\n for (const [granularity, metrics] of prevByGranularity) {\n if (!nextByGranularity.has(granularity)) {\n await this.getClient().send(\n new DisableMetricsCollectionCommand({\n AutoScalingGroupName: physicalId,\n ...(metrics && metrics.length > 0 ? { Metrics: metrics } : {}),\n })\n );\n }\n }\n for (const [granularity, metrics] of nextByGranularity) {\n const before = prevByGranularity.get(granularity);\n if (JSON.stringify(before ?? null) === JSON.stringify(metrics ?? null)) continue;\n // If the Metrics list shrunk, disable the removed metrics first\n // (AWS Enable is additive). When `metrics` is undefined or empty,\n // AWS treats that as \"all metrics\" — disable any prior subset\n // before re-enabling the full set.\n if (before && before.length > 0) {\n const removed = metrics ? before.filter((m) => !metrics.includes(m)) : [];\n if (removed.length > 0) {\n await this.getClient().send(\n new DisableMetricsCollectionCommand({\n AutoScalingGroupName: physicalId,\n Metrics: removed,\n })\n );\n }\n }\n await this.getClient().send(\n new EnableMetricsCollectionCommand({\n AutoScalingGroupName: physicalId,\n Granularity: granularity,\n ...(metrics && metrics.length > 0 ? { Metrics: metrics } : {}),\n })\n );\n }\n }\n\n private async applyLifecycleHooksDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n const nextEntries = (Array.isArray(next) ? next : []) as Array<{\n LifecycleHookName?: string;\n LifecycleTransition?: string;\n RoleARN?: string;\n NotificationTargetARN?: string;\n NotificationMetadata?: string;\n HeartbeatTimeout?: number;\n DefaultResult?: string;\n }>;\n const prevEntries = (Array.isArray(prev) ? prev : []) as Array<{\n LifecycleHookName?: string;\n }>;\n const nextNames = new Set(\n nextEntries.map((e) => e.LifecycleHookName).filter((n): n is string => !!n)\n );\n // Delete hooks no longer in `next`.\n for (const e of prevEntries) {\n if (e.LifecycleHookName && !nextNames.has(e.LifecycleHookName)) {\n await this.getClient().send(\n new DeleteLifecycleHookCommand({\n AutoScalingGroupName: physicalId,\n LifecycleHookName: e.LifecycleHookName,\n })\n );\n }\n }\n // PutLifecycleHook is upsert — issue for every hook in `next` whose\n // shape differs from the matching `prev` entry.\n const prevByName = new Map<string, unknown>();\n for (const e of prevEntries) {\n if (e.LifecycleHookName) prevByName.set(e.LifecycleHookName, e);\n }\n for (const e of nextEntries) {\n if (!e.LifecycleHookName) continue;\n const prevHook = prevByName.get(e.LifecycleHookName);\n if (JSON.stringify(prevHook) === JSON.stringify(e)) continue;\n await this.getClient().send(\n new PutLifecycleHookCommand({\n AutoScalingGroupName: physicalId,\n LifecycleHookName: e.LifecycleHookName,\n ...(e.LifecycleTransition !== undefined && {\n LifecycleTransition: e.LifecycleTransition,\n }),\n ...(e.RoleARN !== undefined && { RoleARN: e.RoleARN }),\n ...(e.NotificationTargetARN !== undefined && {\n NotificationTargetARN: e.NotificationTargetARN,\n }),\n ...(e.NotificationMetadata !== undefined && {\n NotificationMetadata: e.NotificationMetadata,\n }),\n ...(e.HeartbeatTimeout !== undefined && { HeartbeatTimeout: e.HeartbeatTimeout }),\n ...(e.DefaultResult !== undefined && { DefaultResult: e.DefaultResult }),\n })\n );\n }\n }\n\n private async applyTrafficSourcesDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n const nextEntries = (Array.isArray(next) ? next : []) as Array<{\n Identifier?: string;\n Type?: string;\n }>;\n const prevEntries = (Array.isArray(prev) ? prev : []) as Array<{\n Identifier?: string;\n Type?: string;\n }>;\n const nextIds = new Set(nextEntries.map((e) => e.Identifier).filter((i): i is string => !!i));\n const prevIds = new Set(prevEntries.map((e) => e.Identifier).filter((i): i is string => !!i));\n const toDetach = prevEntries.filter((e) => e.Identifier && !nextIds.has(e.Identifier));\n const toAttach = nextEntries.filter((e) => e.Identifier && !prevIds.has(e.Identifier));\n if (toDetach.length > 0) {\n await this.getClient().send(\n new DetachTrafficSourcesCommand({\n AutoScalingGroupName: physicalId,\n TrafficSources: toDetach.map((e) => ({\n Identifier: e.Identifier as string,\n ...(e.Type !== undefined && { Type: e.Type }),\n })),\n })\n );\n }\n if (toAttach.length > 0) {\n await this.getClient().send(\n new AttachTrafficSourcesCommand({\n AutoScalingGroupName: physicalId,\n TrafficSources: toAttach.map((e) => ({\n Identifier: e.Identifier as string,\n ...(e.Type !== undefined && { Type: e.Type }),\n })),\n })\n );\n }\n }\n\n private async applyNotificationConfigurationsDiff(\n physicalId: string,\n next: unknown,\n prev: unknown\n ): Promise<void> {\n if (JSON.stringify(next ?? []) === JSON.stringify(prev ?? [])) return;\n // CFn `NotificationConfigurations` is an array of `{TopicARN,\n // NotificationTypes[]}`; AWS `PutNotificationConfiguration` is keyed\n // by TopicARN — one call per topic. AWS reports each notification\n // type as a separate response entry (one row per `(asgName, topicArn,\n // notificationType)` triple), but cdkd state stores the CFn shape, so\n // both sides of the diff share the per-topic key.\n const nextEntries = (Array.isArray(next) ? next : []) as Array<{\n TopicARN?: string;\n NotificationTypes?: string[];\n }>;\n const prevEntries = (Array.isArray(prev) ? prev : []) as Array<{\n TopicARN?: string;\n NotificationTypes?: string[];\n }>;\n const nextByTopic = new Map<string, string[] | undefined>();\n for (const e of nextEntries) {\n if (e.TopicARN) nextByTopic.set(e.TopicARN, e.NotificationTypes);\n }\n const prevByTopic = new Map<string, string[] | undefined>();\n for (const e of prevEntries) {\n if (e.TopicARN) prevByTopic.set(e.TopicARN, e.NotificationTypes);\n }\n for (const topic of prevByTopic.keys()) {\n if (!nextByTopic.has(topic)) {\n await this.getClient().send(\n new DeleteNotificationConfigurationCommand({\n AutoScalingGroupName: physicalId,\n TopicARN: topic,\n })\n );\n }\n }\n for (const [topic, types] of nextByTopic) {\n const before = prevByTopic.get(topic);\n if (JSON.stringify(before ?? null) === JSON.stringify(types ?? null)) continue;\n await this.getClient().send(\n new PutNotificationConfigurationCommand({\n AutoScalingGroupName: physicalId,\n TopicARN: topic,\n NotificationTypes: types ?? [],\n })\n );\n }\n }\n}\n\n// ─── File-level reverse-mappers (CFn template shape) ────────────────\n\n/**\n * Reverse-map AWS `EnabledMetrics: [{Metric, Granularity}]` (flat list,\n * one row per enabled metric) back to the CFn array shape\n * `[{Granularity, Metrics?[]}]`. Metrics with the same Granularity are\n * grouped together; the resulting Metrics list is sorted alphabetically\n * for stable positional compare in the drift comparator.\n *\n * Always returns a placeholder `[]` per the cdkd PR #145 always-emit\n * convention so a console-side EnableMetricsCollection on a previously-\n * empty group surfaces as drift on the v3 `observedProperties` baseline.\n */\nfunction mapEnabledMetricsToCfn(\n enabledMetrics:\n | Array<{ Metric?: string | undefined; Granularity?: string | undefined }>\n | undefined\n): Array<{ Granularity: string; Metrics?: string[] }> {\n if (!enabledMetrics || enabledMetrics.length === 0) return [];\n const byGranularity = new Map<string, Set<string>>();\n for (const e of enabledMetrics) {\n const g = e.Granularity;\n if (!g) continue;\n let set = byGranularity.get(g);\n if (!set) {\n set = new Set();\n byGranularity.set(g, set);\n }\n if (e.Metric) set.add(e.Metric);\n }\n const result: Array<{ Granularity: string; Metrics?: string[] }> = [];\n // Sort by Granularity for stable positional compare.\n for (const granularity of Array.from(byGranularity.keys()).sort()) {\n const metrics = Array.from(byGranularity.get(granularity) ?? []).sort();\n result.push(\n metrics.length > 0\n ? { Granularity: granularity, Metrics: metrics }\n : { Granularity: granularity }\n );\n }\n return result;\n}\n\n/**\n * Reverse-map AWS `DescribeLifecycleHooks` response to the CFn\n * `LifecycleHookSpecificationList` shape. Each hook is surfaced under the\n * exact CFn property name. AWS-side fields cdkd state never carried\n * (`AutoScalingGroupName` — duplicated on every hook by AWS,\n * `GlobalTimeout` — AWS-derived) are filtered out. Sorted by\n * LifecycleHookName for stable positional compare.\n */\nfunction mapLifecycleHooksToCfn(\n hooks: Array<{\n LifecycleHookName?: string | undefined;\n LifecycleTransition?: string | undefined;\n NotificationTargetARN?: string | undefined;\n RoleARN?: string | undefined;\n NotificationMetadata?: string | undefined;\n HeartbeatTimeout?: number | undefined;\n DefaultResult?: string | undefined;\n }>\n): Array<Record<string, unknown>> {\n if (!hooks || hooks.length === 0) return [];\n const result: Array<Record<string, unknown>> = [];\n for (const h of hooks) {\n if (!h.LifecycleHookName) continue;\n const entry: Record<string, unknown> = { LifecycleHookName: h.LifecycleHookName };\n if (h.LifecycleTransition !== undefined) entry['LifecycleTransition'] = h.LifecycleTransition;\n if (h.RoleARN !== undefined) entry['RoleARN'] = h.RoleARN;\n if (h.NotificationTargetARN !== undefined) {\n entry['NotificationTargetARN'] = h.NotificationTargetARN;\n }\n if (h.NotificationMetadata !== undefined) {\n entry['NotificationMetadata'] = h.NotificationMetadata;\n }\n if (h.HeartbeatTimeout !== undefined) entry['HeartbeatTimeout'] = h.HeartbeatTimeout;\n if (h.DefaultResult !== undefined) entry['DefaultResult'] = h.DefaultResult;\n result.push(entry);\n }\n result.sort((a, b) =>\n String(a['LifecycleHookName']).localeCompare(String(b['LifecycleHookName']))\n );\n return result;\n}\n\n/**\n * Reverse-map AWS `DescribeTrafficSources` response to the CFn\n * `TrafficSources` shape `[{Identifier, Type?}]`. AWS-side runtime fields\n * (`State`, the deprecated `TrafficSource` alias) are filtered out.\n * Sorted by Identifier for stable positional compare.\n */\nfunction mapTrafficSourcesToCfn(\n trafficSources: Array<{ Identifier?: string | undefined; Type?: string | undefined }>\n): Array<Record<string, unknown>> {\n if (!trafficSources || trafficSources.length === 0) return [];\n const result: Array<Record<string, unknown>> = [];\n for (const t of trafficSources) {\n if (!t.Identifier) continue;\n const entry: Record<string, unknown> = { Identifier: t.Identifier };\n if (t.Type !== undefined) entry['Type'] = t.Type;\n result.push(entry);\n }\n result.sort((a, b) => String(a['Identifier']).localeCompare(String(b['Identifier'])));\n return result;\n}\n\n/**\n * Reverse-map AWS `DescribeNotificationConfigurations` (a flat list, one\n * row per `(topicArn, notificationType)`) into the CFn shape\n * `[{TopicARN, NotificationTypes[]}]`. NotificationTypes are grouped per\n * TopicARN and sorted alphabetically for stable positional compare.\n */\nfunction mapNotificationsToCfn(\n configurations: Array<{ TopicARN?: string | undefined; NotificationType?: string | undefined }>\n): Array<Record<string, unknown>> {\n if (!configurations || configurations.length === 0) return [];\n const byTopic = new Map<string, Set<string>>();\n for (const c of configurations) {\n if (!c.TopicARN) continue;\n let set = byTopic.get(c.TopicARN);\n if (!set) {\n set = new Set();\n byTopic.set(c.TopicARN, set);\n }\n if (c.NotificationType) set.add(c.NotificationType);\n }\n const result: Array<Record<string, unknown>> = [];\n for (const topic of Array.from(byTopic.keys()).sort()) {\n const types = Array.from(byTopic.get(topic) ?? []).sort();\n result.push({ TopicARN: topic, NotificationTypes: types });\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,IAAa,cAAb,MAAa,YAAwC;CACnD,AAAQ;CACR,AAAQ;CACR,AAAiB,iBAAiB,QAAQ,IAAI;CAC9C,AAAQ,SAAS,UAAU,CAAC,CAAC,MAAM,aAAa;CAEhD,oCAAoB,IAAI,IAAiC,CACvD,CACE,sDACA,IAAI,IAAI;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CACH,CACF,CAAC;CAED,oCAAoB,IAAI,IAAyC,CAC/D,CACE,sDACA,IAAI,IAAoB,CACtB,CACE,2BACA,2EACF,GACA,CACE,6BACA,wFACF,CACF,CAAC,CACH,CACF,CAAC;CAED,AAAQ,YAA+B;EACrC,IAAI,CAAC,KAAK,WACR,KAAK,YAAY,IAAI,kBACnB,KAAK,iBAAiB,EAAE,QAAQ,KAAK,eAAe,IAAI,CAAC,CAC3D;EAEF,OAAO,KAAK;CACd;CAEA,AAAQ,eAA0B;EAChC,IAAI,CAAC,KAAK,WACR,KAAK,YAAY,IAAI,UAAU,KAAK,iBAAiB,EAAE,QAAQ,KAAK,eAAe,IAAI,CAAC,CAAC;EAE3F,OAAO,KAAK;CACd;CAIA,MAAM,OACJ,WACA,c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IAAI,IAAI,EAAE,gBAAgB;CACpD;CACA,MAAM,SAAyC,CAAC;CAChD,KAAK,MAAM,SAAS,MAAM,KAAK,QAAQ,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG;EACrD,MAAM,QAAQ,MAAM,KAAK,QAAQ,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;EACxD,OAAO,KAAK;GAAE,UAAU;GAAO,mBAAmB;EAAM,CAAC;CAC3D;CACA,OAAO;AACT"}
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { $ as WorkGraph, $t as NestedStackChildDirectDestroyError, A as slowCcOperationTimeoutMs, At as CFN_TEMPLATE_BODY_LIMIT, B as applyRoleArnIfSet, Bt as AwsClients, C as yellow, Ct as resolveAutoAssetStorage, D as ProviderRegistry, Dt as resolveStateBucketWithDefaultAndSource, E as clearOnUpdateRemoval, Et as resolveStateBucketWithDefault, F as refStateLookupFromResource, Ft as expectedOwnerParam, G as DagBuilder, Gt as CdkdError, H as describeTypeWithThrottleRetry, Ht as resetAwsClients, I as WAFv2WebACLProvider, It as AssemblyReader, J as S3StateBackend, Jt as LocalInvokeBuildError$1, K as TemplateParser, L as normalizeAwsTagsToCfn, Lt as processStackMessages, M as isTerminationProtectionPropagationError, Mt as MIGRATE_TMP_PREFIX, N as IntrinsicFunctionResolver, Nt as findLargeInlineResources, O as findActionableSilentDrops, Ot as resolveUseCdkBootstrapAssets, P as cfnRefValueFromPhysicalId, Pt as uploadCfnTemplate, Q as stringifyValue, Qt as MissingCdkCliError, R as resolveExplicitPhysicalId, S as red, St as resolveApp, T as collectInlinePolicyNamesManagedBySiblings, Tt as resolveSkipPrefix, U as withRetry, Ut as setAwsClients, V as DiffCalculator, Vt as getAwsClients, W as isRetryableTransientError, X as shouldRetainResource, Xt as LocalStartServiceError, Y as rebuildClientForBucketRegion, Yt as LocalMigrateError, Z as AssetPublisher, _ as formatResourceLine, _t as getDockerImageBySourceHash, a as DeploymentEventsStore, an as StackTerminationProtectionError, at as BOOTSTRAP_MARKER_PREFIX, b as gray, bt as getDefaultStateBucketName, c as replayFailedOperations, ct as parseBootstrapMarker, d as IMPLICIT_DELETE_DEPENDENCIES, dn as withErrorHandling, dt as buildDockerImage, en as PartialFailureError, et as buildAssetRedirectMap, f as computeImplicitDeleteEdges, ft as formatDockerLoginError, g as renderStatefulReason, gt as AssetManifestLoader, h as isStatefulRecreateTargetSync, ht as runDockerStreaming, i as DeploymentEventsReader, in as StackHasActiveImportsError, it as AssetModeResolver, j as disableInstanceApiTermination, jt as CFN_TEMPLATE_URL_LIMIT, k as CloudControlProvider, kt as warnDeprecatedNoPrefixCliFlag, l as replayRollback, lt as validateAssetBucketName, m as MULTI_REGION_RECREATE_BLOCKED_TYPES, mt as runDockerForeground, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nn as ResourceTimeoutError, nt as loadPublishableAssetManifest, o as planFailedOps, ot as ensureAssetStorage, p as extractDeploymentEventError, pt as getDockerCmd, q as LockManager, r as DeployEngine, rn as ResourceUpdateNotSupportedError, rt as rewriteTemplateAssetReferences, s as planRollback, st as getBootstrapMarkerKey, t as DEFAULT_RESOURCE_TIMEOUT_MS, tn as ProvisioningError, tt as createAssetRedirectResolver, u as withResourceDeadline, un as normalizeAwsError, ut as validateContainerRepoName, v as bold, vt as Synthesizer, w as IAMRoleProvider, wt as resolveCaptureObservedState, x as green, xt as getLegacyStateBucketName, y as cyan, yt as synthesisStatusMessage, z as assertRegionMatch, zt as resolveBucketRegion } from "./deploy-engine-C5ZBU7Ci.js";
2
+ import { $ as WorkGraph, $t as NestedStackChildDirectDestroyError, A as slowCcOperationTimeoutMs, At as CFN_TEMPLATE_BODY_LIMIT, B as applyRoleArnIfSet, Bt as AwsClients, C as yellow, Ct as resolveAutoAssetStorage, D as ProviderRegistry, Dt as resolveStateBucketWithDefaultAndSource, E as clearOnUpdateRemoval, Et as resolveStateBucketWithDefault, F as refStateLookupFromResource, Ft as expectedOwnerParam, G as DagBuilder, Gt as CdkdError, H as describeTypeWithThrottleRetry, Ht as resetAwsClients, I as WAFv2WebACLProvider, It as AssemblyReader, J as S3StateBackend, Jt as LocalInvokeBuildError$1, K as TemplateParser, L as normalizeAwsTagsToCfn, Lt as processStackMessages, M as isTerminationProtectionPropagationError, Mt as MIGRATE_TMP_PREFIX, N as IntrinsicFunctionResolver, Nt as findLargeInlineResources, O as findActionableSilentDrops, Ot as resolveUseCdkBootstrapAssets, P as cfnRefValueFromPhysicalId, Pt as uploadCfnTemplate, Q as stringifyValue, Qt as MissingCdkCliError, R as resolveExplicitPhysicalId, S as red, St as resolveApp, T as collectInlinePolicyNamesManagedBySiblings, Tt as resolveSkipPrefix, U as withRetry, Ut as setAwsClients, V as DiffCalculator, Vt as getAwsClients, W as isRetryableTransientError, X as shouldRetainResource, Xt as LocalStartServiceError, Y as rebuildClientForBucketRegion, Yt as LocalMigrateError, Z as AssetPublisher, _ as formatResourceLine, _t as getDockerImageBySourceHash, a as DeploymentEventsStore, an as StackTerminationProtectionError, at as BOOTSTRAP_MARKER_PREFIX, b as gray, bt as getDefaultStateBucketName, c as replayFailedOperations, ct as parseBootstrapMarker, d as IMPLICIT_DELETE_DEPENDENCIES, dn as withErrorHandling, dt as buildDockerImage, en as PartialFailureError, et as buildAssetRedirectMap, f as computeImplicitDeleteEdges, ft as formatDockerLoginError, g as renderStatefulReason, gt as AssetManifestLoader, h as isStatefulRecreateTargetSync, ht as runDockerStreaming, i as DeploymentEventsReader, in as StackHasActiveImportsError, it as AssetModeResolver, j as disableInstanceApiTermination, jt as CFN_TEMPLATE_URL_LIMIT, k as CloudControlProvider, kt as warnDeprecatedNoPrefixCliFlag, l as replayRollback, lt as validateAssetBucketName, m as MULTI_REGION_RECREATE_BLOCKED_TYPES, mt as runDockerForeground, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nn as ResourceTimeoutError, nt as loadPublishableAssetManifest, o as planFailedOps, ot as ensureAssetStorage, p as extractDeploymentEventError, pt as getDockerCmd, q as LockManager, r as DeployEngine, rn as ResourceUpdateNotSupportedError, rt as rewriteTemplateAssetReferences, s as planRollback, st as getBootstrapMarkerKey, t as DEFAULT_RESOURCE_TIMEOUT_MS, tn as ProvisioningError, tt as createAssetRedirectResolver, u as withResourceDeadline, un as normalizeAwsError, ut as validateContainerRepoName, v as bold, vt as Synthesizer, w as IAMRoleProvider, wt as resolveCaptureObservedState, x as green, xt as getLegacyStateBucketName, y as cyan, yt as synthesisStatusMessage, z as assertRegionMatch, zt as resolveBucketRegion } from "./deploy-engine-DPphskEY.js";
3
3
  import { a as getLiveRenderer, c as PATTERN_B_RESOURCE_TYPES, d as generateResourceNameWithFallback, f as withSkipPrefix, i as runStackBuffered, n as getLogger, o as PATTERN_B_NAME_OPTIONS, p as withStackName, s as PATTERN_B_NAME_PROPERTIES, u as generateResourceName } from "./logger-BYMEE-BS.js";
4
- import { t as ASGProvider } from "./asg-provider-D6491unb.js";
4
+ import { t as ASGProvider } from "./asg-provider-BQswANyu.js";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { createHash, randomBytes, randomUUID } from "node:crypto";
7
7
  import { CopyObjectCommand, CreateBucketCommand, DeleteBucketAnalyticsConfigurationCommand, DeleteBucketCommand, DeleteBucketCorsCommand, DeleteBucketIntelligentTieringConfigurationCommand, DeleteBucketInventoryConfigurationCommand, DeleteBucketLifecycleCommand, DeleteBucketMetricsConfigurationCommand, DeleteBucketPolicyCommand, DeleteBucketReplicationCommand, DeleteBucketTaggingCommand, DeleteBucketWebsiteCommand, DeleteObjectsCommand, GetBucketAccelerateConfigurationCommand, GetBucketCorsCommand, GetBucketEncryptionCommand, GetBucketLifecycleConfigurationCommand, GetBucketLocationCommand, GetBucketLoggingCommand, GetBucketNotificationConfigurationCommand, GetBucketPolicyCommand, GetBucketReplicationCommand, GetBucketTaggingCommand, GetBucketVersioningCommand, GetBucketWebsiteCommand, GetObjectCommand, GetObjectLockConfigurationCommand, GetPublicAccessBlockCommand, HeadBucketCommand, ListBucketAnalyticsConfigurationsCommand, ListBucketIntelligentTieringConfigurationsCommand, ListBucketInventoryConfigurationsCommand, ListBucketMetricsConfigurationsCommand, ListObjectVersionsCommand, ListObjectsV2Command, NoSuchBucket, PutBucketAccelerateConfigurationCommand, PutBucketAnalyticsConfigurationCommand, PutBucketCorsCommand, PutBucketEncryptionCommand, PutBucketIntelligentTieringConfigurationCommand, PutBucketInventoryConfigurationCommand, PutBucketLifecycleConfigurationCommand, PutBucketLoggingCommand, PutBucketMetricsConfigurationCommand, PutBucketNotificationConfigurationCommand, PutBucketOwnershipControlsCommand, PutBucketPolicyCommand, PutBucketReplicationCommand, PutBucketTaggingCommand, PutBucketVersioningCommand, PutBucketWebsiteCommand, PutObjectCommand, PutObjectLockConfigurationCommand, PutPublicAccessBlockCommand, S3Client, S3ServiceException } from "@aws-sdk/client-s3";
@@ -61972,7 +61972,7 @@ function createMigrateCommand() {
61972
61972
  */
61973
61973
  function buildProgram() {
61974
61974
  const program = new Command();
61975
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.267.7");
61975
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.267.8");
61976
61976
  program.hook("preAction", (_thisCommand, actionCommand) => {
61977
61977
  const { profile } = actionCommand.optsWithGlobals();
61978
61978
  if (profile !== void 0) process.env["AWS_PROFILE"] = profile;
@@ -11609,7 +11609,7 @@ var CloudControlProvider = class {
11609
11609
  this.logger.debug(`Deleting resource ${logicalId} (${resourceType}), physical ID: ${physicalId}`);
11610
11610
  if (context?.removeProtection === true && resourceType === "AWS::AutoScaling::AutoScalingGroup") {
11611
11611
  this.logger.debug(`Delegating protected AutoScalingGroup ${logicalId} delete to the SDK ASGProvider (Cloud Control cannot force-delete a protected ASG)`);
11612
- const { ASGProvider } = await import("./asg-provider-D6491unb.js").then((n) => n.n);
11612
+ const { ASGProvider } = await import("./asg-provider-BQswANyu.js").then((n) => n.n);
11613
11613
  await new ASGProvider().delete(logicalId, physicalId, resourceType, _properties, context);
11614
11614
  return;
11615
11615
  }
@@ -17040,6 +17040,11 @@ async function replaySingle(op, stateResources, stackName, ctx, orphanLogicalIds
17040
17040
  throw new Error(`Failed to re-create the old ${op.logicalId} after the new resource (${current.physicalId}) was already deleted: ${recreateError instanceof Error ? recreateError.message : String(recreateError)}. The resource is now absent — fix forward with 'cdkd deploy'.`);
17041
17041
  }
17042
17042
  }
17043
+ const adoptedLiveNewResource = !deletedNewFirst && createResult.physicalId === current.physicalId;
17044
+ if (adoptedLiveNewResource) {
17045
+ logger.warn(` ⚠ ${op.logicalId} (${op.resourceType}): the re-create returned the LIVE new resource (${current.physicalId}) instead of re-creating the old one — its Create API is name-idempotent and the new resource still holds the same user-supplied name. Skipping the delete-new step (it would delete that very resource). The old resource's ORIGINAL properties may NOT have been re-applied; state now records the pre-replacement properties, so run 'cdkd drift ${stackName}' to inspect and 'cdkd deploy' to reconcile, or rename the resource to make the replacement reversible.`);
17046
+ result.warnings++;
17047
+ }
17043
17048
  const { observedProperties: _staleObserved, ...prevRecord } = prev;
17044
17049
  stateResources[op.logicalId] = {
17045
17050
  ...prevRecord,
@@ -17047,13 +17052,13 @@ async function replaySingle(op, stateResources, stackName, ctx, orphanLogicalIds
17047
17052
  attributes: createResult.attributes ?? {}
17048
17053
  };
17049
17054
  await afterOp?.(op.logicalId);
17050
- if (!deletedNewFirst) try {
17055
+ if (!deletedNewFirst && !adoptedLiveNewResource) try {
17051
17056
  await newDeleteProvider.delete(op.logicalId, current.physicalId, op.resourceType, current.properties, { expectedRegion: ctx.region });
17052
17057
  } catch (deleteError) {
17053
17058
  logger.warn(` Rollback: old ${op.logicalId} re-created, but deleting the new resource (${current.physicalId}) failed: ${deleteError instanceof Error ? deleteError.message : String(deleteError)}. Delete it manually — it is no longer tracked in state.`);
17054
17059
  result.warnings++;
17055
17060
  }
17056
- logger.info(` Rollback: ${op.logicalId} replacement reversed (old resource re-created as ${createResult.physicalId})`);
17061
+ logger.info(adoptedLiveNewResource ? ` Rollback: ${op.logicalId} adopted the live resource (${createResult.physicalId}) — replacement NOT fully reversed (name-idempotent Create API)` : ` Rollback: ${op.logicalId} replacement reversed (old resource re-created as ${createResult.physicalId})`);
17057
17062
  ctx.recordEvent?.({
17058
17063
  eventType: "ROLLBACK_RESOURCE_SUCCEEDED",
17059
17064
  stackName,
@@ -17312,7 +17317,7 @@ const FLUSH_INTERVAL_MS = 2e3;
17312
17317
  const FLUSH_EVENT_THRESHOLD = 50;
17313
17318
  /** Build-time cdkd version, with a dev fallback for non-built contexts. */
17314
17319
  function getCdkdVersion() {
17315
- return "0.267.7";
17320
+ return "0.267.8";
17316
17321
  }
17317
17322
  /**
17318
17323
  * Generate a time-sortable unique run id, e.g.
@@ -19318,4 +19323,4 @@ var DeployEngine = class {
19318
19323
 
19319
19324
  //#endregion
19320
19325
  export { WorkGraph as $, NestedStackChildDirectDestroyError as $t, slowCcOperationTimeoutMs as A, CFN_TEMPLATE_BODY_LIMIT as At, applyRoleArnIfSet as B, AwsClients as Bt, yellow as C, resolveAutoAssetStorage as Ct, ProviderRegistry as D, resolveStateBucketWithDefaultAndSource as Dt, clearOnUpdateRemoval as E, resolveStateBucketWithDefault as Et, refStateLookupFromResource as F, expectedOwnerParam as Ft, DagBuilder as G, CdkdError as Gt, describeTypeWithThrottleRetry as H, resetAwsClients as Ht, WAFv2WebACLProvider as I, AssemblyReader as It, S3StateBackend as J, LocalInvokeBuildError as Jt, TemplateParser as K, ConfigError as Kt, normalizeAwsTagsToCfn as L, processStackMessages as Lt, isTerminationProtectionPropagationError as M, MIGRATE_TMP_PREFIX as Mt, IntrinsicFunctionResolver as N, findLargeInlineResources as Nt, findActionableSilentDrops as O, resolveUseCdkBootstrapAssets as Ot, cfnRefValueFromPhysicalId as P, uploadCfnTemplate as Pt, stringifyValue as Q, MissingCdkCliError as Qt, resolveExplicitPhysicalId as R, clearBucketRegionCache as Rt, red as S, resolveApp as St, collectInlinePolicyNamesManagedBySiblings as T, resolveSkipPrefix as Tt, withRetry as U, setAwsClients as Ut, DiffCalculator as V, getAwsClients as Vt, isRetryableTransientError as W, AssetError as Wt, shouldRetainResource as X, LocalStartServiceError as Xt, rebuildClientForBucketRegion as Y, LocalMigrateError as Yt, AssetPublisher as Z, LockError as Zt, formatResourceLine as _, getDockerImageBySourceHash as _t, DeploymentEventsStore as a, StackTerminationProtectionError as an, BOOTSTRAP_MARKER_PREFIX as at, gray as b, getDefaultStateBucketName as bt, replayFailedOperations as c, formatError as cn, parseBootstrapMarker as ct, IMPLICIT_DELETE_DEPENDENCIES as d, withErrorHandling as dn, buildDockerImage as dt, PartialFailureError as en, buildAssetRedirectMap as et, computeImplicitDeleteEdges as f, __exportAll as fn, formatDockerLoginError as ft, renderStatefulReason as g, AssetManifestLoader as gt, isStatefulRecreateTargetSync as h, runDockerStreaming as ht, DeploymentEventsReader as i, StackHasActiveImportsError as in, AssetModeResolver as it, disableInstanceApiTermination as j, CFN_TEMPLATE_URL_LIMIT as jt, CloudControlProvider as k, warnDeprecatedNoPrefixCliFlag as kt, replayRollback as l, isCdkdError as ln, validateAssetBucketName as lt, MULTI_REGION_RECREATE_BLOCKED_TYPES as m, runDockerForeground as mt, DEFAULT_RESOURCE_WARN_AFTER_MS as n, ResourceTimeoutError as nn, loadPublishableAssetManifest as nt, planFailedOps as o, StateError as on, ensureAssetStorage as ot, extractDeploymentEventError as p, getDockerCmd as pt, LockManager as q, DependencyError as qt, DeployEngine as r, ResourceUpdateNotSupportedError as rn, rewriteTemplateAssetReferences as rt, planRollback as s, SynthesisError as sn, getBootstrapMarkerKey as st, DEFAULT_RESOURCE_TIMEOUT_MS as t, ProvisioningError as tn, createAssetRedirectResolver as tt, withResourceDeadline as u, normalizeAwsError as un, validateContainerRepoName as ut, bold as v, Synthesizer as vt, IAMRoleProvider as w, resolveCaptureObservedState as wt, green as x, getLegacyStateBucketName as xt, cyan as y, synthesisStatusMessage as yt, assertRegionMatch as z, resolveBucketRegion as zt };
19321
- //# sourceMappingURL=deploy-engine-C5ZBU7Ci.js.map
19326
+ //# sourceMappingURL=deploy-engine-DPphskEY.js.map