@go-to-k/cdkd 0.16.1 → 0.17.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
@@ -7766,13 +7766,15 @@ import {
7766
7766
  init_aws_clients();
7767
7767
 
7768
7768
  // src/provisioning/resource-name.ts
7769
+ import { AsyncLocalStorage } from "node:async_hooks";
7769
7770
  import { createHash } from "node:crypto";
7770
- var currentStackName;
7771
- function setCurrentStackName(stackName) {
7772
- currentStackName = stackName;
7771
+ var stackNameStore = new AsyncLocalStorage();
7772
+ function withStackName(stackName, fn) {
7773
+ return stackNameStore.run(stackName, fn);
7773
7774
  }
7774
7775
  function generateResourceName(name, options) {
7775
7776
  const { maxLength, lowercase = false, allowedPattern = /[^a-zA-Z0-9-]/g } = options;
7777
+ const currentStackName = stackNameStore.getStore();
7776
7778
  const fullName = currentStackName ? `${currentStackName}-${name}` : name;
7777
7779
  let sanitized = lowercase ? fullName.toLowerCase() : fullName;
7778
7780
  sanitized = sanitized.replace(allowedPattern, "-");
@@ -17513,6 +17515,85 @@ var EC2Provider = class {
17513
17515
  const name = error.name ?? "";
17514
17516
  return message.includes("not found") || message.includes("does not exist") || message.includes("invalidparametervalue") || name === "InvalidVpcID.NotFound" || name === "InvalidSubnetID.NotFound" || name === "InvalidInternetGatewayID.NotFound" || name === "InvalidRouteTableID.NotFound" || name === "InvalidGroup.NotFound" || name === "InvalidAssociationID.NotFound" || name === "InvalidRoute.NotFound" || name === "InvalidInstanceID.NotFound" || name === "InvalidNetworkAclID.NotFound" || name === "InvalidNetworkAclEntry.NotFound";
17515
17517
  }
17518
+ /**
17519
+ * Adopt an existing EC2 networking resource into cdkd state.
17520
+ *
17521
+ * Supported types: `AWS::EC2::VPC`, `AWS::EC2::Subnet`,
17522
+ * `AWS::EC2::SecurityGroup`. Other EC2 types this provider creates
17523
+ * (RouteTable, Route, InternetGateway, VPCGatewayAttachment,
17524
+ * NetworkAcl, Instance) return `null` from import — most have no
17525
+ * stable identity to look up by tag (Routes are derived; SGIngress
17526
+ * is rule-level), and the typical adoption story is "find the VPC,
17527
+ * cdkd reconstructs the rest at deploy time".
17528
+ *
17529
+ * EC2 supports `Filters: [{Name: 'tag:aws:cdk:path', Values: [path]}]`
17530
+ * directly on `Describe*`, so the lookup is one API call per type.
17531
+ */
17532
+ async import(input) {
17533
+ if (input.knownPhysicalId) {
17534
+ return this.verifyExplicit(input.resourceType, input.knownPhysicalId);
17535
+ }
17536
+ if (!input.cdkPath)
17537
+ return null;
17538
+ const tagFilter = { Name: `tag:${CDK_PATH_TAG}`, Values: [input.cdkPath] };
17539
+ try {
17540
+ switch (input.resourceType) {
17541
+ case "AWS::EC2::VPC": {
17542
+ const resp = await this.ec2Client.send(new DescribeVpcsCommand2({ Filters: [tagFilter] }));
17543
+ const vpc = resp.Vpcs?.[0];
17544
+ return vpc?.VpcId ? { physicalId: vpc.VpcId, attributes: {} } : null;
17545
+ }
17546
+ case "AWS::EC2::Subnet": {
17547
+ const resp = await this.ec2Client.send(
17548
+ new DescribeSubnetsCommand2({ Filters: [tagFilter] })
17549
+ );
17550
+ const subnet = resp.Subnets?.[0];
17551
+ return subnet?.SubnetId ? { physicalId: subnet.SubnetId, attributes: {} } : null;
17552
+ }
17553
+ case "AWS::EC2::SecurityGroup": {
17554
+ const resp = await this.ec2Client.send(
17555
+ new DescribeSecurityGroupsCommand2({ Filters: [tagFilter] })
17556
+ );
17557
+ const sg = resp.SecurityGroups?.[0];
17558
+ return sg?.GroupId ? { physicalId: sg.GroupId, attributes: {} } : null;
17559
+ }
17560
+ default:
17561
+ return null;
17562
+ }
17563
+ } catch (error) {
17564
+ if (this.isNotFoundError(error))
17565
+ return null;
17566
+ throw error;
17567
+ }
17568
+ }
17569
+ async verifyExplicit(resourceType, physicalId) {
17570
+ try {
17571
+ switch (resourceType) {
17572
+ case "AWS::EC2::VPC": {
17573
+ const resp = await this.ec2Client.send(new DescribeVpcsCommand2({ VpcIds: [physicalId] }));
17574
+ return resp.Vpcs?.[0] ? { physicalId, attributes: {} } : null;
17575
+ }
17576
+ case "AWS::EC2::Subnet": {
17577
+ const resp = await this.ec2Client.send(
17578
+ new DescribeSubnetsCommand2({ SubnetIds: [physicalId] })
17579
+ );
17580
+ return resp.Subnets?.[0] ? { physicalId, attributes: {} } : null;
17581
+ }
17582
+ case "AWS::EC2::SecurityGroup": {
17583
+ const resp = await this.ec2Client.send(
17584
+ new DescribeSecurityGroupsCommand2({ GroupIds: [physicalId] })
17585
+ );
17586
+ return resp.SecurityGroups?.[0] ? { physicalId, attributes: {} } : null;
17587
+ }
17588
+ default:
17589
+ return null;
17590
+ }
17591
+ } catch (error) {
17592
+ if (this.isNotFoundError(error))
17593
+ return null;
17594
+ throw error;
17595
+ }
17596
+ }
17516
17597
  };
17517
17598
 
17518
17599
  // src/provisioning/providers/apigateway-provider.ts
@@ -18517,6 +18598,32 @@ var ApiGatewayProvider = class _ApiGatewayProvider {
18517
18598
  }
18518
18599
  return result;
18519
18600
  }
18601
+ /**
18602
+ * Adopt an existing API Gateway sub-resource into cdkd state.
18603
+ *
18604
+ * **Explicit override only.** API Gateway sub-resources (Authorizer,
18605
+ * Resource, Deployment, Stage, Method) live under a parent `RestApi`,
18606
+ * and their physical ids are not globally unique — they're scoped
18607
+ * `<restApiId>/<sub-id>`. Auto-lookup by `aws:cdk:path` would need to
18608
+ * walk every RestApi in the account, then every sub-resource within
18609
+ * each, which is impractical and error-prone.
18610
+ *
18611
+ * `AWS::ApiGateway::RestApi` itself is handled by the Cloud Control
18612
+ * API fallback (also explicit-override only — see
18613
+ * `cloud-control-provider.ts`).
18614
+ *
18615
+ * Users adopting an existing API Gateway should pass
18616
+ * `--resource <logicalId>=<physicalId>` for each sub-resource; the
18617
+ * physical id format follows what `create()` returns for the same
18618
+ * type (e.g. `<restApiId>|<resourceId>` for `AWS::ApiGateway::Resource`).
18619
+ */
18620
+ // eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
18621
+ async import(input) {
18622
+ if (input.knownPhysicalId) {
18623
+ return { physicalId: input.knownPhysicalId, attributes: {} };
18624
+ }
18625
+ return null;
18626
+ }
18520
18627
  };
