@go-to-k/cdkd 0.26.0 → 0.27.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
@@ -8638,6 +8638,33 @@ var IAMRoleProvider = class {
8638
8638
  this.logger.debug(`Added/updated ${tagsToAdd.length} tags on role ${roleName}`);
8639
8639
  }
8640
8640
  }
8641
+ /**
8642
+ * Resolve a single `Fn::GetAtt` attribute for an existing IAM role.
8643
+ *
8644
+ * CloudFormation's `AWS::IAM::Role` exposes `Arn` and `RoleId`; both are
8645
+ * available from the `GetRole` response. See:
8646
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#aws-resource-iam-role-return-values
8647
+ *
8648
+ * Used by `cdkd orphan` to live-fetch attribute values that need to be
8649
+ * substituted into sibling references.
8650
+ */
8651
+ async getAttribute(physicalId, _resourceType, attributeName) {
8652
+ try {
8653
+ const resp = await this.iamClient.send(new GetRoleCommand({ RoleName: physicalId }));
8654
+ switch (attributeName) {
8655
+ case "Arn":
8656
+ return resp.Role?.Arn;
8657
+ case "RoleId":
8658
+ return resp.Role?.RoleId;
8659
+ default:
8660
+ return void 0;
8661
+ }
8662
+ } catch (err) {
8663
+ if (err instanceof NoSuchEntityException)
8664
+ return void 0;
8665
+ throw err;
8666
+ }
8667
+ }
8641
8668
  /**
8642
8669
  * Adopt an existing IAM role into cdkd state.
8643
8670
  *
@@ -10488,17 +10515,35 @@ var S3BucketProvider = class {
10488
10515
  return region || "us-east-1";
10489
10516
  }
10490
10517
  /**
10491
- * Build attributes for an S3 bucket
10518
+ * Build attributes for an S3 bucket.
10519
+ *
10520
+ * Covers every CloudFormation `Fn::GetAtt` return value for
10521
+ * `AWS::S3::Bucket`. All fields are derivable from `bucketName` + region —
10522
+ * no extra AWS API call is needed. See:
10523
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html#aws-properties-s3-bucket-return-values
10492
10524
  */
10493
10525
  async buildAttributes(bucketName) {
10494
10526
  const region = await this.getRegion();
10495
10527
  return {
10496
10528
  Arn: `arn:aws:s3:::${bucketName}`,
10497
10529
  DomainName: `${bucketName}.s3.amazonaws.com`,
10530
+ DualStackDomainName: `${bucketName}.s3.dualstack.${region}.amazonaws.com`,
10498
10531
  RegionalDomainName: `${bucketName}.s3.${region}.amazonaws.com`,
10499
10532
  WebsiteURL: `http://${bucketName}.s3-website-${region}.amazonaws.com`
10500
10533
  };
10501
10534
  }
10535
+ /**
10536
+ * Resolve a single `Fn::GetAtt` attribute for an existing bucket.
10537
+ *
10538
+ * Used by `cdkd orphan` to live-fetch attribute values that need to be
10539
+ * substituted into sibling references. All S3 Bucket attributes are
10540
+ * derivable from bucket name + region, so this avoids the round trip and
10541
+ * reuses the same templating as `buildAttributes`.
10542
+ */
10543
+ async getAttribute(physicalId, _resourceType, attributeName) {
10544
+ const attrs = await this.buildAttributes(physicalId);
10545
+ return attrs[attributeName];
10546
+ }
10502
10547
  /**
10503
10548
  * Apply versioning configuration if specified
10504
10549
  */
@@ -11793,6 +11838,43 @@ var SQSQueueProvider = class {
11793
11838
  return `arn:aws:sqs:unknown:unknown:${queueName}`;
11794
11839
  }
11795
11840
  }
