@go-to-k/cdkd 0.256.0 → 0.257.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { $ as BOOTSTRAP_MARKER_PREFIX, A as refStateLookupFromResource, At as AssemblyReader, B as TemplateParser, C as ProviderRegistry, Ct as warnDeprecatedNoPrefixCliFlag, D as isTerminationProtectionPropagationError, Dt as findLargeInlineResources, E as disableInstanceApiTermination, Et as MIGRATE_TMP_PREFIX, F as resolveExplicitPhysicalId, Ft as resetAwsClients, G as AssetPublisher, Gt as MissingCdkCliError, H as S3StateBackend, Ht as LocalMigrateError, I as assertRegionMatch, It as setAwsClients, J as buildAssetRedirectMap, Jt as ProvisioningError, K as stringifyValue, Kt as NestedStackChildDirectDestroyError, L as applyRoleArnIfSet, M as CDK_PATH_TAG, Mt as resolveBucketRegion, N as matchesCdkPath, Nt as AwsClients, O as IntrinsicFunctionResolver, Ot as uploadCfnTemplate, P as normalizeAwsTagsToCfn, Pt as getAwsClients, Q as AssetModeResolver, Qt as StackTerminationProtectionError, R as DiffCalculator, Rt as CdkdError, S as isRetryableTransientError, St as resolveUseCdkBootstrapAssets, T as CloudControlProvider, Tt as CFN_TEMPLATE_URL_LIMIT, U as rebuildClientForBucketRegion, Ut as LocalStartServiceError, V as LockManager, Vt as LocalInvokeBuildError$1, W as shouldRetainResource, X as loadPublishableAssetManifest, Xt as ResourceUpdateNotSupportedError, Y as createAssetRedirectResolver, Yt as ResourceTimeoutError, Z as rewriteTemplateAssetReferences, Zt as StackHasActiveImportsError, _ as yellow, _t as resolveAutoAssetStorage, a as IMPLICIT_DELETE_DEPENDENCIES, at as buildDockerImage, b as importTagWalk, bt as resolveStateBucketWithDefault, c as MULTI_REGION_RECREATE_BLOCKED_TYPES, ct as runDockerForeground, d as formatResourceLine, dt as getDockerImageBySourceHash, et as ensureAssetStorage, f as bold, ft as Synthesizer, g as red, gt as resolveApp, h as green, ht as getLegacyStateBucketName, i as withResourceDeadline, in as withErrorHandling, it as validateContainerRepoName, j as WAFv2WebACLProvider, k as cfnRefValueFromPhysicalId, kt as expectedOwnerParam, l as isStatefulRecreateTargetSync, lt as runDockerStreaming, m as gray, mt as getDefaultStateBucketName, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as parseBootstrapMarker, o as computeImplicitDeleteEdges, ot as formatDockerLoginError, p as cyan, pt as synthesisStatusMessage, q as WorkGraph, qt as PartialFailureError, r as DeployEngine, rn as normalizeAwsError, rt as validateAssetBucketName, s as extractDeploymentEventError, st as getDockerCmd, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as getBootstrapMarkerKey, u as renderStatefulReason, ut as AssetManifestLoader, v as IAMRoleProvider, vt as resolveCaptureObservedState, w as findActionableSilentDrops, wt as CFN_TEMPLATE_BODY_LIMIT, x as withRetry, xt as resolveStateBucketWithDefaultAndSource, y as collectInlinePolicyNamesManagedBySiblings, yt as resolveSkipPrefix, z as DagBuilder } from "./deploy-engine-vUgwldVH.js";
2
+ import { $ as BOOTSTRAP_MARKER_PREFIX, A as withRetry, At as AssemblyReader, B as TemplateParser, C as disableInstanceApiTermination, Ct as warnDeprecatedNoPrefixCliFlag, D as refStateLookupFromResource, Dt as findLargeInlineResources, E as cfnRefValueFromPhysicalId, Et as MIGRATE_TMP_PREFIX, F as resolveExplicitPhysicalId, Ft as resetAwsClients, G as AssetPublisher, Gt as MissingCdkCliError, H as S3StateBackend, Ht as LocalMigrateError, I as assertRegionMatch, It as setAwsClients, J as buildAssetRedirectMap, Jt as ProvisioningError, K as stringifyValue, Kt as NestedStackChildDirectDestroyError, L as applyRoleArnIfSet, M as CDK_PATH_TAG, Mt as resolveBucketRegion, N as matchesCdkPath, Nt as AwsClients, O as WAFv2WebACLProvider, Ot as uploadCfnTemplate, P as normalizeAwsTagsToCfn, Pt as getAwsClients, Q as AssetModeResolver, Qt as StackTerminationProtectionError, R as DiffCalculator, Rt as CdkdError, S as CloudControlProvider, St as resolveUseCdkBootstrapAssets, T as IntrinsicFunctionResolver, Tt as CFN_TEMPLATE_URL_LIMIT, U as rebuildClientForBucketRegion, Ut as LocalStartServiceError, V as LockManager, Vt as LocalInvokeBuildError$1, W as shouldRetainResource, X as loadPublishableAssetManifest, Xt as ResourceUpdateNotSupportedError, Y as createAssetRedirectResolver, Yt as ResourceTimeoutError, Z as rewriteTemplateAssetReferences, Zt as StackHasActiveImportsError, _ as yellow, _t as resolveAutoAssetStorage, a as IMPLICIT_DELETE_DEPENDENCIES, at as buildDockerImage, b as ProviderRegistry, bt as resolveStateBucketWithDefault, c as MULTI_REGION_RECREATE_BLOCKED_TYPES, ct as runDockerForeground, d as formatResourceLine, dt as getDockerImageBySourceHash, et as ensureAssetStorage, f as bold, ft as Synthesizer, g as red, gt as resolveApp, h as green, ht as getLegacyStateBucketName, i as withResourceDeadline, in as withErrorHandling, it as validateContainerRepoName, j as isRetryableTransientError, k as importTagWalk, kt as expectedOwnerParam, l as isStatefulRecreateTargetSync, lt as runDockerStreaming, m as gray, mt as getDefaultStateBucketName, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as parseBootstrapMarker, o as computeImplicitDeleteEdges, ot as formatDockerLoginError, p as cyan, pt as synthesisStatusMessage, q as WorkGraph, qt as PartialFailureError, r as DeployEngine, rn as normalizeAwsError, rt as validateAssetBucketName, s as extractDeploymentEventError, st as getDockerCmd, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as getBootstrapMarkerKey, u as renderStatefulReason, ut as AssetManifestLoader, v as IAMRoleProvider, vt as resolveCaptureObservedState, w as isTerminationProtectionPropagationError, wt as CFN_TEMPLATE_BODY_LIMIT, x as findActionableSilentDrops, xt as resolveStateBucketWithDefaultAndSource, y as collectInlinePolicyNamesManagedBySiblings, yt as resolveSkipPrefix, z as DagBuilder } from "./deploy-engine-DOPBIRKR.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-DbIC4hWG.js";
4
+ import { t as ASGProvider } from "./asg-provider-6IZKZOKp.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, ListBucketsCommand, ListDirectoryBucketsCommand, 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";
@@ -1899,7 +1899,7 @@ const FLUSH_INTERVAL_MS = 2e3;
1899
1899
  const FLUSH_EVENT_THRESHOLD = 50;
