@go-to-k/cdkd 0.103.1 → 0.103.2

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
@@ -30,7 +30,7 @@ import { CreateAliasCommand, CreateKeyCommand, DeleteAliasCommand, DescribeKeyCo
30
30
  import { promisify } from "node:util";
31
31
  import { CreateRepositoryCommand, DeleteLifecyclePolicyCommand, DeleteRepositoryCommand, DeleteRepositoryPolicyCommand, DescribeRepositoriesCommand, ECRClient, GetAuthorizationTokenCommand, GetLifecyclePolicyCommand, LifecyclePolicyNotFoundException, ListTagsForResourceCommand as ListTagsForResourceCommand$7, PutImageScanningConfigurationCommand, PutImageTagMutabilityCommand, PutLifecyclePolicyCommand, RepositoryNotFoundException, SetRepositoryPolicyCommand, TagResourceCommand as TagResourceCommand$9 } from "@aws-sdk/client-ecr";
32
32
  import graphlib from "graphlib";
33
- import { AddTagsToResourceCommand as AddTagsToResourceCommand$1, CreateDBClusterCommand, CreateDBInstanceCommand, CreateDBSubnetGroupCommand, DeleteDBClusterCommand, DeleteDBInstanceCommand, DeleteDBSubnetGroupCommand, DescribeDBClustersCommand, DescribeDBInstancesCommand, DescribeDBSubnetGroupsCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$8, ModifyDBClusterCommand, ModifyDBInstanceCommand, ModifyDBSubnetGroupCommand, RDSClient, RemoveTagsFromResourceCommand as RemoveTagsFromResourceCommand$1 } from "@aws-sdk/client-rds";
33
+ import { AddTagsToResourceCommand as AddTagsToResourceCommand$1, CreateDBClusterCommand, CreateDBInstanceCommand, CreateDBSubnetGroupCommand, DBProxyNotFoundFault, DBProxyTargetGroupNotFoundFault, DBProxyTargetNotFoundFault, DeleteDBClusterCommand, DeleteDBInstanceCommand, DeleteDBSubnetGroupCommand, DeregisterDBProxyTargetsCommand, DescribeDBClustersCommand, DescribeDBInstancesCommand, DescribeDBProxyTargetGroupsCommand, DescribeDBSubnetGroupsCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$8, ModifyDBClusterCommand, ModifyDBInstanceCommand, ModifyDBProxyTargetGroupCommand, ModifyDBSubnetGroupCommand, RDSClient, RegisterDBProxyTargetsCommand, RemoveTagsFromResourceCommand as RemoveTagsFromResourceCommand$1 } from "@aws-sdk/client-rds";
34
34
  import { Command, Option } from "commander";
35
35
  import { writeFileSync as writeFileSync$1 } from "fs";
36
36
  import { join as join$1 } from "path";
@@ -17748,6 +17748,178 @@ var RDSProvider = class {
17748
17748
  }
17749
17749
  };
17750
17750
 