18521
18628
 
18522
18629
  // src/provisioning/providers/apigatewayv2-provider.ts
@@ -19237,6 +19344,8 @@ import {
19237
19344
  DeleteDistributionCommand,
19238
19345
  GetDistributionCommand,
19239
19346
  GetDistributionConfigCommand,
19347
+ ListDistributionsCommand,
19348
+ ListTagsForResourceCommand as ListTagsForResourceCommand5,
19240
19349
  NoSuchDistribution
19241
19350
  } from "@aws-sdk/client-cloudfront";
19242
19351
  init_aws_clients();
@@ -19641,6 +19750,52 @@ var CloudFrontDistributionProvider = class {
19641
19750
  this.applyQuantityAtPath(nested, rest);
19642
19751
  }
19643
19752
  }
19753
+ /**
19754
+ * Adopt an existing CloudFront distribution into cdkd state.
19755
+ *
19756
+ * CloudFront distributions don't carry a template-supplied name
19757
+ * (physical id is the AWS-generated `E...` distribution id), so the
19758
+ * lookup is either explicit-override or `aws:cdk:path` tag match
19759
+ * via `ListDistributions` + `ListTagsForResource(ARN)`.
19760
+ */
19761
+ async import(input) {
19762
+ if (input.knownPhysicalId) {
19763
+ try {
19764
+ await this.cloudFrontClient.send(new GetDistributionCommand({ Id: input.knownPhysicalId }));
19765
+ return { physicalId: input.knownPhysicalId, attributes: {} };
19766
+ } catch (err) {
19767
+ if (err instanceof NoSuchDistribution)
19768
+ return null;
19769
+ throw err;
19770
+ }
19771
+ }
19772
+ if (!input.cdkPath)
19773
+ return null;
19774
+ let marker;
19775
+ do {
19776
+ const list = await this.cloudFrontClient.send(
19777
+ new ListDistributionsCommand({ ...marker && { Marker: marker } })
19778
+ );
19779
+ for (const d of list.DistributionList?.Items ?? []) {
19780
+ if (!d.Id || !d.ARN)
19781
+ continue;
19782
+ try {
19783
+ const tagsResp = await this.cloudFrontClient.send(
19784
+ new ListTagsForResourceCommand5({ Resource: d.ARN })
19785
+ );
19786
+ if (matchesCdkPath(tagsResp.Tags?.Items, input.cdkPath)) {
19787
+ return { physicalId: d.Id, attributes: {} };
19788
+ }
19789
+ } catch (err) {
19790
+ if (err instanceof NoSuchDistribution)
19791
+ continue;
19792
+ throw err;
19793
+ }
19794
+ }
19795
+ marker = list.DistributionList?.IsTruncated ? list.DistributionList?.NextMarker : void 0;
19796
+ } while (marker);
19797
+ return null;
19798
+ }
19644
19799
  };