1900
1900
  /** Build-time cdkd version, with a dev fallback for non-built contexts. */
1901
1901
  function getCdkdVersion() {
1902
- return "0.256.0";
1902
+ return "0.257.1";
1903
1903
  }
1904
1904
  /**
1905
1905
  * Generate a time-sortable unique run id, e.g.
@@ -3945,9 +3945,11 @@ var IAMInstanceProfileProvider = class {
3945
3945
  * Lookup order:
3946
3946
  * 1. `--resource` override or `Properties.InstanceProfileName` → verify
3947
3947
  * via `GetInstanceProfile`.
3948
- * 2. `ListInstanceProfiles` paginator + match `aws:cdk:path` against the
3949
- * `InstanceProfile.Tags` array returned inline (no separate
3950
- * `ListInstanceProfileTags` call needed).
3948
+ * 2. `ListInstanceProfiles` paginator + a per-candidate `GetInstanceProfile`
3949
+ * to read the tags, matched against `aws:cdk:path`. The list API does
3950
+ * NOT return tags (AWS documents this on the command) even though the
3951
+ * `InstanceProfile` type declares `Tags?`, so reading them off the
3952
+ * summary typechecks and never matches.
3951
3953
  *
3952
3954
  * IAM is global; this walks every instance profile in the account once.
3953
3955
  */
@@ -3963,20 +3965,32 @@ var IAMInstanceProfileProvider = class {
3963
3965
  if (err instanceof NoSuchEntityException) return null;
3964
3966
  throw err;
3965
3967
  }
3966
- if (!input.cdkPath) return null;
3967
- let marker;
3968
- do {
3969
- const list = await this.iamClient.send(new ListInstanceProfilesCommand({ ...marker && { Marker: marker } }));
3970
- for (const profile of list.InstanceProfiles ?? []) {
3971
- if (!profile.InstanceProfileName) continue;
3972
- if (matchesCdkPath(profile.Tags, input.cdkPath)) return {
3973
- physicalId: profile.InstanceProfileName,
3974
- attributes: {}
3968
+ const match = await importTagWalk({
3969
+ cdkPath: input.cdkPath,
3970
+ logicalId: input.logicalId,
3971
+ listPage: async (marker) => {
3972
+ const list = await this.iamClient.send(new ListInstanceProfilesCommand({ ...marker && { Marker: marker } }));
3973
+ return {
3974
+ items: list.InstanceProfiles,
3975
+ nextMarker: list.IsTruncated ? list.Marker : void 0
3975
3976
  };
3976
- }
3977
- marker = list.IsTruncated ? list.Marker : void 0;
3978
- } while (marker);
3979
- return null;
3977
+ },
3978
+ describe: async (profile) => {
3979
+ if (!profile.InstanceProfileName) return void 0;
3980
+ try {
3981
+ return (await this.iamClient.send(new GetInstanceProfileCommand({ InstanceProfileName: profile.InstanceProfileName }))).InstanceProfile;
3982
+ } catch (err) {
3983
+ if (err instanceof NoSuchEntityException) return void 0;
3984
+ throw err;
3985
+ }
3986
+ },
3987
+ tagsOf: (detail) => detail?.Tags
3988
+ });
3989
+ if (!match) return null;
3990
+ return {
3991
+ physicalId: match.summary.InstanceProfileName,
3992
+ attributes: {}
3993
+ };
3980
3994
  }
3981
3995
  };
3982
3996
 
@@ -10379,25 +10393,35 @@ var LambdaLayerVersionProvider = class {
10379
10393
  if (err instanceof ResourceNotFoundException) return null;
10380
10394
  throw err;
10381
10395
  }
10382
- if (!input.cdkPath) return null;
10383
- let marker;
10384
- do {
10385
- const list = await this.lambdaClient.send(new ListLayersCommand({ ...marker && { Marker: marker } }));
10386
- for (const layer of list.Layers ?? []) {
10387
- if (!layer.LayerArn || !layer.LatestMatchingVersion?.LayerVersionArn) continue;
10396
+ const match = await importTagWalk({
10397
+ cdkPath: input.cdkPath,
10398
+ logicalId: input.logicalId,
10399
+ listPage: async (marker) => {
10400
+ const list = await this.lambdaClient.send(new ListLayersCommand({ ...marker && { Marker: marker } }));
10401
+ return {
10402
+ items: list.Layers,
10403
+ nextMarker: list.NextMarker
10404
+ };
10405
+ },
10406
+ describe: async (layer) => {
10407
+ if (!layer.LayerArn || !layer.LatestMatchingVersion?.LayerVersionArn) return void 0;
10388
10408
  try {
10389
- if ((await this.lambdaClient.send(new ListTagsCommand({ Resource: layer.LayerArn }))).Tags?.["aws:cdk:path"] === input.cdkPath) return {
10390
- physicalId: layer.LatestMatchingVersion.LayerVersionArn,
10391
- attributes: {}
10392
- };
10409
+ return await this.lambdaClient.send(new ListTagsCommand({ Resource: layer.LayerArn }));
10393
10410
  } catch (err) {
10394
- if (err instanceof ResourceNotFoundException) continue;
10411
+ if (err instanceof ResourceNotFoundException) return void 0;
10395
10412
  throw err;
10396
10413
  }
10397
- }
10398
- marker = list.NextMarker;
10399
- } while (marker);
10400
- return null;
10414
+ },
10415
+ tagsOf: (tagsResp) => Object.entries(tagsResp.Tags ?? {}).map(([Key, Value]) => ({
10416
+ Key,
10417
+ Value
10418
+ }))
10419
+ });
10420
+ if (!match) return null;
10421
+ return {
10422
+ physicalId: match.summary.LatestMatchingVersion.LayerVersionArn,
10423
+ attributes: {}
10424
+ };
10401
10425
  }
10402
10426
  };
10403
10427
 
@@ -12698,24 +12722,33 @@ var DynamoDBGlobalTableProvider = class {
12698
12722
  if (err instanceof ResourceNotFoundException$1) return null;
12699
12723
  throw err;
12700
12724
  }
12701
- if (!input.cdkPath) return null;
12702
- let exclusiveStartTableName;
12703
- do {
12704
- const list = await this.dynamoDBClient.send(new ListTablesCommand({ ...exclusiveStartTableName && { ExclusiveStartTableName: exclusiveStartTableName } }));
12705
- for (const name of list.TableNames ?? []) try {
12706
- const arn = (await this.dynamoDBClient.send(new DescribeTableCommand({ TableName: name }))).Table?.TableArn;
12707
- if (!arn) continue;
12708
- if (matchesCdkPath((await this.dynamoDBClient.send(new ListTagsOfResourceCommand({ ResourceArn: arn }))).Tags, input.cdkPath)) return {
12709
- physicalId: name,
12710
- attributes: {}
12725
+ const match = await importTagWalk({
12726
+ cdkPath: input.cdkPath,
12727
+ logicalId: input.logicalId,
12728
+ listPage: async (marker) => {
12729
+ const list = await this.dynamoDBClient.send(new ListTablesCommand({ ...marker && { ExclusiveStartTableName: marker } }));
12730
+ return {
12731
+ items: list.TableNames,
12732
+ nextMarker: list.LastEvaluatedTableName
12711
12733
  };
12712
- } catch (err) {
12713
- if (err instanceof ResourceNotFoundException$1) continue;
12714
- throw err;
12715
- }
12716
- exclusiveStartTableName = list.LastEvaluatedTableName;
12717
- } while (exclusiveStartTableName);
12718
- return null;
12734
+ },
12735
+ describe: async (name) => {
12736
+ try {
12737
+ const arn = (await this.dynamoDBClient.send(new DescribeTableCommand({ TableName: name }))).Table?.TableArn;
12738
+ if (!arn) return void 0;
12739
+ return await this.dynamoDBClient.send(new ListTagsOfResourceCommand({ ResourceArn: arn }));
12740
+ } catch (err) {
12741
+ if (err instanceof ResourceNotFoundException$1) return void 0;
12742
+ throw err;
12743
+ }
12744
+ },
12745
+ tagsOf: (tagsResp) => tagsResp.Tags
12746
+ });
12747
+ if (!match) return null;
12748
+ return {
12749
+ physicalId: match.summary,
12750
+ attributes: {}
12751
+ };
12719
12752
  }
