@go-to-k/cdkd 0.19.0 → 0.20.0

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
@@ -1155,11 +1155,11 @@ async function resolveStateBucketWithDefaultAndSource(cliBucket, region) {
1155
1155
  return syncResult;
1156
1156
  const logger = getLogger();
1157
1157
  logger.debug("No state bucket specified, resolving default from account...");
1158
- const { GetCallerIdentityCommand: GetCallerIdentityCommand9 } = await import("@aws-sdk/client-sts");
1158
+ const { GetCallerIdentityCommand: GetCallerIdentityCommand11 } = await import("@aws-sdk/client-sts");
1159
1159
  const { S3Client: S3Client11 } = await import("@aws-sdk/client-s3");
1160
1160
  const { getAwsClients: getAwsClients2 } = await Promise.resolve().then(() => (init_aws_clients(), aws_clients_exports));
1161
1161
  const awsClients = getAwsClients2();
1162
- const identity = await awsClients.sts.send(new GetCallerIdentityCommand9({}));
1162
+ const identity = await awsClients.sts.send(new GetCallerIdentityCommand11({}));
1163
1163
  const accountId = identity.Account;
1164
1164
  const newName = getDefaultStateBucketName(accountId);
1165
1165
  const legacyName = getLegacyStateBucketName(accountId, region);
@@ -3431,9 +3431,9 @@ var AssetPublisher = class {
3431
3431
  const region = options.region || process.env["AWS_REGION"] || "us-east-1";
3432
3432
  let accountId = options.accountId;
3433
3433
  if (!accountId) {
3434
- const { STSClient: STSClient7, GetCallerIdentityCommand: GetCallerIdentityCommand9 } = await import("@aws-sdk/client-sts");
3435
- const stsClient = new STSClient7({ region });
3436
- const identity = await stsClient.send(new GetCallerIdentityCommand9({}));
3434
+ const { STSClient: STSClient9, GetCallerIdentityCommand: GetCallerIdentityCommand11 } = await import("@aws-sdk/client-sts");
3435
+ const stsClient = new STSClient9({ region });
3436
+ const identity = await stsClient.send(new GetCallerIdentityCommand11({}));
3437
3437
  accountId = identity.Account;
3438
3438
  stsClient.destroy();
3439
3439
  }
@@ -15109,7 +15109,9 @@ import {
15109
15109
  RemoveTargetsCommand,
15110
15110
  DeleteRuleCommand,
15111
15111
  DescribeRuleCommand,
15112
+ ListRulesCommand,
15112
15113
  ListTargetsByRuleCommand,
15114
+ ListTagsForResourceCommand as ListTagsForResourceCommand5,
15113
15115
  TagResourceCommand as TagResourceCommand4,
15114
15116
  UntagResourceCommand as UntagResourceCommand4,
15115
15117
  ResourceNotFoundException as ResourceNotFoundException9
@@ -15377,6 +15379,85 @@ var EventBridgeRuleProvider = class {
15377
15379
  }
15378
15380
  throw new Error(`Unsupported attribute: ${attributeName} for AWS::Events::Rule`);
15379
15381
  }
15382
+ /**
15383
+ * Adopt an existing EventBridge rule into cdkd state.
15384
+ *
15385
+ * Lookup order:
15386
+ * 1. `--resource <id>=<arnOrName>` override → verify with
15387
+ * `DescribeRule` (scoped to the same `EventBusName` declared in
15388
+ * the template, if any). The override is honored as-is so users
15389
+ * can pass either the ARN (cdkd's standard physicalId form for
15390
+ * this provider) or just the rule name.
15391
+ * 2. If the template carries `Properties.Name` use that as the rule
15392
+ * name lookup, then verify with `DescribeRule` and return the
15393
+ * rule's ARN as physicalId.
15394
+ * 3. Walk `ListRules(EventBusName?)` and match `aws:cdk:path` via
15395
+ * `ListTagsForResource(ResourceARN=rule.Arn)`. Returns the rule
15396
+ * ARN as physicalId — same shape that `create` returns.
15397
+ *
15398
+ * EventBridge tags use the standard `Tag[]` array shape
15399
+ * (`Key`/`Value`).
15400
+ */
15401
+ async import(input) {
15402
+ const eventBusName = input.properties["EventBusName"];
15403
+ if (input.knownPhysicalId) {
15404
+ try {
15405
+ const ruleName = this.extractRuleNameFromArn(input.knownPhysicalId);
15406
+ const resp = await this.eventBridgeClient.send(
15407
+ new DescribeRuleCommand({
15408
+ Name: ruleName,
15409
+ ...eventBusName && { EventBusName: eventBusName }
15410
+ })
15411
+ );
15412
+ return { physicalId: resp.Arn ?? input.knownPhysicalId, attributes: {} };
15413
+ } catch (err) {
15414
+ if (err instanceof ResourceNotFoundException9)
15415
+ return null;
15416
+ throw err;
15417
+ }
15418
+ }
15419
+ const templateName = input.properties["Name"];
15420
+ if (templateName) {
15421
+ try {
15422
+ const resp = await this.eventBridgeClient.send(
15423
+ new DescribeRuleCommand({
15424
+ Name: templateName,
15425
+ ...eventBusName && { EventBusName: eventBusName }
15426
+ })
15427
+ );
15428
+ if (resp.Arn)
15429
+ return { physicalId: resp.Arn, attributes: {} };
15430
+ return null;
15431
+ } catch (err) {
15432
+ if (err instanceof ResourceNotFoundException9)
15433
+ return null;
15434
+ throw err;
15435
+ }
15436
+ }
15437
+ if (!input.cdkPath)
15438
+ return null;
15439
+ let nextToken;
15440
+ do {
15441
+ const list = await this.eventBridgeClient.send(
15442
+ new ListRulesCommand({
15443
+ ...eventBusName && { EventBusName: eventBusName },
15444
+ ...nextToken && { NextToken: nextToken }
15445
+ })
15446
+ );
15447
+ for (const rule of list.Rules ?? []) {
15448
+ if (!rule.Arn)
15449
+ continue;
15450
+ const tagsResp = await this.eventBridgeClient.send(
15451
+ new ListTagsForResourceCommand5({ ResourceARN: rule.Arn })
15452
+ );
15453
+ if (matchesCdkPath(tagsResp.Tags, input.cdkPath)) {
15454
+ return { physicalId: rule.Arn, attributes: {} };
15455
+ }
15456
+ }
15457
+ nextToken = list.NextToken;
15458
+ } while (nextToken);
15459
+ return null;
15460
+ }
15380
15461
  /**
15381
15462
  * Extract rule name from an ARN
15382
15463
  *
@@ -15399,8 +15480,8 @@ import {
15399
15480
  UpdateEventBusCommand,
15400
15481
  DescribeEventBusCommand,
15401
15482
  ListEventBusesCommand,
15402
- ListRulesCommand,
15403
- ListTagsForResourceCommand as ListTagsForResourceCommand5,
15483
+ ListRulesCommand as ListRulesCommand2,
15484
+ ListTagsForResourceCommand as ListTagsForResourceCommand6,
15404
15485
  RemoveTargetsCommand as RemoveTargetsCommand2,
15405
15486
  DeleteRuleCommand as DeleteRuleCommand2,
15406
15487
  ListTargetsByRuleCommand as ListTargetsByRuleCommand2,
@@ -15595,7 +15676,7 @@ var EventBridgeBusProvider = class {
15595
15676
  async cleanupRulesOnBus(busName) {
15596
15677
  try {
15597
15678
  const rulesResponse = await this.eventBridgeClient.send(
15598
- new ListRulesCommand({ EventBusName: busName })
15679
+ new ListRulesCommand2({ EventBusName: busName })
15599
15680
  );
15600
15681
  const rules = rulesResponse.Rules ?? [];
15601
15682
  if (rules.length === 0)
@@ -15672,7 +15753,7 @@ var EventBridgeBusProvider = class {
15672
15753
  continue;
15673
15754
  try {
15674
15755
  const tagsResp = await this.eventBridgeClient.send(
15675
- new ListTagsForResourceCommand5({ ResourceARN: bus.Arn })
15756
+ new ListTagsForResourceCommand6({ ResourceARN: bus.Arn })
15676
15757
  );
15677
15758
  if (matchesCdkPath(tagsResp.Tags, input.cdkPath)) {
15678
15759
  return { physicalId: bus.Name, attributes: {} };
@@ -19505,7 +19586,7 @@ import {
19505
19586
  GetDistributionCommand,
19506
19587
  GetDistributionConfigCommand,
19507
19588
  ListDistributionsCommand,
19508
- ListTagsForResourceCommand as ListTagsForResourceCommand6,
19589
+ ListTagsForResourceCommand as ListTagsForResourceCommand7,
19509
19590
  NoSuchDistribution
19510
19591
  } from "@aws-sdk/client-cloudfront";
19511
19592
  init_aws_clients();
@@ -19941,7 +20022,7 @@ var CloudFrontDistributionProvider = class {
19941
20022
  continue;
19942
20023
  try {
19943
20024
  const tagsResp = await this.cloudFrontClient.send(
19944
- new ListTagsForResourceCommand6({ Resource: d.ARN })
20025
+ new ListTagsForResourceCommand7({ Resource: d.ARN })
19945
20026
  );
19946
20027
  if (matchesCdkPath(tagsResp.Tags?.Items, input.cdkPath)) {
19947
20028
  return { physicalId: d.Id, attributes: {} };
@@ -20227,6 +20308,8 @@ import {
20227
20308
  UpdateStateMachineCommand,
20228
20309
  DeleteStateMachineCommand,
20229
20310
  DescribeStateMachineCommand,
20311
+ ListStateMachinesCommand,
20312
+ ListTagsForResourceCommand as ListTagsForResourceCommand8,
20230
20313
  StateMachineDoesNotExist
20231
20314
  } from "@aws-sdk/client-sfn";
20232
20315
  var StepFunctionsProvider = class {
@@ -20409,6 +20492,67 @@ var StepFunctionsProvider = class {
20409
20492
  );
20410
20493
  }
20411
20494
  }
20495
+ /**
20496
+ * Adopt an existing Step Functions state machine into cdkd state.
20497
+ *
20498
+ * Lookup order:
20499
+ * 1. `--resource <id>=<arn>` override → verify with `DescribeStateMachine`.
20500
+ * 2. Walk `ListStateMachines` paginator → `ListTagsForResource(arn)`,
20501
+ * match the lowercase `key`/`value` `aws:cdk:path` tag (SFN uses
20502
+ * lowercase tags, so `matchesCdkPath` from import-helpers does not
20503
+ * apply directly).
20504
+ *
20505
+ * SFN state machines do not expose a template-supplied name field
20506
+ * usable as a stable physicalId — the physicalId is the ARN — so the
20507
+ * fallback to `Properties.<NameField>` in `resolveExplicitPhysicalId`
20508
+ * is skipped here.
20509
+ */
20510
+ async import(input) {
20511
+ if (input.knownPhysicalId) {
20512
+ try {
20513
+ await this.getClient().send(
20514
+ new DescribeStateMachineCommand({ stateMachineArn: input.knownPhysicalId })
20515
+ );
20516
+ return { physicalId: input.knownPhysicalId, attributes: {} };
20517
+ } catch (err) {
20518
+ if (err instanceof StateMachineDoesNotExist)
20519
+ return null;
20520
+ throw err;
20521
+ }
20522
+ }
20523
+ if (!input.cdkPath)
20524
+ return null;
20525
+ let nextToken;
20526
+ do {
20527
+ const list = await this.getClient().send(
20528
+ new ListStateMachinesCommand({ ...nextToken && { nextToken } })
20529
+ );
20530
+ for (const sm of list.stateMachines ?? []) {
20531
+ if (!sm.stateMachineArn)
20532
+ continue;
20533
+ const tagsResp = await this.getClient().send(
20534
+ new ListTagsForResourceCommand8({ resourceArn: sm.stateMachineArn })
20535
+ );
20536
+ if (this.tagsMatchCdkPath(tagsResp.tags, input.cdkPath)) {
20537
+ return { physicalId: sm.stateMachineArn, attributes: {} };
20538
+ }
20539
+ }
20540
+ nextToken = list.nextToken;
20541
+ } while (nextToken);
20542
+ return null;
20543
+ }
20544
+ /**
20545
+ * Match SFN's lowercase `key`/`value` tag shape against the CDK path.
20546
+ */
20547
+ tagsMatchCdkPath(tags, cdkPath) {
20548
+ if (!tags)
20549
+ return false;
20550
+ for (const t of tags) {
20551
+ if (t.key === CDK_PATH_TAG && t.value === cdkPath)
20552
+ return true;
20553
+ }
20554
+ return false;
20555
+ }
20412
20556
  /**
20413
20557
  * Build definition string from CDK properties.
20414
20558
  * Handles both DefinitionString (string) and DefinitionString (object) forms.
@@ -20448,7 +20592,7 @@ import {
20448
20592
  DescribeServicesCommand,
20449
20593
  ListClustersCommand,
20450
20594
  ListServicesCommand,
20451
- ListTagsForResourceCommand as ListTagsForResourceCommand7
20595
+ ListTagsForResourceCommand as ListTagsForResourceCommand9
20452
20596
  } from "@aws-sdk/client-ecs";
20453
20597
  function convertTags(tags) {
20454
20598
  if (!tags || tags.length === 0)
@@ -21226,7 +21370,7 @@ var ECSProvider = class {
21226
21370
  );
21227
21371
  for (const arn of list.clusterArns ?? []) {
21228
21372
  const tagsResp = await this.getClient().send(
21229
- new ListTagsForResourceCommand7({ resourceArn: arn })
21373
+ new ListTagsForResourceCommand9({ resourceArn: arn })
21230
21374
  );
21231
21375
  if (this.tagsMatchCdkPath(tagsResp.tags, input.cdkPath)) {
21232
21376
  const name = arn.substring(arn.lastIndexOf("/") + 1);
@@ -21259,7 +21403,7 @@ var ECSProvider = class {
21259
21403
  );
21260
21404
  for (const svcArn of svcList.serviceArns ?? []) {
21261
21405
  const tagsResp = await this.getClient().send(
21262
- new ListTagsForResourceCommand7({ resourceArn: svcArn })
21406
+ new ListTagsForResourceCommand9({ resourceArn: svcArn })
21263
21407
  );
21264
21408
  if (this.tagsMatchCdkPath(tagsResp.tags, input.cdkPath)) {
21265
21409
  const svcName = svcArn.substring(svcArn.lastIndexOf("/") + 1);
@@ -21311,6 +21455,7 @@ import {
21311
21455
  DeleteTargetGroupCommand,
21312
21456
  ModifyTargetGroupCommand,
21313
21457
  DescribeTargetGroupsCommand,
21458
+ DescribeTagsCommand,
21314
21459
  CreateListenerCommand,
21315
21460
  DeleteListenerCommand,
21316
21461
  ModifyListenerCommand
@@ -21806,6 +21951,107 @@ var ELBv2Provider = class {
21806
21951
  return void 0;
21807
21952
  return certificates;
21808
21953
  }
21954
+ /**
21955
+ * Adopt an existing ELBv2 LoadBalancer or TargetGroup into cdkd state.
21956
+ *
21957
+ * Lookup order:
21958
+ * 1. `--resource <id>=<arn>` override → verify with `DescribeLoadBalancers`
21959
+ * or `DescribeTargetGroups`.
21960
+ * 2. Walk `DescribeLoadBalancers` / `DescribeTargetGroups` paginators →
21961
+ * batch-fetch tags for each ARN with `DescribeTags(ResourceArns)`
21962
+ * and match `aws:cdk:path` (standard `Key`/`Value` Tag[] shape).
21963
+ *
21964
+ * Listener is not auto-importable (no template-supplied stable
21965
+ * identifier and no convenient tag-by-LB-context shortcut); use
21966
+ * `--resource <listenerId>=<arn>` for those.
21967
+ */
21968
+ async import(input) {
21969
+ switch (input.resourceType) {
21970
+ case "AWS::ElasticLoadBalancingV2::LoadBalancer":
21971
+ return this.importLoadBalancer(input);
21972
+ case "AWS::ElasticLoadBalancingV2::TargetGroup":
21973
+ return this.importTargetGroup(input);
21974
+ case "AWS::ElasticLoadBalancingV2::Listener":
21975
+ if (input.knownPhysicalId) {
21976
+ return { physicalId: input.knownPhysicalId, attributes: {} };
21977
+ }
21978
+ return null;
21979
+ default:
21980
+ return null;
21981
+ }
21982
+ }
21983
+ async importLoadBalancer(input) {
21984
+ if (input.knownPhysicalId) {
21985
+ try {
21986
+ const resp = await this.getClient().send(
21987
+ new DescribeLoadBalancersCommand2({ LoadBalancerArns: [input.knownPhysicalId] })
21988
+ );
21989
+ return resp.LoadBalancers?.[0]?.LoadBalancerArn ? { physicalId: resp.LoadBalancers[0].LoadBalancerArn, attributes: {} } : null;
21990
+ } catch (err) {
21991
+ if (this.isNotFoundError(err))
21992
+ return null;
21993
+ throw err;
21994
+ }
21995
+ }
21996
+ if (!input.cdkPath)
21997
+ return null;
21998
+ let marker;
21999
+ do {
22000
+ const list = await this.getClient().send(
22001
+ new DescribeLoadBalancersCommand2({ ...marker && { Marker: marker } })
22002
+ );
22003
+ const arns = (list.LoadBalancers ?? []).map((lb) => lb.LoadBalancerArn).filter((arn) => Boolean(arn));
22004
+ for (let i = 0; i < arns.length; i += 20) {
22005
+ const batch = arns.slice(i, i + 20);
22006
+ const tagsResp = await this.getClient().send(
22007
+ new DescribeTagsCommand({ ResourceArns: batch })
22008
+ );
22009
+ for (const td of tagsResp.TagDescriptions ?? []) {
22010
+ if (td.ResourceArn && matchesCdkPath(td.Tags, input.cdkPath)) {
22011
+ return { physicalId: td.ResourceArn, attributes: {} };
22012
+ }
22013
+ }
22014
+ }
22015
+ marker = list.NextMarker;
22016
+ } while (marker);
22017
+ return null;
22018
+ }
22019
+ async importTargetGroup(input) {
22020
+ if (input.knownPhysicalId) {
22021
+ try {
22022
+ const resp = await this.getClient().send(
22023
+ new DescribeTargetGroupsCommand({ TargetGroupArns: [input.knownPhysicalId] })
22024
+ );
22025
+ return resp.TargetGroups?.[0]?.TargetGroupArn ? { physicalId: resp.TargetGroups[0].TargetGroupArn, attributes: {} } : null;
22026
+ } catch (err) {
22027
+ if (this.isNotFoundError(err))
22028
+ return null;
22029
+ throw err;
22030
+ }
22031
+ }
22032
+ if (!input.cdkPath)
22033
+ return null;
22034
+ let marker;
22035
+ do {
22036
+ const list = await this.getClient().send(
22037
+ new DescribeTargetGroupsCommand({ ...marker && { Marker: marker } })
22038
+ );
22039
+ const arns = (list.TargetGroups ?? []).map((tg) => tg.TargetGroupArn).filter((arn) => Boolean(arn));
22040
+ for (let i = 0; i < arns.length; i += 20) {
22041
+ const batch = arns.slice(i, i + 20);
22042
+ const tagsResp = await this.getClient().send(
22043
+ new DescribeTagsCommand({ ResourceArns: batch })
22044
+ );
22045
+ for (const td of tagsResp.TagDescriptions ?? []) {
22046
+ if (td.ResourceArn && matchesCdkPath(td.Tags, input.cdkPath)) {
22047
+ return { physicalId: td.ResourceArn, attributes: {} };
22048
+ }
22049
+ }
22050
+ }
22051
+ marker = list.NextMarker;
22052
+ } while (marker);
22053
+ return null;
22054
+ }
21809
22055
  /**
21810
22056
  * Check if an error indicates the resource was not found
21811
22057
  */
@@ -21833,7 +22079,7 @@ import {
21833
22079
  DeleteDBSubnetGroupCommand,
21834
22080
  DescribeDBSubnetGroupsCommand,
21835
22081
  ModifyDBSubnetGroupCommand,
21836
- ListTagsForResourceCommand as ListTagsForResourceCommand8
22082
+ ListTagsForResourceCommand as ListTagsForResourceCommand10
21837
22083
  } from "@aws-sdk/client-rds";
21838
22084
  var RDSProvider = class {
21839
22085
  rdsClient;
@@ -22474,7 +22720,7 @@ var RDSProvider = class {
22474
22720
  if (!inst.DBInstanceIdentifier || !inst.DBInstanceArn)
22475
22721
  continue;
22476
22722
  const tagsResp = await this.getClient().send(
22477
- new ListTagsForResourceCommand8({ ResourceName: inst.DBInstanceArn })
22723
+ new ListTagsForResourceCommand10({ ResourceName: inst.DBInstanceArn })
22478
22724
  );
22479
22725
  if (matchesCdkPath(tagsResp.TagList, input.cdkPath)) {
22480
22726
  return { physicalId: inst.DBInstanceIdentifier, attributes: {} };
@@ -22509,7 +22755,7 @@ var RDSProvider = class {
22509
22755
  if (!c.DBClusterIdentifier || !c.DBClusterArn)
22510
22756
  continue;
22511
22757
  const tagsResp = await this.getClient().send(
22512
- new ListTagsForResourceCommand8({ ResourceName: c.DBClusterArn })
22758
+ new ListTagsForResourceCommand10({ ResourceName: c.DBClusterArn })
22513
22759
  );
22514
22760
  if (matchesCdkPath(tagsResp.TagList, input.cdkPath)) {
22515
22761
  return { physicalId: c.DBClusterIdentifier, attributes: {} };
@@ -22544,7 +22790,7 @@ var RDSProvider = class {
22544
22790
  if (!sg.DBSubnetGroupName || !sg.DBSubnetGroupArn)
22545
22791
  continue;
22546
22792
  const tagsResp = await this.getClient().send(
22547
- new ListTagsForResourceCommand8({ ResourceName: sg.DBSubnetGroupArn })
22793
+ new ListTagsForResourceCommand10({ ResourceName: sg.DBSubnetGroupArn })
22548
22794
  );
22549
22795
  if (matchesCdkPath(tagsResp.TagList, input.cdkPath)) {
22550
22796
  return { physicalId: sg.DBSubnetGroupName, attributes: {} };
@@ -22570,7 +22816,9 @@ import {
22570
22816
  CreateQueryLoggingConfigCommand,
22571
22817
  DeleteQueryLoggingConfigCommand,
22572
22818
  ListQueryLoggingConfigsCommand,
22573
- ListHostedZonesByNameCommand as ListHostedZonesByNameCommand2
22819
+ ListHostedZonesByNameCommand as ListHostedZonesByNameCommand2,
22820
+ ListHostedZonesCommand,
22821
+ ListTagsForResourceCommand as ListTagsForResourceCommand11
22574
22822
  } from "@aws-sdk/client-route-53";
22575
22823
  var Route53Provider = class {
22576
22824
  route53Client;
@@ -23217,6 +23465,69 @@ var Route53Provider = class {
23217
23465
  physicalId
23218
23466
  );
23219
23467
  }
23468
+ /**
23469
+ * Adopt an existing Route 53 resource into cdkd state.
23470
+ *
23471
+ * Supported types: `AWS::Route53::HostedZone` (full tag-based
23472
+ * lookup); `AWS::Route53::RecordSet` (override-only — RecordSets are
23473
+ * not taggable, and the composite child-of-zone identity makes auto
23474
+ * lookup impractical).
23475
+ */
23476
+ async import(input) {
23477
+ switch (input.resourceType) {
23478
+ case "AWS::Route53::HostedZone":
23479
+ return this.importHostedZone(input);
23480
+ case "AWS::Route53::RecordSet":
23481
+ if (input.knownPhysicalId) {
23482
+ return { physicalId: input.knownPhysicalId, attributes: {} };
23483
+ }
23484
+ return null;
23485
+ default:
23486
+ return null;
23487
+ }
23488
+ }
23489
+ async importHostedZone(input) {
23490
+ if (input.knownPhysicalId) {
23491
+ try {
23492
+ await this.getClient().send(new GetHostedZoneCommand2({ Id: input.knownPhysicalId }));
23493
+ return { physicalId: input.knownPhysicalId, attributes: {} };
23494
+ } catch (err) {
23495
+ if (err instanceof Error && err.name === "NoSuchHostedZone")
23496
+ return null;
23497
+ throw err;
23498
+ }
23499
+ }
23500
+ if (!input.cdkPath)
23501
+ return null;
23502
+ let marker;
23503
+ do {
23504
+ const list = await this.getClient().send(
23505
+ new ListHostedZonesCommand({ ...marker && { Marker: marker } })
23506
+ );
23507
+ for (const zone of list.HostedZones ?? []) {
23508
+ if (!zone.Id)
23509
+ continue;
23510
+ const zoneId = zone.Id.replace("/hostedzone/", "");
23511
+ try {
23512
+ const tagsResp = await this.getClient().send(
23513
+ new ListTagsForResourceCommand11({
23514
+ ResourceType: "hostedzone",
23515
+ ResourceId: zoneId
23516
+ })
23517
+ );
23518
+ if (matchesCdkPath(tagsResp.ResourceTagSet?.Tags, input.cdkPath)) {
23519
+ return { physicalId: zoneId, attributes: {} };
23520
+ }
23521
+ } catch (err) {
23522
+ if (err instanceof Error && err.name === "NoSuchHostedZone")
23523
+ continue;
23524
+ throw err;
23525
+ }
23526
+ }
23527
+ marker = list.IsTruncated ? list.NextMarker : void 0;
23528
+ } while (marker);
23529
+ return null;
23530
+ }
23220
23531
  };
23221
23532
 
23222
23533
  // src/provisioning/providers/wafv2-provider.ts
@@ -23226,6 +23537,8 @@ import {
23226
23537
  UpdateWebACLCommand,
23227
23538
  DeleteWebACLCommand,
23228
23539
  GetWebACLCommand,
23540
+ ListWebACLsCommand,
23541
+ ListTagsForResourceCommand as ListTagsForResourceCommand12,
23229
23542
  WAFNonexistentItemException
23230
23543
  } from "@aws-sdk/client-wafv2";
23231
23544
  function parseWebACLArn(arn) {
@@ -23440,6 +23753,54 @@ var WAFv2WebACLProvider = class {
23440
23753
  );
23441
23754
  }
23442
23755
  }
23756
+ /**
23757
+ * Adopt an existing WAFv2 WebACL into cdkd state.
23758
+ *
23759
+ * Lookup order:
23760
+ * 1. `--resource <id>=<arn>` override → verify with `GetWebACL` (parses
23761
+ * Name/Id/Scope back out of the ARN).
23762
+ * 2. Walk `ListWebACLs(Scope)` → match `aws:cdk:path` via
23763
+ * `ListTagsForResource(ResourceARN)` (returns
23764
+ * `TagInfoForResource.TagList`, standard `Key`/`Value` shape).
23765
+ *
23766
+ * `Scope` is required by `ListWebACLs` — read from
23767
+ * `Properties.Scope` (`REGIONAL` is the default).
23768
+ */
23769
+ async import(input) {
23770
+ if (input.knownPhysicalId) {
23771
+ try {
23772
+ const { id, name, scope: scope2 } = parseWebACLArn(input.knownPhysicalId);
23773
+ await this.getClient().send(new GetWebACLCommand({ Id: id, Name: name, Scope: scope2 }));
23774
+ return { physicalId: input.knownPhysicalId, attributes: {} };
23775
+ } catch (err) {
23776
+ if (err instanceof WAFNonexistentItemException)
23777
+ return null;
23778
+ throw err;
23779
+ }
23780
+ }
23781
+ if (!input.cdkPath)
23782
+ return null;
23783
+ const scope = input.properties["Scope"] || "REGIONAL";
23784
+ let nextMarker;
23785
+ do {
23786
+ const list = await this.getClient().send(
23787
+ new ListWebACLsCommand({ Scope: scope, ...nextMarker && { NextMarker: nextMarker } })
23788
+ );
23789
+ for (const item of list.WebACLs ?? []) {
23790
+ if (!item.ARN)
23791
+ continue;
23792
+ const tagsResp = await this.getClient().send(
23793
+ new ListTagsForResourceCommand12({ ResourceARN: item.ARN })
23794
+ );
23795
+ const tagList = tagsResp.TagInfoForResource?.TagList;
23796
+ if (matchesCdkPath(tagList, input.cdkPath)) {
23797
+ return { physicalId: item.ARN, attributes: {} };
23798
+ }
23799
+ }
23800
+ nextMarker = list.NextMarker;
23801
+ } while (nextMarker);
23802
+ return null;
23803
+ }
23443
23804
  };
23444
23805
 
23445
23806
  // src/provisioning/providers/cognito-provider.ts
@@ -23450,7 +23811,7 @@ import {
23450
23811
  UpdateUserPoolCommand,
23451
23812
  DescribeUserPoolCommand,
23452
23813
  ListUserPoolsCommand,
23453
- ListTagsForResourceCommand as ListTagsForResourceCommand9,
23814
+ ListTagsForResourceCommand as ListTagsForResourceCommand13,
23454
23815
  ResourceNotFoundException as ResourceNotFoundException12
23455
23816
  } from "@aws-sdk/client-cognito-identity-provider";
23456
23817
  var CognitoUserPoolProvider = class {
@@ -23835,7 +24196,7 @@ var CognitoUserPoolProvider = class {
23835
24196
  if (!arn)
23836
24197
  continue;
23837
24198
  const tagsResp = await this.getClient().send(
23838
- new ListTagsForResourceCommand9({ ResourceArn: arn })
24199
+ new ListTagsForResourceCommand13({ ResourceArn: arn })
23839
24200
  );
23840
24201
  if (tagsResp.Tags?.[CDK_PATH_TAG] === input.cdkPath) {
23841
24202
  return { physicalId: pool.Id, attributes: {} };
@@ -23859,13 +24220,18 @@ import {
23859
24220
  CreateCacheClusterCommand,
23860
24221
  DeleteCacheClusterCommand,
23861
24222
  DescribeCacheClustersCommand,
24223
+ DescribeCacheSubnetGroupsCommand,
23862
24224
  CreateCacheSubnetGroupCommand,
23863
24225
  DeleteCacheSubnetGroupCommand,
23864
24226
  ModifyCacheSubnetGroupCommand,
23865
- ModifyCacheClusterCommand
24227
+ ModifyCacheClusterCommand,
24228
+ ListTagsForResourceCommand as ListTagsForResourceCommand14
23866
24229
  } from "@aws-sdk/client-elasticache";
24230
+ import { STSClient as STSClient5, GetCallerIdentityCommand as GetCallerIdentityCommand6 } from "@aws-sdk/client-sts";
23867
24231
  var ElastiCacheProvider = class {
23868
24232
  client;
24233
+ stsClient;
24234
+ cachedAccountId;
23869
24235
  providerRegion = process.env["AWS_REGION"];
23870
24236
  logger = getLogger().child("ElastiCacheProvider");
23871
24237
  handledProperties = /* @__PURE__ */ new Map([
@@ -24267,6 +24633,132 @@ var ElastiCacheProvider = class {
24267
24633
  sleep(ms) {
24268
24634
  return new Promise((resolve4) => setTimeout(resolve4, ms));
24269
24635
  }
24636
+ /**
24637
+ * Adopt an existing ElastiCache resource into cdkd state.
24638
+ *
24639
+ * Supported types:
24640
+ * - `AWS::ElastiCache::CacheCluster` — full tag-based lookup via
24641
+ * `DescribeCacheClusters` + `ListTagsForResource(ResourceName=arn)`.
24642
+ * - `AWS::ElastiCache::SubnetGroup` — full tag-based lookup via
24643
+ * `DescribeCacheSubnetGroups` + `ListTagsForResource(ResourceName=arn)`.
24644
+ *
24645
+ * `ListTagsForResource` requires an ARN. Both `CacheCluster.ARN` and
24646
+ * `CacheSubnetGroup.ARN` are returned by the Describe APIs, so no
24647
+ * extra reconstruction is needed in normal flow; for the explicit
24648
+ * override path we build the ARN from `region` + STS account id +
24649
+ * the resource name.
24650
+ */
24651
+ async import(input) {
24652
+ switch (input.resourceType) {
24653
+ case "AWS::ElastiCache::CacheCluster":
24654
+ return this.importCacheCluster(input);
24655
+ case "AWS::ElastiCache::SubnetGroup":
24656
+ return this.importSubnetGroup(input);
24657
+ default:
24658
+ return null;
24659
+ }
24660
+ }
24661
+ async importCacheCluster(input) {
24662
+ const explicit = resolveExplicitPhysicalId(input, "ClusterName");
24663
+ if (explicit) {
24664
+ try {
24665
+ const resp = await this.getClient().send(
24666
+ new DescribeCacheClustersCommand({ CacheClusterId: explicit })
24667
+ );
24668
+ const c = resp.CacheClusters?.[0];
24669
+ return c?.CacheClusterId ? { physicalId: c.CacheClusterId, attributes: {} } : null;
24670
+ } catch (err) {
24671
+ if (this.isNotFoundError(err, "CacheClusterNotFoundFault"))
24672
+ return null;
24673
+ throw err;
24674
+ }
24675
+ }
24676
+ if (!input.cdkPath)
24677
+ return null;
24678
+ let marker;
24679
+ do {
24680
+ const list = await this.getClient().send(
24681
+ new DescribeCacheClustersCommand({ ...marker && { Marker: marker } })
24682
+ );
24683
+ for (const c of list.CacheClusters ?? []) {
24684
+ if (!c.CacheClusterId)
24685
+ continue;
24686
+ const arn = c.ARN ?? await this.buildClusterArn(c.CacheClusterId);
24687
+ const tagsResp = await this.getClient().send(
24688
+ new ListTagsForResourceCommand14({ ResourceName: arn })
24689
+ );
24690
+ if (matchesCdkPath(tagsResp.TagList, input.cdkPath)) {
24691
+ return { physicalId: c.CacheClusterId, attributes: {} };
24692
+ }
24693
+ }
24694
+ marker = list.Marker;
24695
+ } while (marker);
24696
+ return null;
24697
+ }
24698
+ async importSubnetGroup(input) {
24699
+ const explicit = resolveExplicitPhysicalId(input, "CacheSubnetGroupName");
24700
+ if (explicit) {
24701
+ try {
24702
+ const resp = await this.getClient().send(
24703
+ new DescribeCacheSubnetGroupsCommand({ CacheSubnetGroupName: explicit })
24704
+ );
24705
+ const g = resp.CacheSubnetGroups?.[0];
24706
+ return g?.CacheSubnetGroupName ? { physicalId: g.CacheSubnetGroupName, attributes: {} } : null;
24707
+ } catch (err) {
24708
+ if (this.isNotFoundError(err, "CacheSubnetGroupNotFoundFault"))
24709
+ return null;
24710
+ throw err;
24711
+ }
24712
+ }
24713
+ if (!input.cdkPath)
24714
+ return null;
24715
+ let marker;
24716
+ do {
24717
+ const list = await this.getClient().send(
24718
+ new DescribeCacheSubnetGroupsCommand({ ...marker && { Marker: marker } })
24719
+ );
24720
+ for (const g of list.CacheSubnetGroups ?? []) {
24721
+ if (!g.CacheSubnetGroupName)
24722
+ continue;
24723
+ const arn = g.ARN ?? await this.buildSubnetGroupArn(g.CacheSubnetGroupName);
24724
+ const tagsResp = await this.getClient().send(
24725
+ new ListTagsForResourceCommand14({ ResourceName: arn })
24726
+ );
24727
+ if (matchesCdkPath(tagsResp.TagList, input.cdkPath)) {
24728
+ return { physicalId: g.CacheSubnetGroupName, attributes: {} };
24729
+ }
24730
+ }
24731
+ marker = list.Marker;
24732
+ } while (marker);
24733
+ return null;
24734
+ }
24735
+ async buildClusterArn(clusterName) {
24736
+ const region = await this.getRegion();
24737
+ const account = await this.getAccountId();
24738
+ return `arn:aws:elasticache:${region}:${account}:cluster:${clusterName}`;
24739
+ }
24740
+ async buildSubnetGroupArn(subnetGroupName) {
24741
+ const region = await this.getRegion();
24742
+ const account = await this.getAccountId();
24743
+ return `arn:aws:elasticache:${region}:${account}:subnetgroup:${subnetGroupName}`;
24744
+ }
24745
+ async getRegion() {
24746
+ const region = await this.getClient().config.region();
24747
+ return region || this.providerRegion || "us-east-1";
24748
+ }
24749
+ async getAccountId() {
24750
+ if (this.cachedAccountId)
24751
+ return this.cachedAccountId;
24752
+ if (!this.stsClient) {
24753
+ this.stsClient = new STSClient5(this.providerRegion ? { region: this.providerRegion } : {});
24754
+ }
24755
+ const identity = await this.stsClient.send(new GetCallerIdentityCommand6({}));
24756
+ if (!identity.Account) {
24757
+ throw new Error("Failed to resolve AWS account id from STS");
24758
+ }
24759
+ this.cachedAccountId = identity.Account;
24760
+ return this.cachedAccountId;
24761
+ }
24270
24762
  };
24271
24763
 
24272
24764
  // src/provisioning/providers/servicediscovery-provider.ts
@@ -24280,7 +24772,7 @@ import {
24280
24772
  NamespaceNotFound,
24281
24773
  ServiceNotFound
24282
24774
  } from "@aws-sdk/client-servicediscovery";
24283
- import { STSClient as STSClient5, GetCallerIdentityCommand as GetCallerIdentityCommand6 } from "@aws-sdk/client-sts";
24775
+ import { STSClient as STSClient6, GetCallerIdentityCommand as GetCallerIdentityCommand7 } from "@aws-sdk/client-sts";
24284
24776
  var ServiceDiscoveryProvider = class {
24285
24777
  client;
24286
24778
  stsClient;
@@ -24312,7 +24804,7 @@ var ServiceDiscoveryProvider = class {
24312
24804
  }
24313
24805
  getStsClient() {
24314
24806
  if (!this.stsClient) {
24315
- this.stsClient = new STSClient5(this.providerRegion ? { region: this.providerRegion } : {});
24807
+ this.stsClient = new STSClient6(this.providerRegion ? { region: this.providerRegion } : {});
24316
24808
  }
24317
24809
  return this.stsClient;
24318
24810
  }
@@ -24603,7 +25095,7 @@ var ServiceDiscoveryProvider = class {
24603
25095
  */
24604
25096
  async buildNamespaceArn(namespaceId) {
24605
25097
  const stsClient = this.getStsClient();
24606
- const identity = await stsClient.send(new GetCallerIdentityCommand6({}));
25098
+ const identity = await stsClient.send(new GetCallerIdentityCommand7({}));
24607
25099
  const accountId = identity.Account || "";
24608
25100
  const region = await this.getClient().config.region();
24609
25101
  return `arn:aws:servicediscovery:${region}:${accountId}:namespace/${namespaceId}`;
@@ -25187,10 +25679,18 @@ import {
25187
25679
  CreateTableCommand as CreateTableCommand2,
25188
25680
  UpdateTableCommand,
25189
25681
  DeleteTableCommand as DeleteTableCommand2,
25682
+ GetDatabaseCommand,
25683
+ GetDatabasesCommand,
25684
+ GetTableCommand,
25685
+ GetTablesCommand,
25686
+ GetTagsCommand,
25190
25687
  EntityNotFoundException
25191
25688
  } from "@aws-sdk/client-glue";
25689
+ import { STSClient as STSClient7, GetCallerIdentityCommand as GetCallerIdentityCommand8 } from "@aws-sdk/client-sts";
25192
25690
  var GlueProvider = class {
25193
25691
  client;
25692
+ stsClient;
25693
+ cachedAccountId;
25194
25694
  providerRegion = process.env["AWS_REGION"];
25195
25695
  logger = getLogger().child("GlueProvider");
25196
25696
  handledProperties = /* @__PURE__ */ new Map([
@@ -25561,6 +26061,167 @@ var GlueProvider = class {
25561
26061
  }
25562
26062
  return result;
25563
26063
  }
26064
+ /**
26065
+ * Adopt an existing Glue Database or Table into cdkd state.
26066
+ *
26067
+ * Lookup order (per type):
26068
+ * 1. Explicit override / template name → verify with `GetDatabase`
26069
+ * or `GetTable`.
26070
+ * 2. Walk `GetDatabases` / `GetTables` paginators and match the
26071
+ * `aws:cdk:path` tag via `GetTags(ResourceArn)`. Glue tags are
26072
+ * a `Record<string,string>` map (not a `Tag[]` array), so the
26073
+ * match is `tags?.[CDK_PATH_TAG] === input.cdkPath`.
26074
+ *
26075
+ * Glue list APIs return only names — ARNs are constructed locally
26076
+ * for the per-item GetTags call.
26077
+ */
26078
+ async import(input) {
26079
+ switch (input.resourceType) {
26080
+ case "AWS::Glue::Database":
26081
+ return this.importDatabase(input);
26082
+ case "AWS::Glue::Table":
26083
+ return this.importTable(input);
26084
+ default:
26085
+ return null;
26086
+ }
26087
+ }
26088
+ async importDatabase(input) {
26089
+ const explicitName = input.knownPhysicalId ?? input.properties["DatabaseInput"]?.["Name"];
26090
+ const catalogId = input.properties["CatalogId"];
26091
+ if (explicitName) {
26092
+ try {
26093
+ await this.getClient().send(
26094
+ new GetDatabaseCommand({ Name: explicitName, ...catalogId && { CatalogId: catalogId } })
26095
+ );
26096
+ return { physicalId: explicitName, attributes: {} };
26097
+ } catch (err) {
26098
+ if (err instanceof EntityNotFoundException)
26099
+ return null;
26100
+ throw err;
26101
+ }
26102
+ }
26103
+ if (!input.cdkPath)
26104
+ return null;
26105
+ let nextToken;
26106
+ do {
26107
+ const list = await this.getClient().send(
26108
+ new GetDatabasesCommand({
26109
+ ...nextToken && { NextToken: nextToken },
26110
+ ...catalogId && { CatalogId: catalogId }
26111
+ })
26112
+ );
26113
+ for (const db of list.DatabaseList ?? []) {
26114
+ if (!db.Name)
26115
+ continue;
26116
+ const arn = await this.buildDatabaseArn(db.Name, db.CatalogId);
26117
+ if (await this.tagsMatchCdkPath(arn, input.cdkPath)) {
26118
+ return { physicalId: db.Name, attributes: {} };
26119
+ }
26120
+ }
26121
+ nextToken = list.NextToken;
26122
+ } while (nextToken);
26123
+ return null;
26124
+ }
26125
+ async importTable(input) {
26126
+ const databaseName = input.properties["DatabaseName"];
26127
+ const tableInput = input.properties["TableInput"];
26128
+ const templateTableName = tableInput?.["Name"];
26129
+ const catalogId = input.properties["CatalogId"];
26130
+ if (input.knownPhysicalId) {
26131
+ const [dbName, tName] = input.knownPhysicalId.split("|");
26132
+ if (!dbName || !tName)
26133
+ return null;
26134
+ try {
26135
+ await this.getClient().send(
26136
+ new GetTableCommand({
26137
+ DatabaseName: dbName,
26138
+ Name: tName,
26139
+ ...catalogId && { CatalogId: catalogId }
26140
+ })
26141
+ );
26142
+ return { physicalId: input.knownPhysicalId, attributes: {} };
26143
+ } catch (err) {
26144
+ if (err instanceof EntityNotFoundException)
26145
+ return null;
26146
+ throw err;
26147
+ }
26148
+ }
26149
+ if (databaseName && templateTableName) {
26150
+ try {
26151
+ await this.getClient().send(
26152
+ new GetTableCommand({
26153
+ DatabaseName: databaseName,
26154
+ Name: templateTableName,
26155
+ ...catalogId && { CatalogId: catalogId }
26156
+ })
26157
+ );
26158
+ return { physicalId: `${databaseName}|${templateTableName}`, attributes: {} };
26159
+ } catch (err) {
26160
+ if (err instanceof EntityNotFoundException)
26161
+ return null;
26162
+ throw err;
26163
+ }
26164
+ }
26165
+ if (!input.cdkPath || !databaseName)
26166
+ return null;
26167
+ let nextToken;
26168
+ do {
26169
+ const list = await this.getClient().send(
26170
+ new GetTablesCommand({
26171
+ DatabaseName: databaseName,
26172
+ ...nextToken && { NextToken: nextToken },
26173
+ ...catalogId && { CatalogId: catalogId }
26174
+ })
26175
+ );
26176
+ for (const t of list.TableList ?? []) {
26177
+ if (!t.Name)
26178
+ continue;
26179
+ const arn = await this.buildTableArn(databaseName, t.Name, catalogId);
26180
+ if (await this.tagsMatchCdkPath(arn, input.cdkPath)) {
26181
+ return { physicalId: `${databaseName}|${t.Name}`, attributes: {} };
26182
+ }
26183
+ }
26184
+ nextToken = list.NextToken;
26185
+ } while (nextToken);
26186
+ return null;
26187
+ }
26188
+ async tagsMatchCdkPath(arn, cdkPath) {
26189
+ try {
26190
+ const resp = await this.getClient().send(new GetTagsCommand({ ResourceArn: arn }));
26191
+ return resp.Tags?.[CDK_PATH_TAG] === cdkPath;
26192
+ } catch (err) {
26193
+ if (err instanceof EntityNotFoundException)
26194
+ return false;
26195
+ throw err;
26196
+ }
26197
+ }
26198
+ async buildDatabaseArn(databaseName, catalogId) {
26199
+ const region = await this.getRegion();
26200
+ const account = catalogId ?? await this.getAccountId();
26201
+ return `arn:aws:glue:${region}:${account}:database/${databaseName}`;
26202
+ }
26203
+ async buildTableArn(databaseName, tableName, catalogId) {
26204
+ const region = await this.getRegion();
26205
+ const account = catalogId ?? await this.getAccountId();
26206
+ return `arn:aws:glue:${region}:${account}:table/${databaseName}/${tableName}`;
26207
+ }
26208
+ async getRegion() {
26209
+ const region = await this.getClient().config.region();
26210
+ return region || this.providerRegion || "us-east-1";
26211
+ }
26212
+ async getAccountId() {
26213
+ if (this.cachedAccountId)
26214
+ return this.cachedAccountId;
26215
+ if (!this.stsClient) {
26216
+ this.stsClient = new STSClient7(this.providerRegion ? { region: this.providerRegion } : {});
26217
+ }
26218
+ const identity = await this.stsClient.send(new GetCallerIdentityCommand8({}));
26219
+ if (!identity.Account) {
26220
+ throw new Error("Failed to resolve AWS account id from STS");
26221
+ }
26222
+ this.cachedAccountId = identity.Account;
26223
+ return this.cachedAccountId;
26224
+ }
25564
26225
  };
25565
26226
 
25566
26227
  // src/provisioning/providers/kms-provider.ts
@@ -26042,6 +26703,8 @@ import {
26042
26703
  DecreaseStreamRetentionPeriodCommand,
26043
26704
  StartStreamEncryptionCommand,
26044
26705
  StopStreamEncryptionCommand,
26706
+ ListStreamsCommand,
26707
+ ListTagsForStreamCommand,
26045
26708
  ResourceNotFoundException as ResourceNotFoundException13
26046
26709
  } from "@aws-sdk/client-kinesis";
26047
26710
  var KinesisStreamProvider = class {
@@ -26294,6 +26957,54 @@ var KinesisStreamProvider = class {
26294
26957
  );
26295
26958
  }
26296
26959
  }
26960
+ /**
26961
+ * Adopt an existing Kinesis stream into cdkd state.
26962
+ *
26963
+ * Lookup order:
26964
+ * 1. `--resource <id>=<name>` override or `Properties.Name` → verify
26965
+ * with `DescribeStream`.
26966
+ * 2. Walk `ListStreams` (paged via `ExclusiveStartStreamName`) and
26967
+ * match the `aws:cdk:path` tag via `ListTagsForStream(StreamName)`.
26968
+ *
26969
+ * Kinesis tags use the standard `Tag[]` array shape (`Key`/`Value`),
26970
+ * so `matchesCdkPath` from import-helpers applies directly.
26971
+ */
26972
+ async import(input) {
26973
+ const explicit = resolveExplicitPhysicalId(input, "Name");
26974
+ if (explicit) {
26975
+ try {
26976
+ await this.getClient().send(new DescribeStreamCommand({ StreamName: explicit }));
26977
+ return { physicalId: explicit, attributes: {} };
26978
+ } catch (err) {
26979
+ if (err instanceof ResourceNotFoundException13)
26980
+ return null;
26981
+ throw err;
26982
+ }
26983
+ }
26984
+ if (!input.cdkPath)
26985
+ return null;
26986
+ let exclusiveStartStreamName;
26987
+ while (true) {
26988
+ const list = await this.getClient().send(
26989
+ new ListStreamsCommand({
26990
+ ...exclusiveStartStreamName && { ExclusiveStartStreamName: exclusiveStartStreamName }
26991
+ })
26992
+ );
26993
+ const names = list.StreamNames ?? [];
26994
+ for (const streamName of names) {
26995
+ const tagsResp = await this.getClient().send(
26996
+ new ListTagsForStreamCommand({ StreamName: streamName })
26997
+ );
26998
+ if (matchesCdkPath(tagsResp.Tags, input.cdkPath)) {
26999
+ return { physicalId: streamName, attributes: {} };
27000
+ }
27001
+ }
27002
+ if (!list.HasMoreStreams || names.length === 0)
27003
+ break;
27004
+ exclusiveStartStreamName = names[names.length - 1];
27005
+ }
27006
+ return null;
27007
+ }
26297
27008
  /**
26298
27009
  * Poll DescribeStream until the stream reaches ACTIVE status
26299
27010
  *
@@ -26336,6 +27047,7 @@ import {
26336
27047
  CreateAccessPointCommand,
26337
27048
  DeleteAccessPointCommand,
26338
27049
  DescribeFileSystemsCommand,
27050
+ DescribeAccessPointsCommand,
26339
27051
  FileSystemNotFound,
26340
27052
  MountTargetNotFound,
26341
27053
  AccessPointNotFound
@@ -26737,6 +27449,100 @@ var EFSProvider = class {
26737
27449
  );
26738
27450
  }
26739
27451
  }
27452
+ /**
27453
+ * Adopt an existing EFS resource into cdkd state.
27454
+ *
27455
+ * Supported types:
27456
+ * - `AWS::EFS::FileSystem` — full tag-based lookup via
27457
+ * `DescribeFileSystems` with `Tags` inline on each item.
27458
+ * - `AWS::EFS::AccessPoint` — full tag-based lookup via
27459
+ * `DescribeAccessPoints` with `Tags` inline on each item.
27460
+ * - `AWS::EFS::MountTarget` — override-only (mount targets are
27461
+ * not taggable; auto lookup is impractical).
27462
+ */
27463
+ async import(input) {
27464
+ switch (input.resourceType) {
27465
+ case "AWS::EFS::FileSystem":
27466
+ return this.importFileSystem(input);
27467
+ case "AWS::EFS::AccessPoint":
27468
+ return this.importAccessPoint(input);
27469
+ case "AWS::EFS::MountTarget":
27470
+ if (input.knownPhysicalId) {
27471
+ return { physicalId: input.knownPhysicalId, attributes: {} };
27472
+ }
27473
+ return null;
27474
+ default:
27475
+ return null;
27476
+ }
27477
+ }
27478
+ async importFileSystem(input) {
27479
+ if (input.knownPhysicalId) {
27480
+ try {
27481
+ const resp = await this.getClient().send(
27482
+ new DescribeFileSystemsCommand({ FileSystemId: input.knownPhysicalId })
27483
+ );
27484
+ const fs = resp.FileSystems?.[0];
27485
+ return fs?.FileSystemId ? { physicalId: fs.FileSystemId, attributes: {} } : null;
27486
+ } catch (err) {
27487
+ if (err instanceof FileSystemNotFound)
27488
+ return null;
27489
+ throw err;
27490
+ }
27491
+ }
27492
+ if (!input.cdkPath)
27493
+ return null;
27494
+ let marker;
27495
+ do {
27496
+ const list = await this.getClient().send(
27497
+ new DescribeFileSystemsCommand({ ...marker && { Marker: marker } })
27498
+ );
27499
+ for (const fs of list.FileSystems ?? []) {
27500
+ if (!fs.FileSystemId)
27501
+ continue;
27502
+ if (matchesCdkPath(fs.Tags, input.cdkPath)) {
27503
+ return { physicalId: fs.FileSystemId, attributes: {} };
27504
+ }
27505
+ }
27506
+ marker = list.NextMarker;
27507
+ } while (marker);
27508
+ return null;
27509
+ }
27510
+ async importAccessPoint(input) {
27511
+ if (input.knownPhysicalId) {
27512
+ try {
27513
+ const resp = await this.getClient().send(
27514
+ new DescribeAccessPointsCommand({ AccessPointId: input.knownPhysicalId })
27515
+ );
27516
+ const ap = resp.AccessPoints?.[0];
27517
+ return ap?.AccessPointId ? { physicalId: ap.AccessPointId, attributes: {} } : null;
27518
+ } catch (err) {
27519
+ if (err instanceof AccessPointNotFound)
27520
+ return null;
27521
+ throw err;
27522
+ }
27523
+ }
27524
+ if (!input.cdkPath)
27525
+ return null;
27526
+ const fileSystemId = input.properties["FileSystemId"];
27527
+ let nextToken;
27528
+ do {
27529
+ const list = await this.getClient().send(
27530
+ new DescribeAccessPointsCommand({
27531
+ ...nextToken && { NextToken: nextToken },
27532
+ ...fileSystemId && { FileSystemId: fileSystemId }
27533
+ })
27534
+ );
27535
+ for (const ap of list.AccessPoints ?? []) {
27536
+ if (!ap.AccessPointId)
27537
+ continue;
27538
+ if (matchesCdkPath(ap.Tags, input.cdkPath)) {
27539
+ return { physicalId: ap.AccessPointId, attributes: {} };
27540
+ }
27541
+ }
27542
+ nextToken = list.NextToken;
27543
+ } while (nextToken);
27544
+ return null;
27545
+ }
26740
27546
  };
26741
27547
 
26742
27548
  // src/provisioning/providers/firehose-provider.ts
@@ -26744,6 +27550,9 @@ import {
26744
27550
  FirehoseClient,
26745
27551
  CreateDeliveryStreamCommand,
26746
27552
  DeleteDeliveryStreamCommand,
27553
+ DescribeDeliveryStreamCommand,
27554
+ ListDeliveryStreamsCommand,
27555
+ ListTagsForDeliveryStreamCommand,
26747
27556
  ResourceNotFoundException as ResourceNotFoundException14
26748
27557
  } from "@aws-sdk/client-firehose";
26749
27558
  var FirehoseProvider = class {
@@ -27080,12 +27889,63 @@ var FirehoseProvider = class {
27080
27889
  }
27081
27890
  return result;
27082
27891
  }
27892
+ /**
27893
+ * Adopt an existing Kinesis Firehose delivery stream into cdkd state.
27894
+ *
27895
+ * Lookup order:
27896
+ * 1. `--resource <id>=<name>` override or `Properties.DeliveryStreamName`
27897
+ * → verify with `DescribeDeliveryStream`.
27898
+ * 2. Walk `ListDeliveryStreams` (paged via `ExclusiveStartDeliveryStreamName`)
27899
+ * and match the `aws:cdk:path` tag via
27900
+ * `ListTagsForDeliveryStream(DeliveryStreamName)`.
27901
+ *
27902
+ * Firehose tags use the standard `Tag[]` array shape (`Key`/`Value`).
27903
+ */
27904
+ async import(input) {
27905
+ const explicit = resolveExplicitPhysicalId(input, "DeliveryStreamName");
27906
+ if (explicit) {
27907
+ try {
27908
+ await this.getClient().send(
27909
+ new DescribeDeliveryStreamCommand({ DeliveryStreamName: explicit })
27910
+ );
27911
+ return { physicalId: explicit, attributes: {} };
27912
+ } catch (err) {
27913
+ if (err instanceof ResourceNotFoundException14)
27914
+ return null;
27915
+ throw err;
27916
+ }
27917
+ }
27918
+ if (!input.cdkPath)
27919
+ return null;
27920
+ let exclusiveStartDeliveryStreamName;
27921
+ while (true) {
27922
+ const list = await this.getClient().send(
27923
+ new ListDeliveryStreamsCommand({
27924
+ ...exclusiveStartDeliveryStreamName && {
27925
+ ExclusiveStartDeliveryStreamName: exclusiveStartDeliveryStreamName
27926
+ }
27927
+ })
27928
+ );
27929
+ const names = list.DeliveryStreamNames ?? [];
27930
+ for (const name of names) {
27931
+ const tagsResp = await this.getClient().send(
27932
+ new ListTagsForDeliveryStreamCommand({ DeliveryStreamName: name })
27933
+ );
27934
+ if (matchesCdkPath(tagsResp.Tags, input.cdkPath)) {
27935
+ return { physicalId: name, attributes: {} };
27936
+ }
27937
+ }
27938
+ if (!list.HasMoreDeliveryStreams || names.length === 0)
27939
+ break;
27940
+ exclusiveStartDeliveryStreamName = names[names.length - 1];
27941
+ }
27942
+ return null;
27943
+ }
27083
27944
  /**
27084
27945
  * Wait for a delivery stream to become ACTIVE.
27085
27946
  * Firehose CreateDeliveryStream returns immediately while the stream is still CREATING.
27086
27947
  */
27087
27948
  async waitForActive(streamName, logicalId) {
27088
- const { DescribeDeliveryStreamCommand } = await import("@aws-sdk/client-firehose");
27089
27949
  const maxAttempts = 30;
27090
27950
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
27091
27951
  const resp = await this.getClient().send(
@@ -27893,7 +28753,7 @@ import {
27893
28753
  ListObjectsV2Command as ListObjectsV2Command2,
27894
28754
  DeleteObjectsCommand as DeleteObjectsCommand2
27895
28755
  } from "@aws-sdk/client-s3";
27896
- import { GetCallerIdentityCommand as GetCallerIdentityCommand7 } from "@aws-sdk/client-sts";
28756
+ import { GetCallerIdentityCommand as GetCallerIdentityCommand9 } from "@aws-sdk/client-sts";
27897
28757
  import { EC2Client as EC2Client8, DescribeAvailabilityZonesCommand as DescribeAvailabilityZonesCommand3 } from "@aws-sdk/client-ec2";
27898
28758
  init_aws_clients();
27899
28759
  var S3DirectoryBucketProvider = class {
@@ -27949,7 +28809,7 @@ var S3DirectoryBucketProvider = class {
27949
28809
  * Get the AWS account ID via STS
27950
28810
  */
27951
28811
  async getAccountId() {
27952
- const identity = await this.stsClient.send(new GetCallerIdentityCommand7({}));
28812
+ const identity = await this.stsClient.send(new GetCallerIdentityCommand9({}));
27953
28813
  return identity.Account;
27954
28814
  }
27955
28815
  /**
@@ -28504,7 +29364,7 @@ import {
28504
29364
  PutImageScanningConfigurationCommand,
28505
29365
  PutImageTagMutabilityCommand,
28506
29366
  TagResourceCommand as TagResourceCommand7,
28507
- ListTagsForResourceCommand as ListTagsForResourceCommand10,
29367
+ ListTagsForResourceCommand as ListTagsForResourceCommand15,
28508
29368
  RepositoryNotFoundException
28509
29369
  } from "@aws-sdk/client-ecr";
28510
29370
  var ECRProvider = class {
@@ -28773,7 +29633,7 @@ var ECRProvider = class {
28773
29633
  continue;
28774
29634
  try {
28775
29635
  const tagsResp = await this.getClient().send(
28776
- new ListTagsForResourceCommand10({ resourceArn: repo.repositoryArn })
29636
+ new ListTagsForResourceCommand15({ resourceArn: repo.repositoryArn })
28777
29637
  );
28778
29638
  if (matchesCdkPath(tagsResp.tags, input.cdkPath)) {
28779
29639
  return { physicalId: repo.repositoryName, attributes: {} };
@@ -30301,11 +31161,11 @@ async function deployCommand(stacks, options) {
30301
31161
  addDependencies(stack.stackName);
30302
31162
  }
30303
31163
  }
30304
- const { STSClient: STSClient7, GetCallerIdentityCommand: GetCallerIdentityCommand9 } = await import("@aws-sdk/client-sts");
30305
- const stsClient = new STSClient7({
31164
+ const { STSClient: STSClient9, GetCallerIdentityCommand: GetCallerIdentityCommand11 } = await import("@aws-sdk/client-sts");
31165
+ const stsClient = new STSClient9({
30306
31166
  region: options.region || process.env["AWS_REGION"] || "us-east-1"
30307
31167
  });
30308
- const callerIdentity = await stsClient.send(new GetCallerIdentityCommand9({}));
31168
+ const callerIdentity = await stsClient.send(new GetCallerIdentityCommand11({}));
30309
31169
  const accountId = callerIdentity.Account;
30310
31170
  stsClient.destroy();
30311
31171
  const assetPublisher = new AssetPublisher();
@@ -31358,7 +32218,7 @@ import {
31358
32218
  PutBucketVersioningCommand as PutBucketVersioningCommand3,
31359
32219
  S3Client as S3Client10
31360
32220
  } from "@aws-sdk/client-s3";
31361
- import { GetCallerIdentityCommand as GetCallerIdentityCommand8 } from "@aws-sdk/client-sts";
32221
+ import { GetCallerIdentityCommand as GetCallerIdentityCommand10 } from "@aws-sdk/client-sts";
31362
32222
  init_aws_clients();
31363
32223
  async function stateMigrateCommand(options) {
31364
32224
  const logger = getLogger();
@@ -31371,7 +32231,7 @@ async function stateMigrateCommand(options) {
31371
32231
  });
31372
32232
  setAwsClients(awsClients);
31373
32233
  try {
31374
- const identity = await awsClients.sts.send(new GetCallerIdentityCommand8({}));
32234
+ const identity = await awsClients.sts.send(new GetCallerIdentityCommand10({}));
31375
32235
  const accountId = identity.Account;
31376
32236
  if (!accountId) {
31377
32237
  throw new Error("STS GetCallerIdentity returned no Account id.");
@@ -32699,7 +33559,7 @@ function reorderArgs(argv) {
32699
33559
  }
32700
33560
  async function main() {
32701
33561
  const program = new Command13();
32702
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.19.0");
33562
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.20.0");
32703
33563
  program.addCommand(createBootstrapCommand());
32704
33564
  program.addCommand(createSynthCommand());
32705
33565
  program.addCommand(createListCommand());