11841
+ /**
11842
+ * Resolve a single `Fn::GetAtt` attribute for an existing SQS queue.
11843
+ *
11844
+ * CloudFormation's `AWS::SQS::Queue` exposes `Arn`, `QueueName` and
11845
+ * `QueueUrl`. The cdkd physicalId is the queue URL; `QueueUrl` and
11846
+ * `QueueName` are derivable from it without an AWS call, while `Arn`
11847
+ * requires `GetQueueAttributes`. See:
11848
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html#aws-properties-sqs-queues-return-values
11849
+ *
11850
+ * Used by `cdkd orphan` to live-fetch attribute values that need to be
11851
+ * substituted into sibling references.
11852
+ */
11853
+ async getAttribute(physicalId, _resourceType, attributeName) {
11854
+ switch (attributeName) {
11855
+ case "QueueUrl":
11856
+ return physicalId;
11857
+ case "QueueName":
11858
+ return physicalId.substring(physicalId.lastIndexOf("/") + 1);
11859
+ case "Arn": {
11860
+ try {
11861
+ const resp = await this.sqsClient.send(
11862
+ new GetQueueAttributesCommand({
11863
+ QueueUrl: physicalId,
11864
+ AttributeNames: ["QueueArn"]
11865
+ })
11866
+ );
11867
+ return resp.Attributes?.["QueueArn"];
11868
+ } catch (err) {
11869
+ if (err instanceof QueueDoesNotExist)
11870
+ return void 0;
11871
+ throw err;
11872
+ }
11873
+ }
11874
+ default:
11875
+ return void 0;
11876
+ }
11877
+ }
11796
11878
  /**
11797
11879
  * Adopt an existing SQS queue into cdkd state.
11798
11880
  *
@@ -12328,6 +12410,28 @@ var SNSTopicProvider = class {
12328
12410
  );
12329
12411
  }
12330
12412
  }
12413
+ /**
12414
+ * Resolve a single `Fn::GetAtt` attribute for an existing SNS topic.
12415
+ *
12416
+ * CloudFormation's `AWS::SNS::Topic` exposes `TopicName` and `TopicArn`.
12417
+ * The cdkd physicalId is the topic ARN, so both are derivable without
12418
+ * an AWS call. See:
12419
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html#aws-properties-sns-topic-return-values
12420
+ *
12421
+ * Used by `cdkd orphan` to live-fetch attribute values that need to be
12422
+ * substituted into sibling references.
12423
+ */
12424
+ // eslint-disable-next-line @typescript-eslint/require-await -- consistent async signature with other providers
12425
+ async getAttribute(physicalId, _resourceType, attributeName) {
12426
+ switch (attributeName) {
12427
+ case "TopicArn":
12428
+ return physicalId;
12429
+ case "TopicName":
12430
+ return physicalId.split(":").pop();
12431
+ default:
12432
+ return void 0;
12433
+ }
12434
+ }
12331
12435
  /**
12332
12436
  * Adopt an existing SNS topic into cdkd state.
12333
12437
  *
@@ -13309,6 +13413,43 @@ var LambdaFunctionProvider = class {
13309
13413
  }
13310
13414
  return (crc ^ 4294967295) >>> 0;
13311
13415
  }
13416
+ /**
13417
+ * Resolve a single `Fn::GetAtt` attribute for an existing Lambda function.
13418
+ *
13419
+ * CloudFormation's `AWS::Lambda::Function` exposes `Arn`,
13420
+ * `SnapStartResponse.ApplyOn`, and `SnapStartResponse.OptimizationStatus`
13421
+ * as documented at
13422
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#aws-resource-lambda-function-return-values.
13423
+ *
13424
+ * All three live in the same `GetFunction` response (`Configuration.FunctionArn`
13425
+ * and `Configuration.SnapStart.{ApplyOn,OptimizationStatus}`), so a single API
13426
+ * call covers every supported attr. Used by `cdkd orphan` to live-fetch
13427
+ * attribute values that need to be substituted into sibling references.
13428
+ */
13429
+ async getAttribute(physicalId, _resourceType, attributeName) {
13430
+ if (attributeName !== "Arn" && attributeName !== "SnapStartResponse.ApplyOn" && attributeName !== "SnapStartResponse.OptimizationStatus") {
13431
+ return void 0;
13432
+ }
13433
+ try {
13434
+ const resp = await this.lambdaClient.send(
13435
+ new GetFunctionCommand({ FunctionName: physicalId })
13436
+ );
13437
+ switch (attributeName) {
13438
+ case "Arn":
13439
+ return resp.Configuration?.FunctionArn;
13440
+ case "SnapStartResponse.ApplyOn":
13441
+ return resp.Configuration?.SnapStart?.ApplyOn;
13442
+ case "SnapStartResponse.OptimizationStatus":
13443
+ return resp.Configuration?.SnapStart?.OptimizationStatus;
13444
+ default:
13445
+ return void 0;
13446
+ }
13447
+ } catch (err) {
13448
+ if (err instanceof ResourceNotFoundException)
13449
+ return void 0;
13450
+ throw err;
13451
+ }
13452
+ }
13312
13453
  /**
13313
13454
  * Adopt an existing Lambda function into cdkd state.
13314
13455
  *
@@ -13581,6 +13722,7 @@ var LambdaPermissionProvider = class {
13581
13722
  import {
13582
13723
  CreateFunctionUrlConfigCommand,
13583
13724
  DeleteFunctionUrlConfigCommand,
13725
+ GetFunctionUrlConfigCommand as GetFunctionUrlConfigCommand2,
13584
13726
  UpdateFunctionUrlConfigCommand,
13585
13727
  ResourceNotFoundException as ResourceNotFoundException3
13586
13728
  } from "@aws-sdk/client-lambda";
@@ -13708,6 +13850,36 @@ var LambdaUrlProvider = class {
13708
13850
  );
13709
13851
  }
13710
13852
  }
13853
+ /**
13854
+ * Resolve a single `Fn::GetAtt` attribute for an existing Lambda Function
13855
+ * URL.
13856
+ *
13857
+ * CloudFormation's `AWS::Lambda::Url` exposes `FunctionArn` and
13858
+ * `FunctionUrl`. Both come from `GetFunctionUrlConfig`. See:
13859
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-url.html#aws-resource-lambda-url-return-values
13860
+ *
13861
+ * Used by `cdkd orphan` to live-fetch attribute values that need to be
13862
+ * substituted into sibling references.
13863
+ */
13864
+ async getAttribute(physicalId, _resourceType, attributeName) {
13865
+ try {
13866
+ const resp = await this.lambdaClient.send(
13867
+ new GetFunctionUrlConfigCommand2({ FunctionName: physicalId })
13868
+ );
13869
+ switch (attributeName) {
13870
+ case "FunctionArn":
13871
+ return resp.FunctionArn;
13872
+ case "FunctionUrl":
13873
+ return resp.FunctionUrl;
13874
+ default:
13875
+ return void 0;
13876
+ }
13877
+ } catch (err) {
13878
+ if (err instanceof ResourceNotFoundException3)
13879
+ return void 0;
13880
+ throw err;
13881
+ }
13882
+ }
13711
13883
  /**
13712
13884
  * Adopt an existing Lambda Function URL into cdkd state.
13713
13885
  *
@@ -14419,6 +14591,40 @@ var DynamoDBTableProvider = class {
14419
14591
  }
14420
14592
  throw new Error(`Table ${tableName} did not reach ACTIVE status within ${maxAttempts} seconds`);
14421
14593
  }
14594
+ /**
14595
+ * Resolve a single `Fn::GetAtt` attribute for an existing DynamoDB table.
14596
+ *
14597
+ * CloudFormation's `AWS::DynamoDB::Table` exposes `Arn`, `StreamArn`
14598
+ * (a.k.a. `LatestStreamArn` in the SDK; CFn returns the latest enabled
14599
+ * stream's ARN), and `LatestStreamLabel`. All three are sibling fields on
14600
+ * the same `DescribeTable` response, so a single API call covers every
14601
+ * supported attr. See:
14602
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#aws-resource-dynamodb-table-return-values
14603
+ *
14604
+ * Used by `cdkd orphan` to live-fetch attribute values that need to be
14605
+ * substituted into sibling references.
14606
+ */
14607
+ async getAttribute(physicalId, _resourceType, attributeName) {
14608
+ try {
14609
+ const resp = await this.dynamoDBClient.send(
14610
+ new DescribeTableCommand2({ TableName: physicalId })
14611
+ );
14612
+ switch (attributeName) {
14613
+ case "Arn":
14614
+ return resp.Table?.TableArn;
14615
+ case "StreamArn":
14616
+ return resp.Table?.LatestStreamArn;
14617
+ case "LatestStreamLabel":
14618
+ return resp.Table?.LatestStreamLabel;
14619
+ default:
14620
+ return void 0;
14621
+ }
14622
+ } catch (err) {
14623
+ if (err instanceof ResourceNotFoundException6)
14624
+ return void 0;
14625
+ throw err;
14626
+ }
14627
+ }
14422
14628
  /**
14423
14629
  * Adopt an existing DynamoDB table into cdkd state.
14424
14630
  *
@@ -14706,6 +14912,23 @@ var LogsLogGroupProvider = class {
14706
14912
  return `arn:aws:logs:unknown:unknown:log-group:${logGroupName}:*`;
14707
14913
  }
14708
14914
  }
14915
+ /**
14916
+ * Resolve a single `Fn::GetAtt` attribute for an existing log group.
14917
+ *
14918
+ * CloudFormation's `AWS::Logs::LogGroup` exposes only `Arn`. The ARN is
14919
+ * derivable from the log group name + account + region via the existing
14920
+ * `buildArn` helper. See:
14921
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html#aws-resource-logs-loggroup-return-values
14922
+ *
14923
+ * Used by `cdkd orphan` to live-fetch attribute values that need to be
14924
+ * substituted into sibling references.
14925
+ */
14926
+ async getAttribute(physicalId, _resourceType, attributeName) {
14927
+ if (attributeName !== "Arn") {
14928
+ return void 0;
14929
+ }
14930
+ return this.buildArn(physicalId);
14931
+ }
14709
14932
  /**
14710
14933
  * Adopt an existing CloudWatch Logs log group into cdkd state.
14711
14934
  *
@@ -16743,29 +16966,63 @@ var EC2Provider = class {
16743
16966
  }
16744
16967
  }
16745
16968
  }
16969
+ /**
16970
+ * Resolve a single `Fn::GetAtt` attribute for an `AWS::EC2::VPC`.
16971
+ *
16972
+ * CloudFormation returns `CidrBlock`, `CidrBlockAssociations`,
16973
+ * `DefaultNetworkAcl`, `DefaultSecurityGroup`, and `Ipv6CidrBlocks`. See:
16974
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpc.html#aws-resource-ec2-vpc-return-values
16975
+ *
16976
+ * `DefaultNetworkAcl` and `DefaultSecurityGroup` previously returned wrong
16977
+ * values (DHCP options id and `undefined` respectively); the AWS console
16978
+ * surfaces these the same way as CFn — by filtering the relevant
16979
+ * `Describe*` API on `vpc-id` + the `default` flag.
16980
+ */
16746
16981
  async getVpcAttribute(physicalId, attributeName) {
16747
- if (attributeName === "VpcId")
16748
- return physicalId;
16749
16982
  try {
16750
- const response = await this.ec2Client.send(new DescribeVpcsCommand2({ VpcIds: [physicalId] }));
16751
- const vpc = response.Vpcs?.[0];
16752
- if (!vpc)
16753
- return void 0;
16754
16983
  switch (attributeName) {
16755
- case "CidrBlock":
16756
- return vpc.CidrBlock;
16757
- case "Ipv6CidrBlocks":
16758
- return vpc.Ipv6CidrBlockAssociationSet?.filter(
16759
- (a) => a.Ipv6CidrBlockState?.State === "associated"
16760
- ).map((a) => a.Ipv6CidrBlock) || [];
16761
- case "CidrBlockAssociations":
16762
- return vpc.CidrBlockAssociationSet?.map((a) => a.AssociationId) || [];
16763
- case "DefaultNetworkAcl":
16764
- return vpc.DhcpOptionsId;
16765
- case "DefaultSecurityGroup":
16766
- return void 0;
16767
- default:
16768
- return void 0;
16984
+ case "DefaultNetworkAcl": {
16985
+ const resp = await this.ec2Client.send(
16986
+ new DescribeNetworkAclsCommand({
16987
+ Filters: [
16988
+ { Name: "vpc-id", Values: [physicalId] },
16989
+ { Name: "default", Values: ["true"] }
16990
+ ]
16991
+ })
16992
+ );
16993
+ return resp.NetworkAcls?.[0]?.NetworkAclId;
16994
+ }
16995
+ case "DefaultSecurityGroup": {
16996
+ const resp = await this.ec2Client.send(
16997
+ new DescribeSecurityGroupsCommand2({
16998
+ Filters: [
16999
+ { Name: "vpc-id", Values: [physicalId] },
17000
+ { Name: "group-name", Values: ["default"] }
17001
+ ]
17002
+ })
17003
+ );
17004
+ return resp.SecurityGroups?.[0]?.GroupId;
17005
+ }
17006
+ default: {
17007
+ const response = await this.ec2Client.send(
17008
+ new DescribeVpcsCommand2({ VpcIds: [physicalId] })
17009
+ );
17010
+ const vpc = response.Vpcs?.[0];
17011
+ if (!vpc)
17012
+ return void 0;
17013
+ switch (attributeName) {
17014
+ case "CidrBlock":
17015
+ return vpc.CidrBlock;
17016
+ case "Ipv6CidrBlocks":
17017
+ return vpc.Ipv6CidrBlockAssociationSet?.filter(
17018
+ (a) => a.Ipv6CidrBlockState?.State === "associated"
17019
+ ).map((a) => a.Ipv6CidrBlock) || [];
17020
+ case "CidrBlockAssociations":
17021
+ return vpc.CidrBlockAssociationSet?.map((a) => a.AssociationId) || [];
17022
+ default:
17023
+ return void 0;
17024
+ }
17025
+ }
16769
17026
  }
16770
17027
  } catch {
16771
17028
  return void 0;
@@ -35316,7 +35573,7 @@ function reorderArgs(argv) {
35316
35573
  }
35317
35574
  async function main() {
35318
35575
  const program = new Command13();
35319
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.26.0");
35576
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.27.0");
35320
35577
  program.addCommand(createBootstrapCommand());
35321
35578
  program.addCommand(createSynthCommand());
35322
35579
  program.addCommand(createListCommand());