12720
12753
  async waitForTableActive(tableName, logicalId, maxAttempts = 120) {
12721
12754
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
@@ -13931,17 +13964,24 @@ var SecretsManagerSecretProvider = class {
13931
13964
  if (err instanceof ResourceNotFoundException$3) return null;
13932
13965
  throw err;
13933
13966
  }
13934
- if (!input.cdkPath) return null;
13935
- let nextToken;
13936
- do {
13937
- const list = await this.smClient.send(new ListSecretsCommand({ ...nextToken && { NextToken: nextToken } }));
13938
- for (const s of list.SecretList ?? []) if (s.ARN && matchesCdkPath(s.Tags, input.cdkPath)) return {
13939
- physicalId: s.ARN,
13940
- attributes: {}
13941
- };
13942
- nextToken = list.NextToken;
13943
- } while (nextToken);
13944
- return null;
13967
+ const match = await importTagWalk({
13968
+ cdkPath: input.cdkPath,
13969
+ logicalId: input.logicalId,
13970
+ listPage: async (marker) => {
13971
+ const list = await this.smClient.send(new ListSecretsCommand({ ...marker && { NextToken: marker } }));
13972
+ return {
13973
+ items: list.SecretList,
13974
+ nextMarker: list.NextToken
13975
+ };
13976
+ },
13977
+ describe: async (secret) => secret.ARN ? secret : void 0,
13978
+ tagsOf: (secret) => secret.Tags
13979
+ });
13980
+ if (!match) return null;
13981
+ return {
13982
+ physicalId: match.summary.ARN,
13983
+ attributes: {}
13984
+ };
13945
13985
  }
13946
13986
  };
13947
13987
 
@@ -14579,23 +14619,30 @@ var EventBridgeRuleProvider = class {
14579
14619
  if (err instanceof ResourceNotFoundException$2) return null;
14580
14620
  throw err;
14581
14621
  }
14582
- if (!input.cdkPath) return null;
14583
- let nextToken;
14584
- do {
14585
- const list = await this.eventBridgeClient.send(new ListRulesCommand({
14586
- ...eventBusName && { EventBusName: eventBusName },
14587
- ...nextToken && { NextToken: nextToken }
14588
- }));
14589
- for (const rule of list.Rules ?? []) {
14590
- if (!rule.Arn) continue;
14591
- if (matchesCdkPath((await this.eventBridgeClient.send(new ListTagsForResourceCommand$1({ ResourceARN: rule.Arn }))).Tags, input.cdkPath)) return {
14592
- physicalId: rule.Arn,
14593
- attributes: {}
14622
+ const match = await importTagWalk({
14623
+ cdkPath: input.cdkPath,
14624
+ logicalId: input.logicalId,
14625
+ listPage: async (marker) => {
14626
+ const list = await this.eventBridgeClient.send(new ListRulesCommand({
14627
+ ...eventBusName && { EventBusName: eventBusName },
14628
+ ...marker && { NextToken: marker }
14629
+ }));
14630
+ return {
14631
+ items: list.Rules,
14632
+ nextMarker: list.NextToken
14594
14633
  };
14595
- }
14596
- nextToken = list.NextToken;
14597
- } while (nextToken);
14598
- return null;
14634
+ },
14635
+ describe: async (rule) => {
14636
+ if (!rule.Arn) return void 0;
14637
+ return await this.eventBridgeClient.send(new ListTagsForResourceCommand$1({ ResourceARN: rule.Arn }));
14638
+ },
14639
+ tagsOf: (tagsResp) => tagsResp.Tags
14640
+ });
14641
+ if (!match) return null;
14642
+ return {
14643
+ physicalId: match.summary.Arn,
14644
+ attributes: {}
14645
+ };
14599
14646
  }