19645
19800
 
19646
19801
  // src/provisioning/providers/agentcore-runtime-provider.ts
@@ -20130,7 +20285,10 @@ import {
20130
20285
  CreateServiceCommand,
20131
20286
  UpdateServiceCommand,
20132
20287
  DeleteServiceCommand,
20133
- DescribeServicesCommand
20288
+ DescribeServicesCommand,
20289
+ ListClustersCommand,
20290
+ ListServicesCommand,
20291
+ ListTagsForResourceCommand as ListTagsForResourceCommand6
20134
20292
  } from "@aws-sdk/client-ecs";
20135
20293
  function convertTags(tags) {
20136
20294
  if (!tags || tags.length === 0)
@@ -20859,6 +21017,128 @@ var ECSProvider = class {
20859
21017
  }
20860
21018
  return false;
20861
21019
  }
21020
+ /**
21021
+ * Adopt an existing ECS resource into cdkd state.
21022
+ *
21023
+ * Supported types: `AWS::ECS::Cluster`, `AWS::ECS::Service`,
21024
+ * `AWS::ECS::TaskDefinition`. ECS uses lowercase `key`/`value` tags
21025
+ * (vs the standard CFn `Key`/`Value`), so the standard
21026
+ * `matchesCdkPath` helper doesn't apply — match the tag manually.
21027
+ *
21028
+ * Service has a composite physical id of `<clusterArn>|<serviceName>`
21029
+ * (the form ECSProvider uses internally for mutation operations),
21030
+ * so the explicit-override path takes that composite form when
21031
+ * supplied.
21032
+ */
21033
+ async import(input) {
21034
+ switch (input.resourceType) {
21035
+ case "AWS::ECS::Cluster":
21036
+ return this.importCluster(input);
21037
+ case "AWS::ECS::Service":
21038
+ return this.importService(input);
21039
+ case "AWS::ECS::TaskDefinition":
21040
+ return this.importTaskDefinition(input);
21041
+ default:
21042
+ return null;
21043
+ }
21044
+ }
21045
+ async importCluster(input) {
21046
+ const explicit = resolveExplicitPhysicalId(input, "ClusterName");
21047
+ if (explicit) {
21048
+ try {
21049
+ const resp = await this.getClient().send(
21050
+ new DescribeClustersCommand({ clusters: [explicit] })
21051
+ );
21052
+ return resp.clusters?.[0]?.clusterName ? { physicalId: resp.clusters[0].clusterName, attributes: {} } : null;
21053
+ } catch (err) {
21054
+ if (this.isClusterNotFoundException(err) || this.isServiceNotFoundException(err)) {
21055
+ return null;
21056
+ }
21057
+ throw err;
21058
+ }
21059
+ }
21060
+ if (!input.cdkPath)
21061
+ return null;
21062
+ let nextToken;
21063
+ do {
21064
+ const list = await this.getClient().send(
21065
+ new ListClustersCommand({ ...nextToken && { nextToken } })
21066
+ );
21067
+ for (const arn of list.clusterArns ?? []) {
21068
+ const tagsResp = await this.getClient().send(
21069
+ new ListTagsForResourceCommand6({ resourceArn: arn })
21070
+ );
21071
+ if (this.tagsMatchCdkPath(tagsResp.tags, input.cdkPath)) {
21072
+ const name = arn.substring(arn.lastIndexOf("/") + 1);
21073
+ return { physicalId: name, attributes: {} };
21074
+ }
21075
+ }
21076
+ nextToken = list.nextToken;
21077
+ } while (nextToken);
21078
+ return null;
21079
+ }
21080
+ async importService(input) {
21081
+ if (input.knownPhysicalId) {
21082
+ return { physicalId: input.knownPhysicalId, attributes: {} };
21083
+ }
21084
+ if (!input.cdkPath)
21085
+ return null;
21086
+ let clusterToken;
21087
+ do {
21088
+ const clusterList = await this.getClient().send(
21089
+ new ListClustersCommand({ ...clusterToken && { nextToken: clusterToken } })
21090
+ );
21091
+ for (const clusterArn of clusterList.clusterArns ?? []) {
21092
+ let svcToken;
21093
+ do {
21094
+ const svcList = await this.getClient().send(
21095
+ new ListServicesCommand({
21096
+ cluster: clusterArn,
21097
+ ...svcToken && { nextToken: svcToken }
21098
+ })
21099
+ );
21100
+ for (const svcArn of svcList.serviceArns ?? []) {
21101
+ const tagsResp = await this.getClient().send(
21102
+ new ListTagsForResourceCommand6({ resourceArn: svcArn })
21103
+ );
21104
+ if (this.tagsMatchCdkPath(tagsResp.tags, input.cdkPath)) {
21105
+ const svcName = svcArn.substring(svcArn.lastIndexOf("/") + 1);
21106
+ return { physicalId: `${clusterArn}|${svcName}`, attributes: {} };
21107
+ }
21108
+ }
21109
+ svcToken = svcList.nextToken;
21110
+ } while (svcToken);
21111
+ }
21112
+ clusterToken = clusterList.nextToken;
21113
+ } while (clusterToken);
21114
+ return null;
21115
+ }
21116
+ async importTaskDefinition(input) {
21117
+ if (input.knownPhysicalId) {
21118
+ try {
21119
+ const resp = await this.getClient().send(
21120
+ new DescribeTaskDefinitionCommand({ taskDefinition: input.knownPhysicalId })
21121
+ );
21122
+ const arn = resp.taskDefinition?.taskDefinitionArn;
21123
+ return arn ? { physicalId: arn, attributes: {} } : null;
21124
+ } catch (err) {
21125
+ if (this.isClusterNotFoundException(err) || this.isServiceNotFoundException(err)) {
21126
+ return null;
21127
+ }
21128
+ throw err;
21129
+ }
21130
+ }
21131
+ return null;
21132
+ }
21133
+ tagsMatchCdkPath(tags, cdkPath) {
21134
+ if (!tags)
21135
+ return false;
21136
+ for (const t of tags) {
21137
+ if (t.key === "aws:cdk:path" && t.value === cdkPath)
21138
+ return true;
21139
+ }
21140
+ return false;
21141
+ }
20862
21142
  };
