@go-to-k/cdkd 0.230.2 → 0.230.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { A as withErrorHandling, B as generateResourceName, C as StackHasActiveImportsError, F as getLiveRenderer, H as withSkipPrefix, I as PATTERN_B_NAME_OPTIONS, L as PATTERN_B_NAME_PROPERTIES, M as getLogger, P as runStackBuffered, R as PATTERN_B_RESOURCE_TYPES, S as ResourceUpdateNotSupportedError, U as withStackName, V as generateResourceNameWithFallback, _ as MissingCdkCliError, a as assertRegionMatch, b as ProvisioningError, f as LocalInvokeBuildError$1, i as resolveExplicitPhysicalId, k as normalizeAwsError, l as CdkdError, m as LocalStartServiceError, n as matchesCdkPath, o as disableInstanceApiTermination, p as LocalMigrateError, r as normalizeAwsTagsToCfn, s as isTerminationProtectionPropagationError, t as CDK_PATH_TAG, v as NestedStackChildDirectDestroyError, w as StackTerminationProtectionError, x as ResourceTimeoutError, y as PartialFailureError } from "./import-helpers-DayvBD4T.js";
3
3
  import { a as setAwsClients, i as resetAwsClients, r as getAwsClients, t as AwsClients } from "./aws-clients-pjPwZz1r.js";
4
- import { $ as CFN_TEMPLATE_BODY_LIMIT, A as LockManager, B as runDockerForeground, C as findActionableSilentDrops, D as DiffCalculator, E as applyRoleArnIfSet, F as stringifyValue, G as getDefaultStateBucketName, H as AssetManifestLoader, I as WorkGraph, J as resolveCaptureObservedState, K as getLegacyStateBucketName, L as buildDockerImage, M as rebuildClientForBucketRegion, N as shouldRetainResource, O as DagBuilder, P as AssetPublisher, Q as warnDeprecatedNoPrefixCliFlag, R as formatDockerLoginError, S as ProviderRegistry, T as IntrinsicFunctionResolver, U as getDockerImageBySourceHash, V as runDockerStreaming, W as Synthesizer, X as resolveStateBucketWithDefault, Y as resolveSkipPrefix, Z as resolveStateBucketWithDefaultAndSource, _ as green, a as withRetry, b as IAMRoleProvider, c as computeImplicitDeleteEdges, d as isStatefulRecreateTargetSync, et as CFN_TEMPLATE_URL_LIMIT, f as renderStatefulReason, g as gray, h as cyan, i as withResourceDeadline, it as AssemblyReader, j as S3StateBackend, k as TemplateParser, l as extractDeploymentEventError, m as bold, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as findLargeInlineResources, o as isRetryableTransientError, ot as resolveBucketRegion, p as formatResourceLine, q as resolveApp, r as DeployEngine, rt as uploadCfnTemplate, s as IMPLICIT_DELETE_DEPENDENCIES, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as MIGRATE_TMP_PREFIX, u as MULTI_REGION_RECREATE_BLOCKED_TYPES, v as red, w as CloudControlProvider, x as collectInlinePolicyNamesManagedBySiblings, y as yellow, z as getDockerCmd } from "./deploy-engine-BHGrlCLe.js";
4
+ import { $ as CFN_TEMPLATE_BODY_LIMIT, A as LockManager, B as runDockerForeground, C as findActionableSilentDrops, D as DiffCalculator, E as applyRoleArnIfSet, F as stringifyValue, G as getDefaultStateBucketName, H as AssetManifestLoader, I as WorkGraph, J as resolveCaptureObservedState, K as getLegacyStateBucketName, L as buildDockerImage, M as rebuildClientForBucketRegion, N as shouldRetainResource, O as DagBuilder, P as AssetPublisher, Q as warnDeprecatedNoPrefixCliFlag, R as formatDockerLoginError, S as ProviderRegistry, T as IntrinsicFunctionResolver, U as getDockerImageBySourceHash, V as runDockerStreaming, W as Synthesizer, X as resolveStateBucketWithDefault, Y as resolveSkipPrefix, Z as resolveStateBucketWithDefaultAndSource, _ as green, a as withRetry, b as IAMRoleProvider, c as computeImplicitDeleteEdges, d as isStatefulRecreateTargetSync, et as CFN_TEMPLATE_URL_LIMIT, f as renderStatefulReason, g as gray, h as cyan, i as withResourceDeadline, it as AssemblyReader, j as S3StateBackend, k as TemplateParser, l as extractDeploymentEventError, m as bold, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as findLargeInlineResources, o as isRetryableTransientError, ot as resolveBucketRegion, p as formatResourceLine, q as resolveApp, r as DeployEngine, rt as uploadCfnTemplate, s as IMPLICIT_DELETE_DEPENDENCIES, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as MIGRATE_TMP_PREFIX, u as MULTI_REGION_RECREATE_BLOCKED_TYPES, v as red, w as CloudControlProvider, x as collectInlinePolicyNamesManagedBySiblings, y as yellow, z as getDockerCmd } from "./deploy-engine-DP5yW4f5.js";
5
5
  import { t as ASGProvider } from "./asg-provider-Dgj3loIG.js";