14600
14647
  /**
14601
14648
  * Extract rule name from an ARN
@@ -14880,25 +14927,32 @@ var EventBridgeBusProvider = class {
14880
14927
  if (err instanceof ResourceNotFoundException$2) return null;
14881
14928
  throw err;
14882
14929
  }
14883
- if (!input.cdkPath) return null;
14884
- let nextToken;
14885
- do {
14886
- const list = await this.eventBridgeClient.send(new ListEventBusesCommand({ ...nextToken && { NextToken: nextToken } }));
14887
- for (const bus of list.EventBuses ?? []) {
14888
- if (!bus.Name || !bus.Arn) continue;
14930
+ const match = await importTagWalk({
14931
+ cdkPath: input.cdkPath,
14932
+ logicalId: input.logicalId,
14933
+ listPage: async (marker) => {
14934
+ const list = await this.eventBridgeClient.send(new ListEventBusesCommand({ ...marker && { NextToken: marker } }));
14935
+ return {
14936
+ items: list.EventBuses,
14937
+ nextMarker: list.NextToken
14938
+ };
14939
+ },
14940
+ describe: async (bus) => {
14941
+ if (!bus.Name || !bus.Arn) return void 0;
14889
14942
  try {
14890
- if (matchesCdkPath((await this.eventBridgeClient.send(new ListTagsForResourceCommand$1({ ResourceARN: bus.Arn }))).Tags, input.cdkPath)) return {
14891
- physicalId: bus.Name,
14892
- attributes: {}
14893
- };
14943
+ return await this.eventBridgeClient.send(new ListTagsForResourceCommand$1({ ResourceARN: bus.Arn }));
14894
14944
  } catch (err) {
14895
- if (err instanceof ResourceNotFoundException$2) continue;
14945
+ if (err instanceof ResourceNotFoundException$2) return void 0;
14896
14946
  throw err;
14897
14947
  }
14898
- }
14899
- nextToken = list.NextToken;
14900
- } while (nextToken);
14901
- return null;
14948
+ },
14949
+ tagsOf: (tagsResp) => tagsResp.Tags
14950
+ });
14951
+ if (!match) return null;
14952
+ return {
14953
+ physicalId: match.summary.Name,
14954
+ attributes: {}
14955
+ };
14902
14956
  }
14903
14957
  };
14904
14958
 
@@ -20449,25 +20503,32 @@ var CloudFrontDistributionProvider = class {
20449
20503
  if (err instanceof NoSuchDistribution) return null;
20450
20504
  throw err;
20451
20505
  }
20452
- if (!input.cdkPath) return null;
20453
- let marker;
20454
- do {
20455
- const list = await this.cloudFrontClient.send(new ListDistributionsCommand({ ...marker && { Marker: marker } }));
20456
- for (const d of list.DistributionList?.Items ?? []) {
20457
- if (!d.Id || !d.ARN) continue;
20506
+ const match = await importTagWalk({
20507
+ cdkPath: input.cdkPath,
20508
+ logicalId: input.logicalId,
20509
+ listPage: async (marker) => {
20510
+ const list = await this.cloudFrontClient.send(new ListDistributionsCommand({ ...marker && { Marker: marker } }));
20511
+ return {
20512
+ items: list.DistributionList?.Items,
20513
+ nextMarker: list.DistributionList?.IsTruncated ? list.DistributionList?.NextMarker : void 0
20514
+ };
20515
+ },
20516
+ describe: async (d) => {
20517
+ if (!d.Id || !d.ARN) return void 0;
20458
20518
  try {
20459
- if (matchesCdkPath((await this.cloudFrontClient.send(new ListTagsForResourceCommand$3({ Resource: d.ARN }))).Tags?.Items, input.cdkPath)) return {
20460
- physicalId: d.Id,
20461
- attributes: {}
20462
- };
20519
+ return await this.cloudFrontClient.send(new ListTagsForResourceCommand$3({ Resource: d.ARN }));
20463
20520
  } catch (err) {
20464
- if (err instanceof NoSuchDistribution) continue;
20521
+ if (err instanceof NoSuchDistribution) return void 0;
20465
20522
  throw err;
20466
20523
  }
20467
- }
20468
- marker = list.DistributionList?.IsTruncated ? list.DistributionList?.NextMarker : void 0;
20469
- } while (marker);
20470
- return null;
20524
+ },
20525
+ tagsOf: (tagsResp) => tagsResp.Tags?.Items
20526
+ });
20527
+ if (!match) return null;
20528
+ return {
20529
+ physicalId: match.summary.Id,
20530
+ attributes: {}
20531
+ };
20471
20532
  }
20472
20533
  };
20473
20534
 
@@ -21468,10 +21529,10 @@ var StepFunctionsProvider = class {
21468
21529
  *
21469
21530
  * Lookup order:
21470
21531
  * 1. `--resource <id>=<arn>` override → verify with `DescribeStateMachine`.
21471
- * 2. Walk `ListStateMachines` paginator → `ListTagsForResource(arn)`,
21472
- * match the lowercase `key`/`value` `aws:cdk:path` tag (SFN uses
21473
- * lowercase tags, so `matchesCdkPath` from import-helpers does not
21474
- * apply directly).
21532
+ * 2. Walk `ListStateMachines` → `ListTagsForResource(arn)` via the shared
21533
+ * `importTagWalk` helper. SFN returns lowercase `key`/`value` tags, so
21534
+ * `tagsOf` maps them to the `Key`/`Value` shape the walk's
21535
+ * `aws:cdk:path` matcher expects.
21475
21536
  *
21476
21537
  * SFN state machines do not expose a template-supplied name field
21477
21538
  * usable as a stable physicalId — the physicalId is the ARN — so the
@@ -21489,21 +21550,30 @@ var StepFunctionsProvider = class {
21489
21550
  if (err instanceof StateMachineDoesNotExist) return null;
21490
21551
  throw err;
21491
21552
  }
21492
- if (!input.cdkPath) return null;
21493
- let nextToken;
21494
- do {
21495
- const list = await this.getClient().send(new ListStateMachinesCommand({ ...nextToken && { nextToken } }));
21496
- for (const sm of list.stateMachines ?? []) {
21497
- if (!sm.stateMachineArn) continue;
21498
- const tagsResp = await this.getClient().send(new ListTagsForResourceCommand$11({ resourceArn: sm.stateMachineArn }));
21499
- if (this.tagsMatchCdkPath(tagsResp.tags, input.cdkPath)) return {
21500
- physicalId: sm.stateMachineArn,
21501
- attributes: {}
21553
+ const match = await importTagWalk({
21554
+ cdkPath: input.cdkPath,
21555
+ logicalId: input.logicalId,
21556
+ listPage: async (marker) => {
21557
+ const list = await this.getClient().send(new ListStateMachinesCommand({ ...marker && { nextToken: marker } }));
21558
+ return {
21559
+ items: list.stateMachines,
21560
+ nextMarker: list.nextToken
21502
21561
  };
21503
- }
21504
- nextToken = list.nextToken;
21505
- } while (nextToken);
21506
- return null;
21562
+ },
21563
+ describe: async (sm) => {
21564
+ if (!sm.stateMachineArn) return void 0;
21565
+ return await this.getClient().send(new ListTagsForResourceCommand$11({ resourceArn: sm.stateMachineArn }));
21566
+ },
21567
+ tagsOf: (tagsResp) => (tagsResp.tags ?? []).map((t) => ({
21568
+ Key: t.key,
21569
+ Value: t.value
21570
+ }))
21571
+ });
21572
+ if (!match) return null;
21573
+ return {
21574
+ physicalId: match.summary.stateMachineArn,
21575
+ attributes: {}
21576
+ };
21507
21577
  }
21508
21578
  /**
21509
21579
  * Apply a diff between old and new CFn-shape Tags arrays via SFN's
@@ -21541,14 +21611,6 @@ var StepFunctionsProvider = class {
21541
21611
  }
21542
21612
  }
21543
21613
  /**
21544
- * Match SFN's lowercase `key`/`value` tag shape against the CDK path.
21545
- */
21546
- tagsMatchCdkPath(tags, cdkPath) {
21547
- if (!tags) return false;
21548
- for (const t of tags) if (t.key === "aws:cdk:path" && t.value === cdkPath) return true;
21549
- return false;
21550
- }
21551
- /**
21552
21614
  * Build the state-machine definition string from CDK properties.
21553
21615
  *
21554
21616
  * Precedence (mirrors CloudFormation): an inline `DefinitionString` /
@@ -27959,6 +28021,16 @@ var CognitoUserPoolProvider = class {
27959
28021
  * 3. `aws:cdk:path` tag match via `ListUserPools` +
27960
28022
  * `ListTagsForResource(<arn>)`. Cognito's tag map uses the same
27961
28023
  * `Tags: { [key]: value }` shape as Lambda.
28024
+ *
28025
+ * Steps 2 and 3 share ONE `ListUserPools` walk (per candidate: name check
28026
+ * first, then the two tag reads, only when a `cdkPath` is present), which
28027
+ * runs through the shared `importTagWalk` helper so the N+1 read burst
28028
+ * (DescribeUserPool for the ARN, then ListTagsForResource) is retried with
28029
+ * exponential backoff when AWS throttles it instead of aborting the whole
28030
+ * import. The name match is expressed to the walk as a synthetic
28031
+ * `aws:cdk:path` tag carrying the walk's own lookup key, so a name-only
28032
+ * template (no CDK path metadata) still resolves without any per-candidate
28033
+ * API call, matching the previous inline loop.
27962
28034
  */