20863
21143
 
20864
21144
  // src/provisioning/providers/elbv2-provider.ts
@@ -21391,7 +21671,9 @@ import {
21391
21671
  DescribeDBInstancesCommand,
21392
21672
  CreateDBSubnetGroupCommand,
21393
21673
  DeleteDBSubnetGroupCommand,
21394
- ModifyDBSubnetGroupCommand
21674
+ DescribeDBSubnetGroupsCommand,
21675
+ ModifyDBSubnetGroupCommand,
21676
+ ListTagsForResourceCommand as ListTagsForResourceCommand7
21395
21677
  } from "@aws-sdk/client-rds";
21396
21678
  var RDSProvider = class {
21397
21679
  rdsClient;
@@ -21985,6 +22267,133 @@ var RDSProvider = class {
21985
22267
  sleep(ms) {
21986
22268
  return new Promise((resolve4) => setTimeout(resolve4, ms));
21987
22269
  }
22270
+ /**
22271
+ * Adopt an existing RDS resource into cdkd state.
22272
+ *
22273
+ * Supported types: `AWS::RDS::DBInstance`, `AWS::RDS::DBCluster`,
22274
+ * `AWS::RDS::DBSubnetGroup`. Identifier name properties (`DBInstance
22275
+ * Identifier` / `DBClusterIdentifier` / `DBSubnetGroupName`) are
22276
+ * usually present in CDK templates; fall back to `aws:cdk:path` tag
22277
+ * lookup via the corresponding `Describe*` + `ListTagsForResource`
22278
+ * pair otherwise.
22279
+ */
22280
+ async import(input) {
22281
+ switch (input.resourceType) {
22282
+ case "AWS::RDS::DBInstance":
22283
+ return this.importDBInstance(input);
22284
+ case "AWS::RDS::DBCluster":
22285
+ return this.importDBCluster(input);
22286
+ case "AWS::RDS::DBSubnetGroup":
22287
+ return this.importDBSubnetGroup(input);
22288
+ default:
22289
+ return null;
22290
+ }
22291
+ }
22292
+ async importDBInstance(input) {
22293
+ const explicit = resolveExplicitPhysicalId(input, "DBInstanceIdentifier");
22294
+ if (explicit) {
22295
+ try {
22296
+ await this.getClient().send(
22297
+ new DescribeDBInstancesCommand({ DBInstanceIdentifier: explicit })
22298
+ );
22299
+ return { physicalId: explicit, attributes: {} };
22300
+ } catch (err) {
22301
+ if (err.name === "DBInstanceNotFoundFault")
22302
+ return null;
22303
+ throw err;
22304
+ }
22305
+ }
22306
+ if (!input.cdkPath)
22307
+ return null;
22308
+ let marker;
22309
+ do {
22310
+ const list = await this.getClient().send(
22311
+ new DescribeDBInstancesCommand({ ...marker && { Marker: marker } })
22312
+ );
22313
+ for (const inst of list.DBInstances ?? []) {
22314
+ if (!inst.DBInstanceIdentifier || !inst.DBInstanceArn)
22315
+ continue;
22316
+ const tagsResp = await this.getClient().send(
22317
+ new ListTagsForResourceCommand7({ ResourceName: inst.DBInstanceArn })
22318
+ );
22319
+ if (matchesCdkPath(tagsResp.TagList, input.cdkPath)) {
22320
+ return { physicalId: inst.DBInstanceIdentifier, attributes: {} };
22321
+ }
22322
+ }
22323
+ marker = list.Marker;
22324
+ } while (marker);
22325
+ return null;
22326
+ }
22327
+ async importDBCluster(input) {
22328
+ const explicit = resolveExplicitPhysicalId(input, "DBClusterIdentifier");
22329
+ if (explicit) {
22330
+ try {
22331
+ await this.getClient().send(
22332
+ new DescribeDBClustersCommand({ DBClusterIdentifier: explicit })
22333
+ );
22334
+ return { physicalId: explicit, attributes: {} };
22335
+ } catch (err) {
22336
+ if (err.name === "DBClusterNotFoundFault")
22337
+ return null;
22338
+ throw err;
22339
+ }
22340
+ }
22341
+ if (!input.cdkPath)
22342
+ return null;
22343
+ let marker;
22344
+ do {
22345
+ const list = await this.getClient().send(
22346
+ new DescribeDBClustersCommand({ ...marker && { Marker: marker } })
22347
+ );
22348
+ for (const c of list.DBClusters ?? []) {
22349
+ if (!c.DBClusterIdentifier || !c.DBClusterArn)
22350
+ continue;
22351
+ const tagsResp = await this.getClient().send(
22352
+ new ListTagsForResourceCommand7({ ResourceName: c.DBClusterArn })
22353
+ );
22354
+ if (matchesCdkPath(tagsResp.TagList, input.cdkPath)) {
22355
+ return { physicalId: c.DBClusterIdentifier, attributes: {} };
22356
+ }
22357
+ }
22358
+ marker = list.Marker;
22359
+ } while (marker);
22360
+ return null;
22361
+ }
22362
+ async importDBSubnetGroup(input) {
22363
+ const explicit = resolveExplicitPhysicalId(input, "DBSubnetGroupName");
22364
+ if (explicit) {
22365
+ try {
22366
+ await this.getClient().send(
22367
+ new DescribeDBSubnetGroupsCommand({ DBSubnetGroupName: explicit })
22368
+ );
22369
+ return { physicalId: explicit, attributes: {} };
22370
+ } catch (err) {
22371
+ if (err.name === "DBSubnetGroupNotFoundFault")
22372
+ return null;
22373
+ throw err;
22374
+ }
22375
+ }
22376
+ if (!input.cdkPath)
22377
+ return null;
22378
+ let marker;
22379
+ do {
22380
+ const list = await this.getClient().send(
22381
+ new DescribeDBSubnetGroupsCommand({ ...marker && { Marker: marker } })
22382
+ );
22383
+ for (const sg of list.DBSubnetGroups ?? []) {
22384
+ if (!sg.DBSubnetGroupName || !sg.DBSubnetGroupArn)
22385
+ continue;
22386
+ const tagsResp = await this.getClient().send(
22387
+ new ListTagsForResourceCommand7({ ResourceName: sg.DBSubnetGroupArn })
22388
+ );
22389
+ if (matchesCdkPath(tagsResp.TagList, input.cdkPath)) {
22390
+ return { physicalId: sg.DBSubnetGroupName, attributes: {} };
22391
+ }
22392
+ }
22393
+ marker = list.Marker;
22394
+ } while (marker);
22395
+ return null;
22396
+ }
21988
22397
  };
21989
22398
 
21990
22399
  // src/provisioning/providers/route53-provider.ts
@@ -22880,6 +23289,8 @@ import {
22880
23289
  DeleteUserPoolCommand,
22881
23290
  UpdateUserPoolCommand,
22882
23291
  DescribeUserPoolCommand,
23292
+ ListUserPoolsCommand,
23293
+ ListTagsForResourceCommand as ListTagsForResourceCommand8,
22883
23294
  ResourceNotFoundException as ResourceNotFoundException12
22884
23295
  } from "@aws-sdk/client-cognito-identity-provider";
22885
23296
  var CognitoUserPoolProvider = class {
@@ -23215,6 +23626,71 @@ var CognitoUserPoolProvider = class {
23215
23626
  );
23216
23627
  }
23217
23628
  }
