@go-to-k/cdkd 0.216.0 → 0.218.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
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { a as setAwsClients, i as resetAwsClients, r as getAwsClients, t as AwsClients } from "./aws-clients-DWUnLza1.js";
3
- import { $ as CFN_TEMPLATE_URL_LIMIT, A as DagBuilder, B as getDockerCmd, C as CloudControlProvider, D as IntrinsicFunctionResolver, Dt as withErrorHandling, E as isTerminationProtectionPropagationError, Et as normalizeAwsError, F as AssetPublisher, Ft as generateResourceName, G as getLegacyStateBucketName, H as runDockerStreaming, I as stringifyValue, It as generateResourceNameWithFallback, J as resolveSkipPrefix, K as resolveApp, L as WorkGraph, Lt as withSkipPrefix, M as LockManager, Mt as getLiveRenderer, N as S3StateBackend, Nt as PATTERN_B_NAME_PROPERTIES, O as applyRoleArnIfSet, P as shouldRetainResource, Pt as PATTERN_B_RESOURCE_TYPES, Q as CFN_TEMPLATE_BODY_LIMIT, R as buildDockerImage, Rt as withStackName, S as findActionableSilentDrops, T as disableInstanceApiTermination, U as Synthesizer, V as runDockerForeground, W as getDefaultStateBucketName, X as resolveStateBucketWithDefaultAndSource, Y as resolveStateBucketWithDefault, Z as warnDeprecatedNoPrefixCliFlag, _ as CDK_PATH_TAG, _t as ProvisioningError, a as withRetry, at as resolveBucketRegion, b as resolveExplicitPhysicalId, bt as StackHasActiveImportsError, c as formatResourceLine, d as gray, dt as LocalMigrateError, et as MIGRATE_TMP_PREFIX, f as green, ft as LocalStartServiceError, g as collectInlinePolicyNamesManagedBySiblings, gt as PartialFailureError, h as IAMRoleProvider, ht as NestedStackChildDirectDestroyError, i as withResourceDeadline, j as TemplateParser, jt as runStackBuffered, k as DiffCalculator, kt as getLogger, l as bold, m as yellow, mt as MissingCdkCliError, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as uploadCfnTemplate, o as isRetryableTransientError, p as red, q as resolveCaptureObservedState, r as DeployEngine, rt as AssemblyReader, s as IMPLICIT_DELETE_DEPENDENCIES, st as CdkdError, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as findLargeInlineResources, u as cyan, ut as LocalInvokeBuildError$1, v as matchesCdkPath, vt as ResourceTimeoutError, w as assertRegionMatch, x as ProviderRegistry, xt as StackTerminationProtectionError, y as normalizeAwsTagsToCfn, yt as ResourceUpdateNotSupportedError, z as formatDockerLoginError } from "./deploy-engine-hq-5c3kO.js";
3
+ import { $ as CFN_TEMPLATE_URL_LIMIT, A as DagBuilder, B as getDockerCmd, C as CloudControlProvider, D as IntrinsicFunctionResolver, Dt as withErrorHandling, E as isTerminationProtectionPropagationError, Et as normalizeAwsError, F as AssetPublisher, Ft as generateResourceName, G as getLegacyStateBucketName, H as runDockerStreaming, I as stringifyValue, It as generateResourceNameWithFallback, J as resolveSkipPrefix, K as resolveApp, L as WorkGraph, Lt as withSkipPrefix, M as LockManager, Mt as getLiveRenderer, N as S3StateBackend, Nt as PATTERN_B_NAME_PROPERTIES, O as applyRoleArnIfSet, P as shouldRetainResource, Pt as PATTERN_B_RESOURCE_TYPES, Q as CFN_TEMPLATE_BODY_LIMIT, R as buildDockerImage, Rt as withStackName, S as findActionableSilentDrops, T as disableInstanceApiTermination, U as Synthesizer, V as runDockerForeground, W as getDefaultStateBucketName, X as resolveStateBucketWithDefaultAndSource, Y as resolveStateBucketWithDefault, Z as warnDeprecatedNoPrefixCliFlag, _ as CDK_PATH_TAG, _t as ProvisioningError, a as withRetry, at as resolveBucketRegion, b as resolveExplicitPhysicalId, bt as StackHasActiveImportsError, c as formatResourceLine, d as gray, dt as LocalMigrateError, et as MIGRATE_TMP_PREFIX, f as green, ft as LocalStartServiceError, g as collectInlinePolicyNamesManagedBySiblings, gt as PartialFailureError, h as IAMRoleProvider, ht as NestedStackChildDirectDestroyError, i as withResourceDeadline, j as TemplateParser, jt as runStackBuffered, k as DiffCalculator, kt as getLogger, l as bold, m as yellow, mt as MissingCdkCliError, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as uploadCfnTemplate, o as isRetryableTransientError, p as red, q as resolveCaptureObservedState, r as DeployEngine, rt as AssemblyReader, s as IMPLICIT_DELETE_DEPENDENCIES, st as CdkdError, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as findLargeInlineResources, u as cyan, ut as LocalInvokeBuildError$1, v as matchesCdkPath, vt as ResourceTimeoutError, w as assertRegionMatch, x as ProviderRegistry, xt as StackTerminationProtectionError, y as normalizeAwsTagsToCfn, yt as ResourceUpdateNotSupportedError, z as formatDockerLoginError } from "./deploy-engine-DXr1irt9.js";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  import { randomBytes, randomUUID } from "node:crypto";
6
6
  import { CopyObjectCommand, CreateBucketCommand, DeleteBucketAnalyticsConfigurationCommand, DeleteBucketCommand, DeleteBucketCorsCommand, DeleteBucketIntelligentTieringConfigurationCommand, DeleteBucketInventoryConfigurationCommand, DeleteBucketLifecycleCommand, DeleteBucketMetricsConfigurationCommand, DeleteBucketPolicyCommand, DeleteBucketReplicationCommand, DeleteBucketTaggingCommand, DeleteBucketWebsiteCommand, DeleteObjectsCommand, GetBucketAccelerateConfigurationCommand, GetBucketCorsCommand, GetBucketEncryptionCommand, GetBucketLifecycleConfigurationCommand, GetBucketLocationCommand, GetBucketLoggingCommand, GetBucketNotificationConfigurationCommand, GetBucketPolicyCommand, GetBucketReplicationCommand, GetBucketTaggingCommand, GetBucketVersioningCommand, GetBucketWebsiteCommand, GetObjectCommand, GetObjectLockConfigurationCommand, GetPublicAccessBlockCommand, HeadBucketCommand, ListBucketAnalyticsConfigurationsCommand, ListBucketIntelligentTieringConfigurationsCommand, ListBucketInventoryConfigurationsCommand, ListBucketMetricsConfigurationsCommand, ListBucketsCommand, ListDirectoryBucketsCommand, ListObjectVersionsCommand, ListObjectsV2Command, NoSuchBucket, PutBucketAccelerateConfigurationCommand, PutBucketAnalyticsConfigurationCommand, PutBucketCorsCommand, PutBucketEncryptionCommand, PutBucketIntelligentTieringConfigurationCommand, PutBucketInventoryConfigurationCommand, PutBucketLifecycleConfigurationCommand, PutBucketLoggingCommand, PutBucketMetricsConfigurationCommand, PutBucketNotificationConfigurationCommand, PutBucketOwnershipControlsCommand, PutBucketPolicyCommand, PutBucketReplicationCommand, PutBucketTaggingCommand, PutBucketVersioningCommand, PutBucketWebsiteCommand, PutObjectCommand, PutObjectLockConfigurationCommand, PutPublicAccessBlockCommand, S3Client, S3ServiceException } from "@aws-sdk/client-s3";