27963
28035
  async import(input) {
27964
28036
  if (input.knownPhysicalId) try {
@@ -27972,33 +28044,48 @@ var CognitoUserPoolProvider = class {
27972
28044
  throw err;
27973
28045
  }
27974
28046
  const desiredName = typeof input.properties?.["UserPoolName"] === "string" ? input.properties["UserPoolName"] : void 0;
27975
- let nextToken;
27976
- do {
27977
- const list = await this.getClient().send(new ListUserPoolsCommand({
27978
- MaxResults: 60,
27979
- ...nextToken && { NextToken: nextToken }
27980
- }));
27981
- for (const pool of list.UserPools ?? []) {
27982
- if (!pool.Id) continue;
27983
- if (desiredName && pool.Name === desiredName) return {
27984
- physicalId: pool.Id,
27985
- attributes: {}
28047
+ const walkCdkPath = input.cdkPath || (desiredName ? `cdkd:cognito-user-pool-name:${desiredName}` : void 0);
28048
+ /** Sentinel detail for a candidate matched by its user pool name. */
28049
+ const NAME_MATCH = { nameMatch: true };
28050
+ const match = await importTagWalk({
28051
+ cdkPath: walkCdkPath,
28052
+ logicalId: input.logicalId,
28053
+ listPage: async (marker) => {
28054
+ const list = await this.getClient().send(new ListUserPoolsCommand({
28055
+ MaxResults: 60,
28056
+ ...marker && { NextToken: marker }
28057
+ }));
28058
+ return {
28059
+ items: list.UserPools,
28060
+ nextMarker: list.NextToken
27986
28061
  };
27987
- if (input.cdkPath) try {
28062
+ },
28063
+ describe: async (pool) => {
28064
+ if (!pool.Id) return void 0;
28065
+ if (desiredName && pool.Name === desiredName) return NAME_MATCH;
28066
+ if (!input.cdkPath) return void 0;
28067
+ try {
27988
28068
  const arn = (await this.getClient().send(new DescribeUserPoolCommand({ UserPoolId: pool.Id }))).UserPool?.Arn;
27989
- if (!arn) continue;
27990
- if ((await this.getClient().send(new ListTagsForResourceCommand$15({ ResourceArn: arn }))).Tags?.["aws:cdk:path"] === input.cdkPath) return {
27991
- physicalId: pool.Id,
27992
- attributes: {}
27993
- };
28069
+ if (!arn) return void 0;
28070
+ return await this.getClient().send(new ListTagsForResourceCommand$15({ ResourceArn: arn }));
27994
28071
  } catch (err) {
27995
- if (err instanceof ResourceNotFoundException$7) continue;
28072
+ if (err instanceof ResourceNotFoundException$7) return void 0;
27996
28073
  throw err;
27997
28074
  }
27998
- }
27999
- nextToken = list.NextToken;
28000
- } while (nextToken);
28001
- return null;
28075
+ },
28076
+ tagsOf: (detail) => "nameMatch" in detail ? [{
28077
+ Key: CDK_PATH_TAG,
28078
+ Value: walkCdkPath
28079
+ }] : Object.entries(detail.Tags ?? {}).map(([Key, Value]) => ({
28080
+ Key,
28081
+ Value
28082
+ }))
28083
+ });
28084
+ if (!match) return null;
28085
+ return {
28086
+ physicalId: match.summary.Id,
28087
+ attributes: {}
28088
+ };
28002
28089
  }
28003
28090
  };
28004
28091
 
@@ -32496,25 +32583,35 @@ var KMSProvider = class {
32496
32583
  throw err;
32497
32584
  }
32498
32585
  if (!input.cdkPath) return null;
32499
- let marker;
32500
- do {
32501
- const list = await this.getClient().send(new ListKeysCommand({ ...marker && { Marker: marker } }));
32502
- for (const key of list.Keys ?? []) {
32503
- if (!key.KeyId) continue;
32586
+ const match = await importTagWalk({
32587
+ cdkPath: input.cdkPath,
32588
+ logicalId: input.logicalId,
32589
+ listPage: async (marker) => {
32590
+ const list = await this.getClient().send(new ListKeysCommand({ ...marker && { Marker: marker } }));
32591
+ return {
32592
+ items: list.Keys,
32593
+ nextMarker: list.NextMarker
32594
+ };
32595
+ },
32596
+ describe: async (key) => {
32597
+ if (!key.KeyId) return void 0;
32504
32598
  try {
32505
- const tagsResp = await this.getClient().send(new ListResourceTagsCommand({ KeyId: key.KeyId }));
32506
- for (const tag of tagsResp.Tags ?? []) if (tag.TagKey === "aws:cdk:path" && tag.TagValue === input.cdkPath) return {
32507
- physicalId: key.KeyId,
32508
- attributes: {}
32509
- };
32599
+ return await this.getClient().send(new ListResourceTagsCommand({ KeyId: key.KeyId }));
32510
32600
  } catch (err) {
32511
- if (err.name === "AccessDeniedException" || err instanceof NotFoundException$2) continue;
32601
+ if (err.name === "AccessDeniedException" || err instanceof NotFoundException$2) return void 0;
32512
32602
  throw err;
32513
32603
  }
32514
- }
32515
- marker = list.NextMarker;
32516
- } while (marker);
32517
- return null;
32604
+ },
32605
+ tagsOf: (tagsResp) => (tagsResp.Tags ?? []).map((t) => ({
32606
+ Key: t.TagKey,
32607
+ Value: t.TagValue
32608
+ }))
32609
+ });
32610
+ if (!match) return null;
32611
+ return {
32612
+ physicalId: match.summary.KeyId,
32613
+ attributes: {}
32614
+ };
32518
32615
  }
32519
32616
  };
32520
32617
 
@@ -32984,23 +33081,31 @@ var BudgetsBudgetProvider = class {
32984
33081
  if (error instanceof NotFoundException$5) return null;
32985
33082
  throw error;
32986
33083
  }
32987
- if (!input.cdkPath) return null;
32988
- let nextToken;
32989
- do {
32990
- const list = await client.send(new DescribeBudgetsCommand({
32991
- AccountId: accountId,
32992
- ...nextToken && { NextToken: nextToken }
32993
- }));
32994
- for (const budget of list.Budgets ?? []) {
32995
- if (!budget.BudgetName) continue;
32996
- if (matchesCdkPath((await client.send(new ListTagsForResourceCommand$17({ ResourceARN: this.budgetArn(accountId, budget.BudgetName) }))).ResourceTags, input.cdkPath)) return {
32997
- physicalId: budget.BudgetName,
32998
- attributes: { Arn: this.budgetArn(accountId, budget.BudgetName) }
33084
+ const match = await importTagWalk({
33085
+ cdkPath: input.cdkPath,
33086
+ logicalId: input.logicalId,
33087
+ listPage: async (marker) => {
33088
+ const list = await client.send(new DescribeBudgetsCommand({
33089
+ AccountId: accountId,
33090
+ ...marker && { NextToken: marker }
33091
+ }));
33092
+ return {
33093
+ items: list.Budgets,
33094
+ nextMarker: list.NextToken
32999
33095
  };
33000
- }
33001
- nextToken = list.NextToken;
33002
- } while (nextToken);
33003
- return null;
33096
+ },
33097
+ describe: async (budget) => {
33098
+ if (!budget.BudgetName) return void 0;
33099
+ return await client.send(new ListTagsForResourceCommand$17({ ResourceARN: this.budgetArn(accountId, budget.BudgetName) }));
33100
+ },
33101
+ tagsOf: (tags) => tags.ResourceTags
33102
+ });
33103
+ if (!match) return null;
33104
+ const budgetName = match.summary.BudgetName;
33105
+ return {
33106
+ physicalId: budgetName,
33107
+ attributes: { Arn: this.budgetArn(accountId, budgetName) }
33108
+ };
33004
33109
  }