17751
+ //#endregion
17752
+ //#region src/provisioning/providers/rds-dbproxy-targetgroup-provider.ts
17753
+ /**
17754
+ * AWS RDS DBProxyTargetGroup Provider
17755
+ *
17756
+ * Implements resource provisioning for `AWS::RDS::DBProxyTargetGroup`.
17757
+ *
17758
+ * **Why a dedicated SDK provider** (per `feedback_dedicated_provider_over_special_case.md`):
17759
+ * pre-PR this type went through Cloud Control API, but CC API's resource
17760
+ * handler for `AWS::RDS::DBProxyTargetGroup` fails the delete path with
17761
+ * `Value null at 'dBProxyName' failed to satisfy constraint`. The handler
17762
+ * cannot derive `DBProxyName` from the TargetGroup ARN (the primary
17763
+ * identifier), so the underlying RDS API call goes out with
17764
+ * `DBProxyName: null` and AWS rejects it (Issue #385).
17765
+ *
17766
+ * **What this resource actually does on AWS**: a CFn
17767
+ * `AWS::RDS::DBProxyTargetGroup` is a wiring resource — every DBProxy gets
17768
+ * a default TargetGroup (`TargetGroupName: 'default'`) auto-created by AWS;
17769
+ * the CFn resource only manages target REGISTRATIONS
17770
+ * (`RegisterDBProxyTargets` / `DeregisterDBProxyTargets`) and the
17771
+ * connection pool config (`ModifyDBProxyTargetGroup`). The TargetGroup
17772
+ * object itself is not deleted on resource delete — it lives and dies with
17773
+ * the parent DBProxy.
17774
+ *
17775
+ * **Lifecycle**:
17776
+ * - `create`: optionally `ModifyDBProxyTargetGroup` (connection pool), then
17777
+ * `RegisterDBProxyTargets` (cluster IDs and / or instance IDs), then
17778
+ * `DescribeDBProxyTargetGroups` to recover the TargetGroupArn for state.
17779
+ * - `update`: rejected via `ResourceUpdateNotSupportedError` in MVP. The
17780
+ * per-property update surface (add/remove targets, pool config rewrites)
17781
+ * is a follow-up.
17782
+ * - `delete`: `DeregisterDBProxyTargets` for every registered target.
17783
+ * `DBProxyNotFoundFault` / `DBProxyTargetGroupNotFoundFault` /
17784
+ * `DBProxyTargetNotFoundFault` are treated as idempotent success
17785
+ * (region-match-gated) — the parent DBProxy may already have been
17786
+ * deleted by a sibling cdkd delete or by AWS CASCADE.
17787
+ * - `getAttribute`: `TargetGroupArn` returns the physicalId; `TargetGroupName`
17788
+ * returns `'default'`.
17789
+ *
17790
+ * **physicalId** = TargetGroupArn (matches the CFn `primaryIdentifier`).
17791
+ */
17792
+ var RDSDBProxyTargetGroupProvider = class {
17793
+ rdsClient;
17794
+ providerRegion = process.env["AWS_REGION"];
17795
+ logger = getLogger().child("RDSDBProxyTargetGroupProvider");
17796
+ handledProperties = new Map([["AWS::RDS::DBProxyTargetGroup", new Set([
17797
+ "DBProxyName",
17798
+ "TargetGroupName",
17799
+ "DBClusterIdentifiers",
17800
+ "DBInstanceIdentifiers",
17801
+ "ConnectionPoolConfigurationInfo"
17802
+ ])]]);
17803
+ getClient() {
17804
+ if (!this.rdsClient) this.rdsClient = new RDSClient(this.providerRegion ? { region: this.providerRegion } : {});
17805
+ return this.rdsClient;
17806
+ }
17807
+ async create(logicalId, resourceType, properties) {
17808
+ const dbProxyName = properties["DBProxyName"];
17809
+ if (!dbProxyName) throw new ProvisioningError(`DBProxyName is required for AWS::RDS::DBProxyTargetGroup ${logicalId}`, resourceType, logicalId);
17810
+ const targetGroupName = properties["TargetGroupName"] ?? "default";
17811
+ const dbClusterIdentifiers = properties["DBClusterIdentifiers"];
17812
+ const dbInstanceIdentifiers = properties["DBInstanceIdentifiers"];
17813
+ const connectionPoolConfig = properties["ConnectionPoolConfigurationInfo"];
17814
+ const client = this.getClient();
17815
+ if (connectionPoolConfig) {
17816
+ this.logger.debug(`Applying connection pool config to ${dbProxyName}/${targetGroupName}`);
17817
+ try {
17818
+ await client.send(new ModifyDBProxyTargetGroupCommand({
17819
+ DBProxyName: dbProxyName,
17820
+ TargetGroupName: targetGroupName,
17821
+ ConnectionPoolConfig: connectionPoolConfig
17822
+ }));
17823
+ } catch (error) {
17824
+ throw this.wrapError(error, "CREATE (pool config)", resourceType, logicalId, void 0);
17825
+ }
17826
+ }
17827
+ if (dbClusterIdentifiers && dbClusterIdentifiers.length > 0 || dbInstanceIdentifiers && dbInstanceIdentifiers.length > 0) {
17828
+ this.logger.debug(`Registering targets for ${dbProxyName}/${targetGroupName}: clusters=[${dbClusterIdentifiers?.join(",") ?? ""}], instances=[${dbInstanceIdentifiers?.join(",") ?? ""}]`);
17829
+ try {
17830
+ await client.send(new RegisterDBProxyTargetsCommand({
17831
+ DBProxyName: dbProxyName,
17832
+ TargetGroupName: targetGroupName,
17833
+ DBClusterIdentifiers: dbClusterIdentifiers,
17834
+ DBInstanceIdentifiers: dbInstanceIdentifiers
17835
+ }));
17836
+ } catch (error) {
17837
+ throw this.wrapError(error, "CREATE (register targets)", resourceType, logicalId, void 0);
17838
+ }
17839
+ }
17840
+ let targetGroupArn;
17841
+ try {
17842
+ targetGroupArn = (await client.send(new DescribeDBProxyTargetGroupsCommand({
17843
+ DBProxyName: dbProxyName,
17844
+ TargetGroupName: targetGroupName
17845
+ }))).TargetGroups?.[0]?.TargetGroupArn;
17846
+ } catch (error) {
17847
+ throw this.wrapError(error, "CREATE (describe)", resourceType, logicalId, void 0);
17848
+ }
17849
+ if (!targetGroupArn) throw new ProvisioningError(`Failed to recover TargetGroupArn for ${dbProxyName}/${targetGroupName} after create`, resourceType, logicalId);
17850
+ return {
17851
+ physicalId: targetGroupArn,
17852
+ attributes: {
17853
+ TargetGroupArn: targetGroupArn,
17854
+ TargetGroupName: targetGroupName
17855
+ }
17856
+ };
17857
+ }
17858
+ async update(logicalId, _physicalId, resourceType, _oldProperties, _newProperties) {
17859
+ throw new ResourceUpdateNotSupportedError(resourceType, logicalId, "destroy + redeploy; in-place updates of registered targets / connection pool config are not yet supported");
17860
+ }
17861
+ async delete(logicalId, physicalId, resourceType, properties, context) {
17862
+ const props = properties ?? {};
17863
+ const dbProxyName = props["DBProxyName"];
17864
+ const targetGroupName = props["TargetGroupName"] ?? "default";
17865
+ const dbClusterIdentifiers = props["DBClusterIdentifiers"];
17866
+ const dbInstanceIdentifiers = props["DBInstanceIdentifiers"];
17867
+ if (!dbProxyName) throw new ProvisioningError(`DBProxyName missing from state.properties for AWS::RDS::DBProxyTargetGroup ${logicalId}; cannot deregister targets. Manually run: aws rds deregister-db-proxy-targets --db-proxy-name <proxy-name> --target-group-name ${targetGroupName} ...`, resourceType, logicalId, physicalId);
17868
+ if (!(dbClusterIdentifiers && dbClusterIdentifiers.length > 0 || dbInstanceIdentifiers && dbInstanceIdentifiers.length > 0)) {
17869
+ this.logger.debug(`No targets registered for ${dbProxyName}/${targetGroupName}; nothing to deregister`);
17870
+ return;
17871
+ }
17872
+ this.logger.debug(`Deregistering targets from ${dbProxyName}/${targetGroupName}: clusters=[${dbClusterIdentifiers?.join(",") ?? ""}], instances=[${dbInstanceIdentifiers?.join(",") ?? ""}]`);
17873
+ try {
17874
+ await this.getClient().send(new DeregisterDBProxyTargetsCommand({
17875
+ DBProxyName: dbProxyName,
17876
+ TargetGroupName: targetGroupName,
17877
+ DBClusterIdentifiers: dbClusterIdentifiers,
17878
+ DBInstanceIdentifiers: dbInstanceIdentifiers
17879
+ }));
17880
+ } catch (error) {
17881
+ if (error instanceof DBProxyNotFoundFault || error instanceof DBProxyTargetGroupNotFoundFault || error instanceof DBProxyTargetNotFoundFault) {
17882
+ assertRegionMatch(await this.getClient().config.region(), context?.expectedRegion, resourceType, logicalId, physicalId);
17883
+ this.logger.debug(`${dbProxyName}/${targetGroupName} or its target is already gone, treating as success`);
17884
+ return;
17885
+ }
17886
+ throw this.wrapError(error, "DELETE", resourceType, logicalId, physicalId);
17887
+ }
17888
+ }
17889
+ async getAttribute(physicalId, _resourceType, attributeName) {
17890
+ switch (attributeName) {
17891
+ case "TargetGroupArn": return physicalId;
17892
+ case "TargetGroupName": return "default";
17893
+ default:
17894
+ this.logger.warn(`Unknown attribute ${attributeName} for AWS::RDS::DBProxyTargetGroup, returning undefined`);
17895
+ return;
17896
+ }
17897
+ }
17898
+ /**
17899
+ * Adopt an existing DBProxyTargetGroup into cdkd state.
17900
+ *
17901
+ * **Explicit override only.** The TargetGroup itself has no tags
17902
+ * (the parent DBProxy carries the cdkd path tag, not the wiring child),
17903
+ * so there is no `aws:cdk:path`-based auto-lookup. Users must pass
17904
+ * `--resource <logicalId>=<TargetGroupArn>`.
17905
+ */
17906
+ async import(input) {
17907
+ if (input.knownPhysicalId) return {
17908
+ physicalId: input.knownPhysicalId,
17909
+ attributes: {
17910
+ TargetGroupArn: input.knownPhysicalId,
17911
+ TargetGroupName: "default"
17912
+ }
17913
+ };
17914
+ return null;
17915
+ }
17916
+ wrapError(error, op, resourceType, logicalId, physicalId) {
17917
+ const message = error instanceof Error ? error.message : String(error);
17918
+ const cause = error instanceof Error ? error : void 0;
17919
+ return new ProvisioningError(`${op} failed for ${logicalId}: ${message}`, resourceType, logicalId, physicalId, cause);
17920
+ }
17921
+ };
17922
+
17751
17923
  //#endregion
17752
17924
  //#region src/provisioning/providers/docdb-provider.ts
17753
17925
  /**
@@ -28473,6 +28645,7 @@ function registerAllProviders(registry) {
28473
28645
  registry.register("AWS::RDS::DBSubnetGroup", rdsProvider);
28474
28646
  registry.register("AWS::RDS::DBCluster", rdsProvider);
28475
28647
  registry.register("AWS::RDS::DBInstance", rdsProvider);
28648
+ registry.register("AWS::RDS::DBProxyTargetGroup", new RDSDBProxyTargetGroupProvider());
28476
28649
  const docdbProvider = new DocDBProvider();
28477
28650
  registry.register("AWS::DocDB::DBSubnetGroup", docdbProvider);
28478
28651
  registry.register("AWS::DocDB::DBCluster", docdbProvider);
@@ -43452,7 +43625,7 @@ function reorderArgs(argv) {
43452
43625
  */
43453
43626
  async function main() {
43454
43627
  const program = new Command();
43455
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.103.1");
43628
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.103.2");
43456
43629
  program.addCommand(createBootstrapCommand());
43457
43630
  program.addCommand(createSynthCommand());
43458
43631
  program.addCommand(createListCommand());