6
6
  import { AsyncLocalStorage } from "node:async_hooks";
7
7
  import { randomBytes, randomUUID } from "node:crypto";
@@ -1445,7 +1445,7 @@ const FLUSH_INTERVAL_MS = 2e3;
1445
1445
  const FLUSH_EVENT_THRESHOLD = 50;
1446
1446
  /** Build-time cdkd version, with a dev fallback for non-built contexts. */
1447
1447
  function getCdkdVersion() {
1448
- return "0.230.2";
1448
+ return "0.230.4";
1449
1449
  }
1450
1450
  /**
1451
1451
  * Generate a time-sortable unique run id, e.g.
@@ -55195,7 +55195,7 @@ function reorderArgs(argv) {
55195
55195
  async function main() {
55196
55196
  installPipeCloseHandler();
55197
55197
  const program = new Command();
55198
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.230.2");
55198
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.230.4");
55199
55199
  program.addCommand(createBootstrapCommand());
55200
55200
  program.addCommand(createSynthCommand());
55201
55201
  program.addCommand(createListCommand());
@@ -11,6 +11,7 @@ import { DescribeAvailabilityZonesCommand, DescribeImagesCommand, DescribeInstan
11
11
  import { DescribeTableCommand } from "@aws-sdk/client-dynamodb";
12
12
  import { CloudFormationClient, CreateChangeSetCommand, DeleteStackCommand, DescribeChangeSetCommand, DescribeTypeCommand, GetTemplateCommand, waitUntilChangeSetCreateComplete } from "@aws-sdk/client-cloudformation";
13
13
  import { GetRestApiCommand } from "@aws-sdk/client-api-gateway";
14
+ import { DescribeApiDestinationCommand, DescribeConnectionCommand } from "@aws-sdk/client-eventbridge";
14
15
  import { GetSecretValueCommand } from "@aws-sdk/client-secrets-manager";
15
16
  import { GetParameterCommand, SSMClient } from "@aws-sdk/client-ssm";
16
17
  import { GetCloudFrontOriginAccessIdentityCommand } from "@aws-sdk/client-cloudfront";
@@ -7842,6 +7843,37 @@ var CloudControlProvider = class {
7842
7843
  this.logger.debug(`Failed to get Lambda URL config for ${physicalId}: ${error instanceof Error ? error.message : String(error)}`);
7843
7844
  }
7844
7845
  break;
7846
+ case "AWS::Events::Connection":
7847
+ if (!enriched["Arn"] || !enriched["SecretArn"] || !enriched["ArnForPolicy"]) try {
7848
+ const conn = await getAwsClients().eventBridge.send(new DescribeConnectionCommand({ Name: physicalId }));
7849
+ if (conn.ConnectionArn) {
7850
+ if (!enriched["Arn"]) enriched["Arn"] = conn.ConnectionArn;
7851
+ if (!enriched["ArnForPolicy"]) {
7852
+ const lastSlash = conn.ConnectionArn.lastIndexOf("/");
7853
+ if (lastSlash > 0) enriched["ArnForPolicy"] = conn.ConnectionArn.slice(0, lastSlash);
7854
+ }
7855
+ }
7856
+ if (conn.SecretArn && !enriched["SecretArn"]) enriched["SecretArn"] = conn.SecretArn;
7857
+ this.logger.debug(`Enriched Events Connection ${physicalId} with Arn/SecretArn/ArnForPolicy from DescribeConnection`);
7858
+ } catch (error) {
7859
+ this.logger.debug(`Failed to enrich Events Connection ${physicalId}: ${error instanceof Error ? error.message : String(error)}`);
7860
+ }
7861
+ break;
7862
+ case "AWS::Events::ApiDestination":
7863
+ if (!enriched["Arn"] || !enriched["ArnForPolicy"]) try {
7864
+ const dest = await getAwsClients().eventBridge.send(new DescribeApiDestinationCommand({ Name: physicalId }));
7865
+ if (dest.ApiDestinationArn) {
7866
+ if (!enriched["Arn"]) enriched["Arn"] = dest.ApiDestinationArn;
7867
+ if (!enriched["ArnForPolicy"]) {
7868
+ const lastSlash = dest.ApiDestinationArn.lastIndexOf("/");
7869
+ if (lastSlash > 0) enriched["ArnForPolicy"] = dest.ApiDestinationArn.slice(0, lastSlash);
7870
+ }
7871
+ }
7872
+ this.logger.debug(`Enriched Events ApiDestination ${physicalId} with Arn/ArnForPolicy from DescribeApiDestination`);
7873
+ } catch (error) {
7874
+ this.logger.debug(`Failed to enrich Events ApiDestination ${physicalId}: ${error instanceof Error ? error.message : String(error)}`);
7875
+ }
7876
+ break;
7845
7877
  case "AWS::ElastiCache::ReplicationGroup":
7846
7878
  try {
7847
7879
  const rg = (await new ElastiCacheClient({}).send(new DescribeReplicationGroupsCommand({ ReplicationGroupId: physicalId }))).ReplicationGroups?.[0];
@@ -12565,6 +12597,78 @@ var DeployEngine = class {
12565
12597
  }
12566
12598
  }
12567
12599
  /**
12600
+ * Build a sibling context for the deploy-time `observedProperties`
12601
+ * capture of an IAM principal (`AWS::IAM::Role` / `::User` / `::Group`)
12602
+ * so that inline policies managed by a SEPARATE `AWS::IAM::Policy`
12603
+ * resource are filtered OUT of the captured `Policies` baseline —
12604
+ * exactly as the `cdkd drift` read path already does via
12605
+ * `buildReadCurrentStateContext`.
12606
+ *
12607
+ * Without this, the post-CREATE / post-UPDATE capture passes no
12608
+ * context, so `collectInlinePolicyNamesManagedBySiblings` no-ops. The
12609
+ * capture's `ListRolePolicies` then RACES the sibling
12610
+ * `AWS::IAM::Policy`'s `PutRolePolicy`: when the read lands after the
12611
+ * write, the sibling-managed `DefaultPolicy*` leaks into
12612
+ * `observedProperties.Policies`. A later `cdkd drift` (whose AWS-current
12613
+ * side filters it correctly) then reports phantom drift
12614
+ * `- Policies:[DefaultPolicy] / + Policies:[]` — a systemic false
12615
+ * positive that fires for essentially every Lambda / L2 construct whose
12616
+ * grant emits a `Default Policy`.
12617
+ *
12618
+ * The sibling relationship is fully determined by the TEMPLATE (which
12619
+ * `AWS::IAM::Policy` lists this principal in its `Roles`/`Users`/
12620
+ * `Groups`), so this is built from the template — deploy-order-
12621
+ * independent, immune to the race. Each matched sibling is synthesized
12622
+ * into the resolved-property shape
12623
+ * `collectInlinePolicyNamesManagedBySiblings` expects
12624
+ * (`{ [attachmentField]: [thisPrincipalPhysicalId], PolicyName }`).
12625
+ *
12626
+ * Returns `undefined` (no context) for non-IAM-principal types and when
12627
+ * no sibling policy attaches to the captured principal — both leave the
12628
+ * capture behaving exactly as before.
12629
+ */
12630
+ async buildObservedCaptureSiblings(resourceType, capturedLogicalId, capturedPhysicalId, template, stateResources, stackName, parameterValues, conditions) {
12631
+ if (this.options.captureObservedState !== true) return void 0;
12632
+ const attachmentField = resourceType === "AWS::IAM::Role" ? "Roles" : resourceType === "AWS::IAM::User" ? "Users" : resourceType === "AWS::IAM::Group" ? "Groups" : void 0;
12633
+ if (!attachmentField) return void 0;
12634
+ const resources = template?.Resources;
12635
+ if (!resources) return void 0;
12636
+ let resolverContext;
12637
+ const isRefTo = (value, logicalId) => typeof value === "object" && value !== null && !Array.isArray(value) && value["Ref"] === logicalId;
12638
+ const siblings = {};
12639
+ for (const [lid, res] of Object.entries(resources)) {
12640
+ if (lid === capturedLogicalId) continue;
12641
+ if (res.Type !== "AWS::IAM::Policy") continue;
12642
+ const props = res.Properties ?? {};
12643
+ const attachments = props[attachmentField];
12644
+ if (!Array.isArray(attachments)) continue;
12645
+ if (!attachments.some((a) => isRefTo(a, capturedLogicalId) || a === capturedPhysicalId)) continue;
12646
+ let policyName = props["PolicyName"];
12647
+ if (policyName !== void 0 && typeof policyName !== "string") {
12648
+ resolverContext ??= this.buildResolverContext({
12649
+ template,
12650
+ resources: stateResources,
12651
+ ...parameterValues && { parameters: parameterValues },
12652
+ ...conditions && { conditions }
12653
+ }, stackName);
12654
+ try {
12655
+ policyName = await this.resolver.resolve(policyName, resolverContext);
12656
+ } catch {
12657
+ continue;
12658
+ }
12659
+ }
12660
+ if (typeof policyName !== "string") continue;
12661
+ siblings[lid] = {
12662
+ resourceType: "AWS::IAM::Policy",
12663
+ properties: {
12664
+ [attachmentField]: [capturedPhysicalId],
12665
+ PolicyName: policyName
12666
+ }
12667
+ };
12668
+ }
12669
+ return Object.keys(siblings).length > 0 ? { siblings } : void 0;
12670
+ }
12671
+ /**
12568
12672
  * Kick off `provider.readCurrentState` for every resource in the
12569
12673
  * loaded state that lacks `observedProperties` (e.g. state written
12570
12674
  * by a pre-v3 binary, or a v3 record where a NO_CHANGE-skipped
@@ -13273,7 +13377,8 @@ var DeployEngine = class {
13273
13377
  ...templateAttrs,
13274
13378
  provisionedBy: createDecision.provisionedBy
13275
13379
  };
13276
- this.kickOffObservedCapture(createProvider, logicalId, result.physicalId, resourceType, resolvedProps);
13380
+ const createCaptureSiblings = await this.buildObservedCaptureSiblings(resourceType, logicalId, result.physicalId, template, stateResources, stackName, parameterValues, conditions);
13381
+ this.kickOffObservedCapture(createProvider, logicalId, result.physicalId, resourceType, resolvedProps, createCaptureSiblings);
13277
13382
  if (counts) counts.created++;
13278
13383
  if (progress) progress.current++;
13279
13384
  const createPrefix = progress ? `[${progress.current}/${progress.total}] ` : " ";
@@ -13436,7 +13541,8 @@ var DeployEngine = class {
13436
13541
  ...this.extractTemplateAttributes(template, logicalId),
13437
13542
  provisionedBy: resultProvisionedBy
13438
13543
  };
13439
- this.kickOffObservedCapture(updateProvider, logicalId, result.physicalId, resourceType, resolvedProps);
13544
+ const updateCaptureSiblings = await this.buildObservedCaptureSiblings(resourceType, logicalId, result.physicalId, template, stateResources, stackName, parameterValues, conditions);
13545
+ this.kickOffObservedCapture(updateProvider, logicalId, result.physicalId, resourceType, resolvedProps, updateCaptureSiblings);
13440
13546
  if (counts) counts.updated++;
13441
13547
  if (progress) progress.current++;
13442
13548
  const updatePrefix = progress ? `[${progress.current}/${progress.total}] ` : " ";
@@ -13678,4 +13784,4 @@ var DeployEngine = class {
13678
13784
 
13679
13785
  //#endregion
13680
13786
  export { CFN_TEMPLATE_BODY_LIMIT as $, LockManager as A, runDockerForeground as B, findActionableSilentDrops as C, DiffCalculator as D, applyRoleArnIfSet as E, stringifyValue as F, getDefaultStateBucketName as G, AssetManifestLoader as H, WorkGraph as I, resolveCaptureObservedState as J, getLegacyStateBucketName as K, buildDockerImage as L, rebuildClientForBucketRegion as M, shouldRetainResource as N, DagBuilder as O, AssetPublisher as P, warnDeprecatedNoPrefixCliFlag as Q, formatDockerLoginError as R, ProviderRegistry as S, IntrinsicFunctionResolver as T, getDockerImageBySourceHash as U, runDockerStreaming as V, Synthesizer as W, resolveStateBucketWithDefault as X, resolveSkipPrefix as Y, resolveStateBucketWithDefaultAndSource as Z, green as _, withRetry as a, clearBucketRegionCache as at, IAMRoleProvider as b, computeImplicitDeleteEdges as c, isStatefulRecreateTargetSync as d, CFN_TEMPLATE_URL_LIMIT as et, renderStatefulReason as f, gray as g, cyan as h, withResourceDeadline as i, AssemblyReader as it, S3StateBackend as j, TemplateParser as k, extractDeploymentEventError as l, bold as m, DEFAULT_RESOURCE_WARN_AFTER_MS as n, findLargeInlineResources as nt, isRetryableTransientError as o, resolveBucketRegion as ot, formatResourceLine as p, resolveApp as q, DeployEngine as r, uploadCfnTemplate as rt, IMPLICIT_DELETE_DEPENDENCIES as s, DEFAULT_RESOURCE_TIMEOUT_MS as t, MIGRATE_TMP_PREFIX as tt, MULTI_REGION_RECREATE_BLOCKED_TYPES as u, red as v, CloudControlProvider as w, collectInlinePolicyNamesManagedBySiblings as x, yellow as y, getDockerCmd as z };
13681
- //# sourceMappingURL=deploy-engine-BHGrlCLe.js.map
13787
+ //# sourceMappingURL=deploy-engine-DP5yW4f5.js.map