33005
33110
  };
33006
33111
 
@@ -38200,19 +38305,25 @@ var FirehoseProvider = class {
38200
38305
  if (err instanceof ResourceNotFoundException$10) return null;
38201
38306
  throw err;
38202
38307
  }
38203
- if (!input.cdkPath) return null;
38204
- let exclusiveStartDeliveryStreamName;
38205
- while (true) {
38206
- const list = await this.getClient().send(new ListDeliveryStreamsCommand({ ...exclusiveStartDeliveryStreamName && { ExclusiveStartDeliveryStreamName: exclusiveStartDeliveryStreamName } }));
38207
- const names = list.DeliveryStreamNames ?? [];
38208
- for (const name of names) if (matchesCdkPath((await this.getClient().send(new ListTagsForDeliveryStreamCommand({ DeliveryStreamName: name }))).Tags, input.cdkPath)) return {
38209
- physicalId: name,
38210
- attributes: {}
38211
- };
38212
- if (!list.HasMoreDeliveryStreams || names.length === 0) break;
38213
- exclusiveStartDeliveryStreamName = names[names.length - 1];
38214
- }
38215
- return null;
38308
+ const match = await importTagWalk({
38309
+ cdkPath: input.cdkPath,
38310
+ logicalId: input.logicalId,
38311
+ listPage: async (marker) => {
38312
+ const list = await this.getClient().send(new ListDeliveryStreamsCommand({ ...marker && { ExclusiveStartDeliveryStreamName: marker } }));
38313
+ const names = list.DeliveryStreamNames ?? [];
38314
+ return {
38315
+ items: names,
38316
+ nextMarker: list.HasMoreDeliveryStreams && names.length > 0 ? names[names.length - 1] : void 0
38317
+ };
38318
+ },
38319
+ describe: async (name) => await this.getClient().send(new ListTagsForDeliveryStreamCommand({ DeliveryStreamName: name })),
38320
+ tagsOf: (tagsResp) => tagsResp.Tags
38321
+ });
38322
+ if (!match) return null;
38323
+ return {
38324
+ physicalId: match.summary,
38325
+ attributes: {}
38326
+ };
38216
38327
  }