@@ -9,8 +9,8 @@ import { CreateQueueCommand, DeleteQueueCommand, GetQueueAttributesCommand, GetQ
9
9
  import { CreateTopicCommand, DeleteTopicCommand, GetSubscriptionAttributesCommand, GetTopicAttributesCommand, ListTagsForResourceCommand, ListTopicsCommand, NotFoundException, SNSClient, SetTopicAttributesCommand, SubscribeCommand, TagResourceCommand, UnsubscribeCommand, UntagResourceCommand } from "@aws-sdk/client-sns";
10
10
  import { AddPermissionCommand, CreateEventSourceMappingCommand, CreateFunctionCommand, CreateFunctionUrlConfigCommand, DeleteEventSourceMappingCommand, DeleteFunctionCommand, DeleteFunctionConcurrencyCommand, DeleteFunctionUrlConfigCommand, DeleteLayerVersionCommand, GetEventSourceMappingCommand, GetFunctionCommand, GetFunctionConcurrencyCommand, GetFunctionRecursionConfigCommand, GetFunctionUrlConfigCommand, GetLayerVersionByArnCommand, GetPolicyCommand as GetPolicyCommand$1, LambdaClient, ListFunctionsCommand, ListLayersCommand, ListTagsCommand, PublishLayerVersionCommand, PutFunctionConcurrencyCommand, PutFunctionRecursionConfigCommand, RemovePermissionCommand, ResourceNotFoundException, TagResourceCommand as TagResourceCommand$1, UntagResourceCommand as UntagResourceCommand$1, UpdateEventSourceMappingCommand, UpdateFunctionCodeCommand, UpdateFunctionConfigurationCommand, UpdateFunctionUrlConfigCommand, waitUntilFunctionUpdatedV2 } from "@aws-sdk/client-lambda";
11
11
  import { AssumeRoleCommand, GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts";
12
- import { AssociateRouteTableCommand, AttachInternetGatewayCommand, AuthorizeSecurityGroupEgressCommand, AuthorizeSecurityGroupIngressCommand, CreateInternetGatewayCommand, CreateNatGatewayCommand, CreateNetworkAclCommand, CreateNetworkAclEntryCommand, CreateRouteCommand, CreateRouteTableCommand, CreateSecurityGroupCommand, CreateSubnetCommand, CreateTagsCommand, CreateVpcCommand, DeleteInternetGatewayCommand, DeleteNatGatewayCommand, DeleteNetworkAclCommand, DeleteNetworkAclEntryCommand, DeleteNetworkInterfaceCommand, DeleteRouteCommand, DeleteRouteTableCommand, DeleteSecurityGroupCommand, DeleteSubnetCommand, DeleteTagsCommand, DeleteVpcCommand, DescribeAvailabilityZonesCommand, DescribeInstanceAttributeCommand, DescribeInstancesCommand, DescribeInternetGatewaysCommand, DescribeNatGatewaysCommand, DescribeNetworkAclsCommand, DescribeNetworkInterfacesCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeVolumesCommand, DescribeVpcAttributeCommand, DescribeVpcsCommand, DetachInternetGatewayCommand, DisassociateRouteTableCommand, EC2Client, ModifySubnetAttributeCommand, ModifyVpcAttributeCommand, ReplaceNetworkAclAssociationCommand, RevokeSecurityGroupEgressCommand, RevokeSecurityGroupIngressCommand, RunInstancesCommand, TerminateInstancesCommand, waitUntilInstanceRunning, waitUntilInstanceTerminated, waitUntilNatGatewayAvailable, waitUntilNatGatewayDeleted } from "@aws-sdk/client-ec2";
13
- import { CreateTableCommand, DeleteTableCommand, DescribeContinuousBackupsCommand, DescribeContributorInsightsCommand, DescribeKinesisStreamingDestinationCommand, DescribeTableCommand, DescribeTimeToLiveCommand, DynamoDBClient, ListTablesCommand, ListTagsOfResourceCommand, ResourceNotFoundException as ResourceNotFoundException$1, TagResourceCommand as TagResourceCommand$2, UntagResourceCommand as UntagResourceCommand$2, UpdateContinuousBackupsCommand, UpdateTableCommand, UpdateTimeToLiveCommand } from "@aws-sdk/client-dynamodb";
12
+ import { AssociateRouteTableCommand, AttachInternetGatewayCommand, AuthorizeSecurityGroupEgressCommand, AuthorizeSecurityGroupIngressCommand, CreateInternetGatewayCommand, CreateNatGatewayCommand, CreateNetworkAclCommand, CreateNetworkAclEntryCommand, CreateRouteCommand, CreateRouteTableCommand, CreateSecurityGroupCommand, CreateSubnetCommand, CreateTagsCommand, CreateVpcCommand, DeleteInternetGatewayCommand, DeleteNatGatewayCommand, DeleteNetworkAclCommand, DeleteNetworkAclEntryCommand, DeleteNetworkInterfaceCommand, DeleteRouteCommand, DeleteRouteTableCommand, DeleteSecurityGroupCommand, DeleteSubnetCommand, DeleteTagsCommand, DeleteVpcCommand, DescribeAvailabilityZonesCommand, DescribeInstanceAttributeCommand, DescribeInstanceCreditSpecificationsCommand, DescribeInstancesCommand, DescribeInternetGatewaysCommand, DescribeNatGatewaysCommand, DescribeNetworkAclsCommand, DescribeNetworkInterfacesCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeVolumesCommand, DescribeVpcAttributeCommand, DescribeVpcsCommand, DetachInternetGatewayCommand, DisassociateRouteTableCommand, EC2Client, ModifyInstanceAttributeCommand, ModifyInstanceCreditSpecificationCommand, ModifyInstanceMetadataOptionsCommand, ModifySubnetAttributeCommand, ModifyVpcAttributeCommand, MonitorInstancesCommand, ReplaceNetworkAclAssociationCommand, RevokeSecurityGroupEgressCommand, RevokeSecurityGroupIngressCommand, RunInstancesCommand, TerminateInstancesCommand, UnmonitorInstancesCommand, waitUntilInstanceRunning, waitUntilInstanceTerminated, waitUntilNatGatewayAvailable, waitUntilNatGatewayDeleted } from "@aws-sdk/client-ec2";
13
+ import { CreateTableCommand, DeleteResourcePolicyCommand, DeleteTableCommand, DescribeContinuousBackupsCommand, DescribeContributorInsightsCommand, DescribeKinesisStreamingDestinationCommand, DescribeTableCommand, DescribeTimeToLiveCommand, DisableKinesisStreamingDestinationCommand, DynamoDBClient, EnableKinesisStreamingDestinationCommand, GetResourcePolicyCommand, ListTablesCommand, ListTagsOfResourceCommand, PutResourcePolicyCommand, ResourceNotFoundException as ResourceNotFoundException$1, TagResourceCommand as TagResourceCommand$2, UntagResourceCommand as UntagResourceCommand$2, UpdateContinuousBackupsCommand, UpdateContributorInsightsCommand, UpdateTableCommand, UpdateTimeToLiveCommand } from "@aws-sdk/client-dynamodb";
14
14
  import { CloudFormationClient, CreateChangeSetCommand, DeleteChangeSetCommand, DeleteStackCommand, DescribeChangeSetCommand, DescribeStackEventsCommand, DescribeStackResourcesCommand, DescribeStacksCommand, DescribeTypeCommand, ExecuteChangeSetCommand, GetTemplateCommand, UpdateStackCommand, waitUntilChangeSetCreateComplete, waitUntilStackDeleteComplete, waitUntilStackImportComplete, waitUntilStackUpdateComplete } from "@aws-sdk/client-cloudformation";
15
15
  import { APIGatewayClient, CreateAuthorizerCommand, CreateDeploymentCommand, CreateResourceCommand, CreateStageCommand, DeleteAuthorizerCommand, DeleteDeploymentCommand, DeleteMethodCommand, DeleteResourceCommand, DeleteStageCommand, GetAccountCommand, GetAuthorizerCommand, GetDeploymentCommand, GetMethodCommand, GetResourceCommand, GetStageCommand, NotFoundException as NotFoundException$1, PutIntegrationCommand, PutIntegrationResponseCommand, PutMethodCommand, PutMethodResponseCommand, TagResourceCommand as TagResourceCommand$3, UntagResourceCommand as UntagResourceCommand$3, UpdateAccountCommand, UpdateAuthorizerCommand, UpdateMethodCommand, UpdateStageCommand } from "@aws-sdk/client-api-gateway";
16
16
  import { CreateEventBusCommand, DeleteEventBusCommand, DeleteRuleCommand, DescribeEventBusCommand, DescribeRuleCommand, EventBridgeClient, ListEventBusesCommand, ListRulesCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$1, ListTargetsByRuleCommand, PutRuleCommand, PutTargetsCommand, RemoveTargetsCommand, ResourceNotFoundException as ResourceNotFoundException$2, TagResourceCommand as TagResourceCommand$4, UntagResourceCommand as UntagResourceCommand$4, UpdateEventBusCommand } from "@aws-sdk/client-eventbridge";
@@ -8997,8 +8997,12 @@ var DynamoDBTableProvider = class {
8997
8997
  "DeletionProtectionEnabled",
8998
8998
  "TableClass",
8999
8999
  "PointInTimeRecoverySpecification",
9000
- "TimeToLiveSpecification"
9000
+ "TimeToLiveSpecification",
9001
+ "ResourcePolicy",
9002
+ "KinesisStreamSpecification",
9003
+ "ContributorInsightsSpecification"
9001
9004
  ])]]);