23629
+ /**
23630
+ * Adopt an existing Cognito User Pool into cdkd state.
23631
+ *
23632
+ * User Pool physical id is the AWS-generated `<region>_<random>` id.
23633
+ * Lookup chain:
23634
+ * 1. `--resource` override → `DescribeUserPool` to verify.
23635
+ * 2. `Properties.UserPoolName` (when CDK template carries it) →
23636
+ * `ListUserPools` walk + name match.
23637
+ * 3. `aws:cdk:path` tag match via `ListUserPools` +
23638
+ * `ListTagsForResource(<arn>)`. Cognito's tag map uses the same
23639
+ * `Tags: { [key]: value }` shape as Lambda.
23640
+ */
23641
+ async import(input) {
23642
+ if (input.knownPhysicalId) {
23643
+ try {
23644
+ await this.getClient().send(
23645
+ new DescribeUserPoolCommand({ UserPoolId: input.knownPhysicalId })
23646
+ );
23647
+ return { physicalId: input.knownPhysicalId, attributes: {} };
23648
+ } catch (err) {
23649
+ if (err instanceof ResourceNotFoundException12)
23650
+ return null;
23651
+ throw err;
23652
+ }
23653
+ }
23654
+ const desiredName = typeof input.properties?.["UserPoolName"] === "string" ? input.properties["UserPoolName"] : void 0;
23655
+ let nextToken;
23656
+ do {
23657
+ const list = await this.getClient().send(
23658
+ new ListUserPoolsCommand({
23659
+ MaxResults: 60,
23660
+ ...nextToken && { NextToken: nextToken }
23661
+ })
23662
+ );
23663
+ for (const pool of list.UserPools ?? []) {
23664
+ if (!pool.Id)
23665
+ continue;
23666
+ if (desiredName && pool.Name === desiredName) {
23667
+ return { physicalId: pool.Id, attributes: {} };
23668
+ }
23669
+ if (input.cdkPath) {
23670
+ try {
23671
+ const desc = await this.getClient().send(
23672
+ new DescribeUserPoolCommand({ UserPoolId: pool.Id })
23673
+ );
23674
+ const arn = desc.UserPool?.Arn;
23675
+ if (!arn)
23676
+ continue;
23677
+ const tagsResp = await this.getClient().send(
23678
+ new ListTagsForResourceCommand8({ ResourceArn: arn })
23679
+ );
23680
+ if (tagsResp.Tags?.[CDK_PATH_TAG] === input.cdkPath) {
23681
+ return { physicalId: pool.Id, attributes: {} };
23682
+ }
23683
+ } catch (err) {
23684
+ if (err instanceof ResourceNotFoundException12)
23685
+ continue;
23686
+ throw err;
23687
+ }
23688
+ }
23689
+ }
23690
+ nextToken = list.NextToken;
23691
+ } while (nextToken);
23692
+ return null;
23693
+ }
23218
23694
  };
23219
23695
 
23220
23696
  // src/provisioning/providers/elasticache-provider.ts
@@ -28316,9 +28792,11 @@ var DeployEngine = class {
28316
28792
  * Deploy a CloudFormation template
28317
28793
  */
28318
28794
  async deploy(stackName, template) {
28795
+ return withStackName(stackName, () => this.doDeploy(stackName, template));
28796
+ }
28797
+ async doDeploy(stackName, template) {
28319
28798
  const startTime = Date.now();
28320
28799
  this.logger.debug(`Starting deployment for stack: ${stackName}`);
28321
- setCurrentStackName(stackName);
28322
28800
  await this.lockManager.acquireLockWithRetry(stackName, this.stackRegion, void 0, "deploy");
28323
28801
  const renderer = getLiveRenderer();
28324
28802
  renderer.start();
@@ -31661,7 +32139,7 @@ function reorderArgs(argv) {
31661
32139
  }
31662
32140
  async function main() {
31663
32141
  const program = new Command12();
31664
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.16.1");
32142
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.17.1");
31665
32143
  program.addCommand(createBootstrapCommand());
31666
32144
  program.addCommand(createSynthCommand());
31667
32145
  program.addCommand(createListCommand());