38217
38328
  /**
38218
38329
  * Wait for a delivery stream to become ACTIVE.
@@ -38718,26 +38829,32 @@ var CloudTrailProvider = class {
38718
38829
  if (err instanceof TrailNotFoundException) return null;
38719
38830
  throw err;
38720
38831
  }
38721
- if (!input.cdkPath) return null;
38722
- let nextToken;
38723
- do {
38724
- const list = await this.getClient().send(new ListTrailsCommand({ ...nextToken && { NextToken: nextToken } }));
38725
- for (const trail of list.Trails ?? []) {
38726
- if (!trail.TrailARN || !trail.Name) continue;
38832
+ const match = await importTagWalk({
38833
+ cdkPath: input.cdkPath,
38834
+ logicalId: input.logicalId,
38835
+ listPage: async (marker) => {
38836
+ const list = await this.getClient().send(new ListTrailsCommand({ ...marker && { NextToken: marker } }));
38837
+ return {
38838
+ items: list.Trails,
38839
+ nextMarker: list.NextToken
38840
+ };
38841
+ },
38842
+ describe: async (trail) => {
38843
+ if (!trail.TrailARN || !trail.Name) return void 0;
38727
38844
  try {
38728
- const list2 = (await this.getClient().send(new ListTagsCommand$1({ ResourceIdList: [trail.TrailARN] }))).ResourceTagList?.[0];
38729
- if (matchesCdkPath(list2?.TagsList, input.cdkPath)) return {
38730
- physicalId: trail.Name,
38731
- attributes: {}
38732
- };
38845
+ return await this.getClient().send(new ListTagsCommand$1({ ResourceIdList: [trail.TrailARN] }));
38733
38846
  } catch (err) {
38734
- if (err instanceof TrailNotFoundException) continue;
38847
+ if (err instanceof TrailNotFoundException) return void 0;
38735
38848
  throw err;
38736
38849
  }
38737
- }
38738
- nextToken = list.NextToken;
38739
- } while (nextToken);
38740
- return null;
38850
+ },
38851
+ tagsOf: (tagsResp) => tagsResp.ResourceTagList?.[0]?.TagsList
38852
+ });
38853
+ if (!match) return null;
38854
+ return {
38855
+ physicalId: match.summary.Name,
38856
+ attributes: {}
38857
+ };
38741
38858
  }
38742
38859
  };
38743
38860
 
@@ -39611,28 +39728,42 @@ var CodeCommitRepositoryProvider = class {
39611
39728
  if (err instanceof RepositoryDoesNotExistException) return null;
39612
39729
  throw err;
39613
39730
  }
39614
- if (!input.cdkPath) return null;
39615
- let nextToken;
39616
- do {
39617
- const list = await this.getClient().send(new ListRepositoriesCommand({ ...nextToken && { nextToken } }));
39618
- for (const repo of list.repositories ?? []) {
39619
- if (!repo.repositoryName) continue;
39731
+ const match = await importTagWalk({
39732
+ cdkPath: input.cdkPath,
39733
+ logicalId: input.logicalId,
39734
+ listPage: async (marker) => {
39735
+ const list = await this.getClient().send(new ListRepositoriesCommand({ ...marker && { nextToken: marker } }));
39736
+ return {
39737
+ items: list.repositories,
39738
+ nextMarker: list.nextToken
39739
+ };
39740
+ },
39741
+ describe: async (repo) => {
39742
+ if (!repo.repositoryName) return void 0;
39620
39743
  let metadata;
39621
39744
  try {
39622
39745
  metadata = await this.getRepositoryMetadata(repo.repositoryName);
39623
39746
  } catch (err) {
39624
- if (err instanceof RepositoryDoesNotExistException) continue;
39747
+ if (err instanceof RepositoryDoesNotExistException) return void 0;
39625
39748
  throw err;
39626
39749
  }
39627
- if (!metadata?.Arn) continue;
39628
- if ((await this.getClient().send(new ListTagsForResourceCommand$19({ resourceArn: metadata.Arn }))).tags?.["aws:cdk:path"] === input.cdkPath) return {
39629
- physicalId: repo.repositoryName,
39630
- attributes: this.toAttributes(metadata)
39750
+ if (!metadata?.Arn) return void 0;
39751
+ const tagsResp = await this.getClient().send(new ListTagsForResourceCommand$19({ resourceArn: metadata.Arn }));
39752
+ return {
39753
+ metadata,
39754
+ tags: tagsResp.tags
39631
39755
  };
39632
- }
39633
- nextToken = list.nextToken;
39634
- } while (nextToken);
39635
- return null;
39756
+ },
39757
+ tagsOf: (detail) => Object.entries(detail.tags ?? {}).map(([Key, Value]) => ({
39758
+ Key,
39759
+ Value
39760
+ }))
39761
+ });
39762
+ if (!match) return null;
39763
+ return {
39764
+ physicalId: match.summary.repositoryName,
39765
+ attributes: this.toAttributes(match.detail.metadata)
39766
+ };
39636
39767
  }
39637
39768
  /**
39638
39769
  * Seed the repository's initial commit from the CFn `Code` property.
@@ -39962,16 +40093,23 @@ var DLMLifecyclePolicyProvider = class {
39962
40093
  if (err instanceof ResourceNotFoundException$12) return null;
39963
40094
  throw err;
39964
40095
  }
39965
- if (!input.cdkPath) return null;
39966
- const list = await this.getClient().send(new GetLifecyclePoliciesCommand({}));
39967
- for (const policy of list.Policies ?? []) {
39968
- if (!policy.PolicyId) continue;
39969
- if (policy.Tags?.["aws:cdk:path"] === input.cdkPath) return {
39970
- physicalId: policy.PolicyId,
39971
- attributes: {}
39972
- };
39973
- }
39974
- return null;
40096
+ const match = await importTagWalk({
40097
+ cdkPath: input.cdkPath,
40098
+ logicalId: input.logicalId,
40099
+ listPage: async () => {
40100
+ return { items: (await this.getClient().send(new GetLifecyclePoliciesCommand({}))).Policies };
40101
+ },
40102
+ describe: async (policy) => policy.PolicyId ? policy : void 0,
40103
+ tagsOf: (policy) => Object.entries(policy.Tags ?? {}).map(([Key, Value]) => ({
40104
+ Key,
40105
+ Value
40106
+ }))
40107
+ });
40108
+ if (!match) return null;
40109
+ return {
40110
+ physicalId: match.summary.PolicyId,
40111
+ attributes: {}
40112
+ };
39975
40113
  }
39976
40114
  };
39977
40115
 
@@ -40209,25 +40347,35 @@ var S3VectorsProvider = class {
40209
40347
  if (this.isNotFoundError(err)) return null;
40210
40348
  throw err;
40211
40349
  }
40212
- if (!input.cdkPath) return null;
40213
- let token;
40214
- do {
40215
- const list = await this.getClient().send(new ListVectorBucketsCommand({ ...token && { nextToken: token } }));
40216
- for (const bucket of list.vectorBuckets ?? []) {
40217
- if (!bucket.vectorBucketName || !bucket.vectorBucketArn) continue;
40350
+ const match = await importTagWalk({
40351
+ cdkPath: input.cdkPath,
40352
+ logicalId: input.logicalId,
40353
+ listPage: async (marker) => {
40354
+ const list = await this.getClient().send(new ListVectorBucketsCommand({ ...marker && { nextToken: marker } }));
40355
+ return {
40356
+ items: list.vectorBuckets,
40357
+ nextMarker: list.nextToken
40358
+ };
40359
+ },
40360
+ describe: async (bucket) => {
40361
+ if (!bucket.vectorBucketName || !bucket.vectorBucketArn) return void 0;
40218
40362
  try {
40219
- if ((await this.getClient().send(new ListTagsForResourceCommand$20({ resourceArn: bucket.vectorBucketArn }))).tags?.["aws:cdk:path"] === input.cdkPath) return {
40220
- physicalId: bucket.vectorBucketName,
40221
- attributes: {}
40222
- };
40363
+ return await this.getClient().send(new ListTagsForResourceCommand$20({ resourceArn: bucket.vectorBucketArn }));
40223
40364
  } catch (err) {
40224
- if (this.isNotFoundError(err)) continue;
40365
+ if (this.isNotFoundError(err)) return void 0;
40225
40366
  throw err;
40226
40367
  }
40227
- }
40228
- token = list.nextToken;
40229
- } while (token);
40230
- return null;
40368
+ },
40369
+ tagsOf: (tagsResp) => Object.entries(tagsResp.tags ?? {}).map(([Key, Value]) => ({
40370
+ Key,
40371
+ Value
40372
+ }))
40373
+ });
40374
+ if (!match) return null;
40375
+ return {
40376
+ physicalId: match.summary.vectorBucketName,
40377
+ attributes: {}
40378
+ };
40231
40379
  }
40232
40380
  isNotFoundError(error) {
40233
40381
  if (error instanceof Error) {
@@ -40458,26 +40606,33 @@ var S3DirectoryBucketProvider = class {
40458
40606
  if (e.name === "NotFound" || e.name === "NoSuchBucket") return null;
40459
40607
  throw err;
40460
40608
  }
40461
- if (!input.cdkPath) return null;
40462
- let token;
40463
- do {
40464
- const list = await this.s3Client.send(new ListDirectoryBucketsCommand({ ...token && { ContinuationToken: token } }));
40465
- for (const b of list.Buckets ?? []) {
40466
- if (!b.Name) continue;
40609
+ const match = await importTagWalk({
40610
+ cdkPath: input.cdkPath,
40611
+ logicalId: input.logicalId,
40612
+ listPage: async (token) => {
40613
+ const list = await this.s3Client.send(new ListDirectoryBucketsCommand({ ...token && { ContinuationToken: token } }));
40614
+ return {
40615
+ items: list.Buckets,
40616
+ nextMarker: list.ContinuationToken
40617
+ };
40618
+ },
40619
+ describe: async (b) => {
40620
+ if (!b.Name) return void 0;
40467
40621
  try {
40468
- if (matchesCdkPath((await this.s3Client.send(new GetBucketTaggingCommand({ Bucket: b.Name }))).TagSet, input.cdkPath)) return {
40469
- physicalId: b.Name,
40470
- attributes: {}
40471
- };
40622
+ return await this.s3Client.send(new GetBucketTaggingCommand({ Bucket: b.Name }));
40472
40623
  } catch (err) {
40473
40624
  const e = err;
40474
- if (e.name === "NoSuchTagSet" || e.name === "AccessDenied") continue;
40625
+ if (e.name === "NoSuchTagSet" || e.name === "AccessDenied") return void 0;
40475
40626
  throw err;
40476
40627
  }
40477
- }
40478
- token = list.ContinuationToken;
40479
- } while (token);
40480
- return null;
40628
+ },
40629
+ tagsOf: (tagging) => tagging.TagSet
40630
+ });
40631
+ if (!match) return null;
40632
+ return {
40633
+ physicalId: match.summary.Name,
40634
+ attributes: {}
40635
+ };
40481
40636
  }
40482
40637
  };
40483
40638
 
@@ -42510,28 +42665,36 @@ var ACMCertificateProvider = class {
42510
42665
  throw err;
42511
42666
  }
42512
42667
  }
42513
- if (!input.cdkPath) return null;
42514
- let nextToken;
42515
- do {
42516
- const list = await this.acmClient.send(new ListCertificatesCommand({ ...nextToken ? { NextToken: nextToken } : {} }));
42517
- for (const summary of list.CertificateSummaryList ?? []) {
42518
- if (!summary.CertificateArn) continue;
42668
+ const match = await importTagWalk({
42669
+ cdkPath: input.cdkPath,
42670
+ logicalId: input.logicalId,
42671
+ listPage: async (marker) => {
42672
+ const list = await this.acmClient.send(new ListCertificatesCommand({ ...marker && { NextToken: marker } }));
42673
+ return {
42674
+ items: list.CertificateSummaryList,
42675
+ nextMarker: list.NextToken
42676
+ };
42677
+ },
42678
+ describe: async (summary) => {
42679
+ if (!summary.CertificateArn) return void 0;
42519
42680
  try {
42520
- if (matchesCdkPath((await this.acmClient.send(new ListTagsForCertificateCommand({ CertificateArn: summary.CertificateArn }))).Tags, input.cdkPath)) return {
42521
- physicalId: summary.CertificateArn,
42522
- attributes: {
42523
- Arn: summary.CertificateArn,
42524
- CertificateArn: summary.CertificateArn
42525
- }
42526
- };
42681
+ return await this.acmClient.send(new ListTagsForCertificateCommand({ CertificateArn: summary.CertificateArn }));
42527
42682
  } catch (err) {
42528
- if (err instanceof ResourceNotFoundException$6) continue;
42683
+ if (err instanceof ResourceNotFoundException$6) return void 0;
42529
42684
  throw err;
42530
42685
  }
42686
+ },
42687
+ tagsOf: (tagsResp) => tagsResp.Tags
42688
+ });
42689
+ if (!match) return null;
42690
+ const arn = match.summary.CertificateArn;
42691
+ return {
42692
+ physicalId: arn,
42693
+ attributes: {
42694
+ Arn: arn,
42695
+ CertificateArn: arn
42531
42696
  }
42532
- nextToken = list.NextToken;
42533
- } while (nextToken);
42534
- return null;
42697
+ };
42535
42698
  }
42536
42699
  /**
42537
42700
  * Poll `DescribeCertificate` until status === `ISSUED`. On the FIRST poll
@@ -44088,6 +44251,67 @@ async function confirmPrompt$6(prompt) {
44088
44251
  rl.close();
44089
44252
  }
44090
44253
  }
44254
+ /**
44255
+ * Flat `logicalId -> physicalId` map for ONE CloudFormation stack, or `null`
44256
+ * when no stack of that name exists.
44257
+ *
44258
+ * This is the non-recursive, non-throwing sibling of
44259
+ * {@link getCloudFormationResourceTree}, used by `cdkd import`'s auto mode as
44260
+ * a best-effort lookup (issue #1128). The distinction matters:
44261
+ *
44262
+ * - the tree walk is for `--migrate-from-cloudformation`, where the stack is
44263
+ * known to exist and nested children must be walked so each child's state
44264
+ * can be written and the whole tree retired;
44265
+ * - this one runs speculatively on every auto-mode import, so a missing
44266
+ * stack is the NORMAL case (a cdkd-native stack has no CFn counterpart)
44267
+ * and must return `null` rather than abort the import.
44268
+ *
44269
+ * NO failure is fatal. The lookup is an OPTIMIZATION: when it cannot answer,
44270
+ * the caller falls through to the per-provider lookups, which is exactly the
44271
+ * behavior that shipped before this function existed. Throwing would convert a
44272
+ * missed improvement into a hard failure — and it would do so precisely for the
44273
+ * users least likely to benefit. A cdkd-native stack has no CloudFormation
44274
+ * counterpart, so an operator whose IAM policy is scoped to cdkd's actual needs
44275
+ * (no `cloudformation:DescribeStackResources`) would see `AccessDenied` abort an
44276
+ * import that worked fine the day before.
44277
+ *
44278
+ * A missing stack is the expected case and logs at debug. Anything else logs a
44279
+ * WARN naming the cause, so a permissions gap or a throttle is visible rather
44280
+ * than silent — the user learns why the ids were not resolved, and still gets
44281
+ * the pre-existing behavior instead of an abort.
44282
+ */
44283
+ async function tryGetCloudFormationResourceMap(stackName, cfnClient) {
44284
+ const logger = getLogger();
44285
+ let resp;
44286
+ try {
44287
+ resp = await cfnClient.send(new DescribeStackResourcesCommand({ StackName: stackName }));
44288
+ } catch (err) {
44289
+ if (isStackNotFoundError(err)) {
44290
+ logger.debug(`No CloudFormation stack named '${stackName}'.`);
44291
+ return null;
44292
+ }
44293
+ const reason = err instanceof Error ? err.message : String(err);
44294
+ logger.warn(`Could not read CloudFormation stack '${stackName}' to resolve physical IDs (${reason}). Falling back to per-resource lookup; resources whose physical name CloudFormation generated may be reported as not found. Grant cloudformation:DescribeStackResources, or pass --resource <LogicalId>=<physicalId> for those resources.`);
44295
+ return null;
44296
+ }
44297
+ const resources = /* @__PURE__ */ new Map();
44298
+ for (const r of resp.StackResources ?? []) {
44299
+ if (!r.LogicalResourceId || !r.PhysicalResourceId) continue;
44300
+ resources.set(r.LogicalResourceId, r.PhysicalResourceId);
44301
+ }
44302
+ return resources;
44303
+ }
44304
+ /**
44305
+ * CloudFormation reports an unknown stack as a `ValidationError` whose message
44306
+ * carries "does not exist" — there is no dedicated exception type to catch.
44307
+ * Matching the message is therefore required, but it is kept narrow so an
44308
+ * unrelated ValidationError (a malformed stack name, say) still surfaces.
44309
+ */
44310
+ function isStackNotFoundError(err) {
44311
+ const name = err?.name;
44312
+ const message = err?.message ?? "";
44313
+ return name === "ValidationError" && /does not exist/i.test(message);
44314
+ }
44091
44315
 