9005
+ unhandledByDesign = new Map([["AWS::DynamoDB::Table", new Map([["ImportSourceSpecification", "S3 import uses the separate ImportTable API (not CreateTable) and is create-only with no readback; deferred to a dedicated import-from-S3 PR"]])]]);
9002
9006
  constructor() {
9003
9007
  const awsClients = getAwsClients();
9004
9008
  this.dynamoDBClient = awsClients.dynamoDB;
@@ -9041,12 +9045,16 @@ var DynamoDBTableProvider = class {
9041
9045
  if (properties["Tags"]) createParams.Tags = properties["Tags"];
9042
9046
  if (properties["DeletionProtectionEnabled"] !== void 0) createParams.DeletionProtectionEnabled = properties["DeletionProtectionEnabled"];
9043
9047
  if (properties["TableClass"]) createParams.TableClass = properties["TableClass"];
9048
+ const createResourcePolicyDoc = this.extractResourcePolicyDocument(properties["ResourcePolicy"]);
9049
+ if (createResourcePolicyDoc !== void 0) createParams.ResourcePolicy = createResourcePolicyDoc;
9044
9050
  await this.dynamoDBClient.send(new CreateTableCommand(createParams));
9045
9051
  tableCreated = true;
9046
9052
  this.logger.debug(`CreateTable initiated for ${tableName}, waiting for ACTIVE status`);
9047
9053
  const tableInfo = await this.waitForTableActive(tableName);
9048
9054
  await this.applyPointInTimeRecovery(tableName, properties["PointInTimeRecoverySpecification"]);
9049
9055
  await this.applyTimeToLive(tableName, properties["TimeToLiveSpecification"]);
9056
+ await this.applyKinesisStreamingDestination(tableName, properties["KinesisStreamSpecification"]);
9057
+ await this.applyContributorInsights(tableName, properties["ContributorInsightsSpecification"]);
9050
9058
  this.logger.debug(`Successfully created DynamoDB table ${logicalId}: ${tableName}`);
9051
9059
  return {
9052
9060
  physicalId: tableName,
@@ -9101,6 +9109,12 @@ var DynamoDBTableProvider = class {
9101
9109
  }
9102
9110
  if (JSON.stringify(properties["PointInTimeRecoverySpecification"]) !== JSON.stringify(previousProperties["PointInTimeRecoverySpecification"])) await this.applyPointInTimeRecovery(physicalId, properties["PointInTimeRecoverySpecification"], previousProperties["PointInTimeRecoverySpecification"]);
9103
9111
  if (JSON.stringify(properties["TimeToLiveSpecification"]) !== JSON.stringify(previousProperties["TimeToLiveSpecification"])) await this.applyTimeToLive(physicalId, properties["TimeToLiveSpecification"], previousProperties["TimeToLiveSpecification"]);
9112
+ if (JSON.stringify(properties["ResourcePolicy"]) !== JSON.stringify(previousProperties["ResourcePolicy"])) {
9113
+ if (!table?.TableArn) throw new ProvisioningError(`Cannot apply ResourcePolicy change for DynamoDB table ${logicalId}: DescribeTable returned no TableArn`, resourceType, logicalId, physicalId);
9114
+ await this.applyResourcePolicy(table.TableArn, properties["ResourcePolicy"], previousProperties["ResourcePolicy"]);
9115
+ }
9116
+ if (JSON.stringify(properties["KinesisStreamSpecification"]) !== JSON.stringify(previousProperties["KinesisStreamSpecification"])) await this.applyKinesisStreamingDestination(physicalId, properties["KinesisStreamSpecification"], previousProperties["KinesisStreamSpecification"]);
9117
+ if (JSON.stringify(properties["ContributorInsightsSpecification"]) !== JSON.stringify(previousProperties["ContributorInsightsSpecification"])) await this.applyContributorInsights(physicalId, properties["ContributorInsightsSpecification"], previousProperties["ContributorInsightsSpecification"]);
9104
9118
  return {
9105
9119
  physicalId,
9106
9120
  wasReplaced: false,
@@ -9275,6 +9289,114 @@ var DynamoDBTableProvider = class {
9275
9289
  }
9276
9290
  }
9277
9291
  /**
9292
+ * Extract the resource-policy document from the CFn `ResourcePolicy`
9293
+ * property and serialize it to the JSON string the DynamoDB APIs expect.
9294
+ *
9295
+ * CFn shape is `{ PolicyDocument: <JSON object | string> }`. Both
9296
+ * `CreateTable.ResourcePolicy` and `PutResourcePolicy.Policy` take a JSON
9297
+ * STRING, so a document already supplied as a string is passed through
9298
+ * verbatim (CDK can emit either an object or, post-intrinsic-resolution, a
9299
+ * string). Returns `undefined` when there is no policy document to apply.
9300
+ */
9301
+ extractResourcePolicyDocument(spec) {
9302
+ if (spec === void 0 || spec === null) return void 0;
9303
+ const doc = spec["PolicyDocument"];
9304
+ if (doc === void 0 || doc === null) return void 0;
9305
+ return typeof doc === "string" ? doc : JSON.stringify(doc);
9306
+ }
9307
+ /**
9308
+ * Apply the table's `ResourcePolicy` via the separate `PutResourcePolicy` /
9309
+ * `DeleteResourcePolicy` APIs (used by `update()` — `create()` rides the
9310
+ * policy on CreateTable directly). On removal — when the template drops the
9311
+ * block but it was present before — the existing policy is deleted.
9312
+ */
9313
+ async applyResourcePolicy(tableArn, spec, previousSpec) {
9314
+ const policyDoc = this.extractResourcePolicyDocument(spec);
9315
+ if (policyDoc !== void 0) {
9316
+ await this.retryOnTransientControlPlane(() => this.dynamoDBClient.send(new PutResourcePolicyCommand({
9317
+ ResourceArn: tableArn,
9318
+ Policy: policyDoc
9319
+ })), `put ResourcePolicy on ${tableArn}`);
9320
+ this.logger.debug(`Put ResourcePolicy on DynamoDB table ${tableArn}`);
9321
+ return;
9322
+ }
9323
+ if (previousSpec !== void 0 && previousSpec !== null) try {
9324
+ await this.retryOnTransientControlPlane(() => this.dynamoDBClient.send(new DeleteResourcePolicyCommand({ ResourceArn: tableArn })), `delete ResourcePolicy on ${tableArn}`);
9325
+ this.logger.debug(`Deleted ResourcePolicy on DynamoDB table ${tableArn}`);
9326
+ } catch (error) {
9327
+ if (!(error instanceof ResourceNotFoundException$1)) throw error;
9328
+ }
9329
+ }
9330
+ /**
9331
+ * Apply the table's `KinesisStreamSpecification` via the separate
9332
+ * Enable/Disable/Update `KinesisStreamingDestination` APIs (NOT a field on
9333
+ * CreateTable). CFn shape is
9334
+ * `{ StreamArn: string, ApproximateCreationDateTimePrecision?: 'MICROSECOND' | 'MILLISECOND' }`.
9335
+ *
9336
+ * Called from both `create()` (after the table is ACTIVE) and `update()`
9337
+ * (only when the value changed). On `update()`-side removal — template drops
9338
+ * the block but it was present before — streaming is disabled to the PREVIOUS
9339
+ * stream ARN. A same-ARN change of only the precision is a deliberate no-op
9340
+ * (re-enabling against an already-enabled stream errors), matching the
9341
+ * pre-existing WarmThroughput "no clean remap" stance; precision changes flow
9342
+ * through on the create / first-enable path.
9343
+ */
9344
+ async applyKinesisStreamingDestination(tableName, spec, previousSpec) {
9345
+ const newArn = this.extractKinesisStreamArn(spec);
9346
+ const prevArn = this.extractKinesisStreamArn(previousSpec);
9347
+ if (newArn === prevArn) {
9348
+ if (newArn && JSON.stringify(spec?.["ApproximateCreationDateTimePrecision"]) !== JSON.stringify(previousSpec?.["ApproximateCreationDateTimePrecision"])) this.logger.warn(`Kinesis streaming ApproximateCreationDateTimePrecision change on ${tableName} was not applied (same stream ARN; precision-only updates are not yet supported)`);
9349
+ return;
9350
+ }
9351
+ if (prevArn) {
9352
+ await this.retryOnTransientControlPlane(() => this.dynamoDBClient.send(new DisableKinesisStreamingDestinationCommand({
9353
+ TableName: tableName,
9354
+ StreamArn: prevArn
9355
+ })), `disable Kinesis streaming on ${tableName}`);
9356
+ this.logger.debug(`Disabled Kinesis streaming destination ${prevArn} on DynamoDB table ${tableName}`);
9357
+ }
9358
+ if (newArn) {
9359
+ const precision = spec["ApproximateCreationDateTimePrecision"];
9360
+ await this.retryOnTransientControlPlane(() => this.dynamoDBClient.send(new EnableKinesisStreamingDestinationCommand({
9361
+ TableName: tableName,
9362
+ StreamArn: newArn,
9363
+ ...precision ? { EnableKinesisStreamingConfiguration: { ApproximateCreationDateTimePrecision: precision } } : {}
9364
+ })), `enable Kinesis streaming on ${tableName}`);
9365
+ this.logger.debug(`Enabled Kinesis streaming destination ${newArn} on DynamoDB table ${tableName}`);
9366
+ }
9367
+ }
9368
+ extractKinesisStreamArn(spec) {
9369
+ if (spec === void 0 || spec === null) return void 0;
9370
+ const arn = spec["StreamArn"];
9371
+ return typeof arn === "string" ? arn : void 0;
9372
+ }
9373
+ /**
9374
+ * Apply the table's `ContributorInsightsSpecification` via the separate
9375
+ * `UpdateContributorInsights` API (NOT a field on CreateTable). CFn shape is
9376
+ * `{ Enabled: boolean, Mode?: 'ACCESSED_AND_THROTTLED_KEYS' | 'THROTTLED_KEYS' }`.
9377
+ *
9378
+ * Called from both `create()` (after the table is ACTIVE) and `update()`
9379
+ * (only when the value changed). On `update()`-side removal — template drops
9380
+ * the block but it was present before — insights is disabled.
9381
+ */
9382
+ async applyContributorInsights(tableName, spec, previousSpec) {
9383
+ let action;
9384
+ let mode;
9385
+ if (spec !== void 0 && spec !== null) {
9386
+ const s = spec;
9387
+ const enabled = Boolean(s["Enabled"]);
9388
+ action = enabled ? "ENABLE" : "DISABLE";
9389
+ if (enabled && s["Mode"] !== void 0) mode = s["Mode"];
9390
+ } else if (previousSpec !== void 0 && previousSpec !== null) action = "DISABLE";
9391
+ if (action === void 0) return;
9392
+ await this.retryOnTransientControlPlane(() => this.dynamoDBClient.send(new UpdateContributorInsightsCommand({
9393
+ TableName: tableName,
9394
+ ContributorInsightsAction: action,
9395
+ ...mode ? { ContributorInsightsMode: mode } : {}
9396
+ })), `set ContributorInsights on ${tableName}`);
9397
+ this.logger.debug(`Set ContributorInsightsAction=${action}${mode !== void 0 ? ` Mode=${mode}` : ""} on DynamoDB table ${tableName}`);
9398
+ }
9399
+ /**
9278
9400
  * Poll DescribeTable until the table reaches ACTIVE status
9279
9401
  *
9280
9402
  * Uses a tight polling loop (1s intervals) instead of CC API's exponential
@@ -9425,6 +9547,39 @@ var DynamoDBTableProvider = class {
9425
9547
  } catch (err) {
9426
9548
  this.logger.debug(`Could not read TimeToLive for ${physicalId}: ${err instanceof Error ? err.message : String(err)}`);
9427
9549
  }
9550
+ if (table.TableArn) try {
9551
+ const rpResp = await this.dynamoDBClient.send(new GetResourcePolicyCommand({ ResourceArn: table.TableArn }));
9552
+ if (rpResp.Policy) {
9553
+ let doc = rpResp.Policy;
9554
+ try {
9555
+ doc = JSON.parse(rpResp.Policy);
9556
+ } catch {}
9557
+ result["ResourcePolicy"] = { PolicyDocument: doc };
9558
+ }
9559
+ } catch (err) {
9560
+ if (!(err instanceof ResourceNotFoundException$1)) this.logger.debug(`Could not read ResourcePolicy for ${physicalId}: ${err instanceof Error ? err.message : String(err)}`);
9561
+ }
9562
+ try {
9563
+ const active = ((await this.dynamoDBClient.send(new DescribeKinesisStreamingDestinationCommand({ TableName: physicalId }))).KinesisDataStreamDestinations ?? []).find((d) => d.DestinationStatus === "ACTIVE" || d.DestinationStatus === "ENABLING");
9564
+ if (active?.StreamArn) {
9565
+ const kspec = { StreamArn: active.StreamArn };
9566
+ if (active.ApproximateCreationDateTimePrecision !== void 0) kspec["ApproximateCreationDateTimePrecision"] = active.ApproximateCreationDateTimePrecision;
9567
+ result["KinesisStreamSpecification"] = kspec;
9568
+ }
9569
+ } catch (err) {
9570
+ this.logger.debug(`Could not read KinesisStreamingDestination for ${physicalId}: ${err instanceof Error ? err.message : String(err)}`);
9571
+ }
9572
+ try {
9573
+ const ciResp = await this.dynamoDBClient.send(new DescribeContributorInsightsCommand({ TableName: physicalId }));
9574
+ const status = ciResp.ContributorInsightsStatus;
9575
+ if (status === "ENABLED" || status === "DISABLED") {
9576
+ const cspec = { Enabled: status === "ENABLED" };
9577
+ if (status === "ENABLED" && ciResp.ContributorInsightsMode !== void 0) cspec["Mode"] = ciResp.ContributorInsightsMode;
9578
+ result["ContributorInsightsSpecification"] = cspec;
9579
+ }
9580
+ } catch (err) {
9581
+ this.logger.debug(`Could not read ContributorInsights for ${physicalId}: ${err instanceof Error ? err.message : String(err)}`);
9582
+ }
9428
9583
  return result;
9429
9584
  } catch (err) {
9430
9585
  if (err instanceof ResourceNotFoundException$1) return void 0;
@@ -12880,7 +13035,12 @@ var EC2Provider = class {
12880
13035
  "IamInstanceProfile",
12881
13036
  "UserData",
12882
13037
  "BlockDeviceMappings",
12883
- "Tags"
13038
+ "Tags",
13039
+ "DisableApiTermination",
13040
+ "MetadataOptions",
13041
+ "Monitoring",
13042
+ "EbsOptimized",
13043
+ "CreditSpecification"
12884
13044
  ])],
12885
13045
  ["AWS::EC2::NetworkAcl", new Set(["VpcId", "Tags"])],
12886
13046
  ["AWS::EC2::NetworkAclEntry", new Set([
@@ -13770,7 +13930,12 @@ var EC2Provider = class {
13770
13930
  Arn: iamInstanceProfile["Arn"],
13771
13931
  Name: iamInstanceProfile["Name"]
13772
13932
  } : void 0,
13773
- BlockDeviceMappings: this.buildBlockDeviceMappings(properties)
13933
+ BlockDeviceMappings: this.buildBlockDeviceMappings(properties),
13934
+ DisableApiTermination: this.coerceBool(properties["DisableApiTermination"]),
13935
+ EbsOptimized: this.coerceBool(properties["EbsOptimized"]),
13936
+ Monitoring: this.buildRunInstancesMonitoring(properties),
13937
+ MetadataOptions: this.buildMetadataOptions(properties),
13938
+ CreditSpecification: this.buildCreditSpecification(properties)
13774
13939
  }))).Instances?.[0];
13775
13940
  if (!instance?.InstanceId) throw new Error("No instance ID returned from RunInstances");
13776
13941
  const instanceId = instance.InstanceId;
@@ -13814,6 +13979,7 @@ var EC2Provider = class {
13814
13979
  this.logger.debug(`Updating EC2 Instance ${logicalId}: ${physicalId}`);
13815
13980
  try {
13816
13981
  await this.applyTagDiff(physicalId, previousProperties["Tags"], properties["Tags"]);
13982
+ await this.updateInstanceSecurityProps(physicalId, properties, previousProperties);
13817
13983
  const instance = (await this.ec2Client.send(new DescribeInstancesCommand({ InstanceIds: [physicalId] }))).Reservations?.[0]?.Instances?.[0];
13818
13984
  return {
13819
13985
  physicalId,
@@ -13832,6 +13998,57 @@ var EC2Provider = class {
13832
13998
  throw new ProvisioningError(`Failed to update EC2 Instance ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
13833
13999
  }
13834
14000
  }
14001
+ /**
14002
+ * Apply in-place modifications for four of the five security-focused
14003
+ * backfill props (#609). Each is diffed against `previousProperties` so a
14004
+ * no-drift round-trip (`update(state, state)`) issues zero mutating calls
14005
+ * (the `cdkd drift --revert` invariant). Each maps to a distinct EC2
14006
+ * modify API:
14007
+ * - DisableApiTermination -> ModifyInstanceAttribute
14008
+ * - Monitoring -> MonitorInstances / UnmonitorInstances
14009
+ * - MetadataOptions -> ModifyInstanceMetadataOptions
14010
+ * - CreditSpecification -> ModifyInstanceCreditSpecification
14011
+ * EbsOptimized is NOT here: it can only be changed on a STOPPED instance, so
14012
+ * an EbsOptimized change is routed to replacement (see ReplacementRules).
14013
+ */
14014
+ async updateInstanceSecurityProps(physicalId, properties, previousProperties) {
14015
+ const newDisableApiTermination = this.coerceBool(properties["DisableApiTermination"]);
14016
+ const oldDisableApiTermination = this.coerceBool(previousProperties["DisableApiTermination"]);
14017
+ if (newDisableApiTermination !== void 0 && newDisableApiTermination !== oldDisableApiTermination) await this.ec2Client.send(new ModifyInstanceAttributeCommand({
14018
+ InstanceId: physicalId,
14019
+ DisableApiTermination: { Value: newDisableApiTermination }
14020
+ }));
14021
+ const newMonitoring = this.coerceBool(properties["Monitoring"]);
14022
+ const oldMonitoring = this.coerceBool(previousProperties["Monitoring"]);
14023
+ if (newMonitoring !== void 0 && newMonitoring !== oldMonitoring) if (newMonitoring) await this.ec2Client.send(new MonitorInstancesCommand({ InstanceIds: [physicalId] }));
14024
+ else await this.ec2Client.send(new UnmonitorInstancesCommand({ InstanceIds: [physicalId] }));
14025
+ const newMetadata = this.buildMetadataOptions(properties);
14026
+ const oldMetadata = this.buildMetadataOptions(previousProperties);
14027
+ if (newMetadata !== void 0 && !this.shallowEqual(newMetadata, oldMetadata)) await this.ec2Client.send(new ModifyInstanceMetadataOptionsCommand({
14028
+ InstanceId: physicalId,
14029
+ ...newMetadata
14030
+ }));
14031
+ const newCpuCredits = this.readCpuCredits(properties["CreditSpecification"]);
14032
+ const oldCpuCredits = this.readCpuCredits(previousProperties["CreditSpecification"]);
14033
+ if (newCpuCredits !== void 0 && newCpuCredits !== oldCpuCredits) await this.ec2Client.send(new ModifyInstanceCreditSpecificationCommand({ InstanceCreditSpecifications: [{
14034
+ InstanceId: physicalId,
14035
+ CpuCredits: newCpuCredits
14036
+ }] }));
14037
+ }
14038
+ /**
14039
+ * Shallow value-equality for the small flat MetadataOptions request shape.
14040
+ * Treats `undefined` and an absent object as equal so the no-drift
14041
+ * round-trip produces zero modify calls.
14042
+ */
14043
+ shallowEqual(a, b) {
14044
+ if (b === void 0) return false;
14045
+ const ra = a;
14046
+ const rb = b;
14047
+ const keysA = Object.keys(ra);
14048
+ const keysB = Object.keys(rb);
14049
+ if (keysA.length !== keysB.length) return false;
14050
+ return keysA.every((k) => ra[k] === rb[k]);
14051
+ }
13835
14052
  async deleteInstance(logicalId, physicalId, resourceType, context) {
13836
14053
  this.logger.debug(`Terminating EC2 Instance ${logicalId}: ${physicalId}`);
13837
14054
  const removeProtection = context?.removeProtection === true;
@@ -13891,6 +14108,73 @@ var EC2Provider = class {
13891
14108
  });
13892
14109
  }
13893
14110
  /**
14111
+ * Coerce a CFn boolean-ish value (`true` | `false` | `"true"` | `"false"`)
14112
+ * into a real boolean, or `undefined` when the property is absent. CFn
14113
+ * templates can carry either the JSON boolean or its string form depending
14114
+ * on how the value was produced (a literal vs an intrinsic-resolved value),
14115
+ * so the wire boundary must normalize both. Returns `undefined` for absent
14116
+ * props so the field is omitted from the SDK input (AWS keeps its default)
14117
+ * rather than being forced to `false`.
14118
+ */
14119
+ coerceBool(value) {
14120
+ if (value === void 0 || value === null) return void 0;
14121
+ if (typeof value === "boolean") return value;
14122
+ if (value === "true") return true;
14123
+ if (value === "false") return false;
14124
+ }
14125
+ /**
14126
+ * Build the RunInstances `Monitoring` shape from the CFn `Monitoring`
14127
+ * boolean. AWS expects `{ Enabled: boolean }`; CFn carries a flat boolean.
14128
+ * Returns `undefined` when the prop is absent so the field is omitted.
14129
+ */
14130
+ buildRunInstancesMonitoring(properties) {
14131
+ const enabled = this.coerceBool(properties["Monitoring"]);
14132
+ if (enabled === void 0) return void 0;
14133
+ return { Enabled: enabled };
14134
+ }
14135
+ /**
14136
+ * Build the RunInstances `MetadataOptions` shape from the CFn
14137
+ * `MetadataOptions` object. CFn and the SDK share field names
14138
+ * (HttpTokens / HttpEndpoint / HttpPutResponseHopLimit / HttpProtocolIpv6 /
14139
+ * InstanceMetadataTags). `HttpPutResponseHopLimit` is numeric — CFn may
14140
+ * carry it as a string, so coerce at the wire boundary. Only emits keys the
14141
+ * template actually set so AWS keeps its defaults for the rest.
14142
+ */
14143
+ buildMetadataOptions(properties) {
14144
+ const opts = properties["MetadataOptions"];
14145
+ if (!opts || typeof opts !== "object") return void 0;
14146
+ const result = {};
14147
+ if (opts["HttpTokens"] !== void 0) result.HttpTokens = opts["HttpTokens"];
14148
+ if (opts["HttpEndpoint"] !== void 0) result.HttpEndpoint = opts["HttpEndpoint"];
14149
+ if (opts["HttpProtocolIpv6"] !== void 0) result.HttpProtocolIpv6 = opts["HttpProtocolIpv6"];
14150
+ if (opts["InstanceMetadataTags"] !== void 0) result.InstanceMetadataTags = opts["InstanceMetadataTags"];
14151
+ const hopLimit = opts["HttpPutResponseHopLimit"];
14152
+ if (hopLimit !== void 0 && hopLimit !== null) result.HttpPutResponseHopLimit = Number(hopLimit);
14153
+ return Object.keys(result).length > 0 ? result : void 0;
14154
+ }
14155
+ /**
14156
+ * Build the RunInstances `CreditSpecification` shape from the CFn
14157
+ * `CreditSpecification` object. CFn uses `CPUCredits` (capital CPU, the
14158
+ * canonical CDK `CfnInstance` emission); accept the SDK-style `CpuCredits`
14159
+ * too for hand-authored templates. Returns `undefined` when absent / empty.
14160
+ */
14161
+ buildCreditSpecification(properties) {
14162
+ const cpuCredits = this.readCpuCredits(properties["CreditSpecification"]);
14163
+ if (cpuCredits === void 0) return void 0;
14164
+ return { CpuCredits: cpuCredits };
14165
+ }
14166
+ /**
14167
+ * Extract the CpuCredits string from a CFn `CreditSpecification` object,
14168
+ * tolerating both the canonical `CPUCredits` key and the SDK-style
14169
+ * `CpuCredits` key. Shared by create() and update().
14170
+ */
14171
+ readCpuCredits(spec) {
14172
+ if (!spec || typeof spec !== "object") return void 0;
14173
+ const obj = spec;
14174
+ const raw = obj["CPUCredits"] ?? obj["CpuCredits"];
14175
+ return typeof raw === "string" ? raw : void 0;
14176
+ }
14177
+ /**
13894
14178
  * Build an IpPermission object from CloudFormation-style properties.
13895
14179
  *
13896
14180
  * The EC2 IpPermission shape is identical for ingress and egress; only the
@@ -14565,6 +14849,17 @@ var EC2Provider = class {
14565
14849
  if (instance.SourceDestCheck !== void 0) result["SourceDestCheck"] = instance.SourceDestCheck;
14566
14850
  const monitoringState = instance.Monitoring?.State;
14567
14851
  result["Monitoring"] = monitoringState === "enabled" || monitoringState === "pending";
14852
+ if (instance.EbsOptimized !== void 0) result["EbsOptimized"] = instance.EbsOptimized;
14853
+ const md = instance.MetadataOptions;
14854
+ if (md !== void 0) {
14855
+ const out = {};
14856
+ if (md.HttpTokens !== void 0) out["HttpTokens"] = md.HttpTokens;
14857
+ if (md.HttpPutResponseHopLimit !== void 0) out["HttpPutResponseHopLimit"] = md.HttpPutResponseHopLimit;
14858
+ if (md.HttpEndpoint !== void 0) out["HttpEndpoint"] = md.HttpEndpoint;
14859
+ if (md.HttpProtocolIpv6 !== void 0) out["HttpProtocolIpv6"] = md.HttpProtocolIpv6;
14860
+ if (md.InstanceMetadataTags !== void 0) out["InstanceMetadataTags"] = md.InstanceMetadataTags;
14861
+ if (Object.keys(out).length > 0) result["MetadataOptions"] = out;
14862
+ }
14568
14863
  if (instance.Placement?.Tenancy !== void 0) result["Tenancy"] = instance.Placement.Tenancy;
14569
14864
  if (instance.IamInstanceProfile?.Arn !== void 0) result["IamInstanceProfile"] = instance.IamInstanceProfile.Arn;
14570
14865
  const volumeIds = (instance.BlockDeviceMappings ?? []).filter((m) => m.Ebs?.VolumeId !== void 0).map((m) => m.Ebs.VolumeId);
@@ -14608,6 +14903,12 @@ var EC2Provider = class {
14608
14903
  } catch (err) {
14609
14904
  this.logger.debug(`DescribeInstanceAttribute(disableApiTermination, ${physicalId}) failed: ${err instanceof Error ? err.message : String(err)}`);
14610
14905
  }
14906
+ try {
14907
+ const cpuCredits = (await this.ec2Client.send(new DescribeInstanceCreditSpecificationsCommand({ InstanceIds: [physicalId] }))).InstanceCreditSpecifications?.[0]?.CpuCredits;
14908
+ if (cpuCredits !== void 0) result["CreditSpecification"] = { CPUCredits: cpuCredits };
14909
+ } catch (err) {
14910
+ this.logger.debug(`DescribeInstanceCreditSpecifications(${physicalId}) failed: ${err instanceof Error ? err.message : String(err)}`);
14911
+ }
14611
14912
  return result;
14612
14913
  }
14613
14914
  async readNetworkAclCurrentState(physicalId) {
@@ -53173,7 +53474,7 @@ function reorderArgs(argv) {
53173
53474
  async function main() {
53174
53475
  installPipeCloseHandler();
53175
53476
  const program = new Command();
53176
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.216.0");
53477
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.218.0");
53177
53478
  program.addCommand(createBootstrapCommand());
53178
53479
  program.addCommand(createSynthCommand());
53179
53480
  program.addCommand(createListCommand());