44092
44316
  //#endregion
44093
44317
  //#region src/cli/commands/diff-recursive.ts
@@ -51814,6 +52038,21 @@ async function importCommand(stackArg, options) {
51814
52038
  }
51815
52039
  const selectiveMode = overrides.size > 0 && !options.auto && !options.migrateFromCloudformation;
51816
52040
  if (selectiveMode) logger.info(`Selective mode: only importing the ${overrides.size} resource(s) you listed (${[...overrides.keys()].join(", ")}). Pass --auto to also tag-import the rest.`);
52041
+ if (!selectiveMode && !migrationCfnStackName) {
52042
+ const cfnResources = await tryGetCloudFormationResourceMap(stackInfo.stackName, awsClients.cloudFormation);
52043
+ if (cfnResources) {
52044
+ let derived = 0;
52045
+ for (const [logicalId, physicalId] of cfnResources) {
52046
+ if (!templateLogicalIds.has(logicalId)) continue;
52047
+ if (template.Resources[logicalId]?.Type === "AWS::CloudFormation::Stack") continue;
52048
+ if (overrides.has(logicalId)) continue;
52049
+ overrides.set(logicalId, physicalId);
52050
+ derived++;
52051
+ }
52052
+ if (derived > 0) logger.info(`Resolved ${derived} physical ID(s) from CloudFormation stack '${stackInfo.stackName}'. To adopt AND retire that stack, use --migrate-from-cloudformation.`);
52053
+ else logger.debug(`CloudFormation stack '${stackInfo.stackName}' contributed no new physical IDs.`);
52054
+ } else logger.debug(`No CloudFormation stack named '${stackInfo.stackName}' — resolving physical IDs per provider.`);
52055
+ }
51817
52056
  const existingResult = await stateBackend.getState(stackInfo.stackName, targetRegion);
51818
52057
  const existingState = existingResult?.state ?? null;
51819
52058
  const existingEtag = existingResult?.etag;
@@ -62081,7 +62320,7 @@ function createMigrateCommand() {
62081
62320
  */
62082
62321
  function buildProgram() {
62083
62322
  const program = new Command();
62084
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.256.0");
62323
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.257.1");
62085
62324
  program.addCommand(createBootstrapCommand());
62086
62325
  program.addCommand(createSynthCommand());
62087
62326
  program.addCommand(createListCommand());