@go-to-k/cdkd 0.235.0 → 0.235.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
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
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 normalizeAwsTagsToCfn, b as ProvisioningError, f as LocalInvokeBuildError$1, i as matchesCdkPath, k as normalizeAwsError, l as CdkdError, m as LocalStartServiceError, n as isTerminationProtectionPropagationError, o as resolveExplicitPhysicalId, p as LocalMigrateError, r as CDK_PATH_TAG, s as assertRegionMatch, t as disableInstanceApiTermination, v as NestedStackChildDirectDestroyError, w as StackTerminationProtectionError, x as ResourceTimeoutError, y as PartialFailureError } from "./ec2-termination-protection-uvVnteGl.js";
3
- import { a as setAwsClients, i as resetAwsClients, r as getAwsClients, t as AwsClients } from "./aws-clients-pjPwZz1r.js";
4
- import { $ as AssetManifestLoader, A as DiffCalculator, B as buildAssetRedirectMap, C as findActionableSilentDrops, D as refStateLookupFromResource, E as cfnRefValueFromPhysicalId, F as rebuildClientForBucketRegion, G as BOOTSTRAP_MARKER_PREFIX, H as loadPublishableAssetManifest, I as shouldRetainResource, J as buildDockerImage, K as ensureAssetStorage, L as AssetPublisher, M as TemplateParser, N as LockManager, O as WAFv2WebACLProvider, P as S3StateBackend, Q as runDockerStreaming, R as stringifyValue, S as ProviderRegistry, T as IntrinsicFunctionResolver, U as rewriteTemplateAssetReferences, V as createAssetRedirectResolver, W as AssetModeResolver, X as getDockerCmd, Y as formatDockerLoginError, Z as runDockerForeground, _ as green, _t as uploadCfnTemplate, a as withRetry, at as resolveApp, b as IAMRoleProvider, bt as resolveBucketRegion, c as computeImplicitDeleteEdges, ct as resolveSkipPrefix, d as isStatefulRecreateTargetSync, dt as resolveUseCdkBootstrapAssets, et as getDockerImageBySourceHash, f as renderStatefulReason, ft as warnDeprecatedNoPrefixCliFlag, g as gray, gt as findLargeInlineResources, h as cyan, ht as MIGRATE_TMP_PREFIX, i as withResourceDeadline, it as getLegacyStateBucketName, j as DagBuilder, k as applyRoleArnIfSet, l as extractDeploymentEventError, lt as resolveStateBucketWithDefault, m as bold, mt as CFN_TEMPLATE_URL_LIMIT, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as synthesisStatusMessage, o as isRetryableTransientError, ot as resolveAutoAssetStorage, p as formatResourceLine, pt as CFN_TEMPLATE_BODY_LIMIT, q as parseBootstrapMarker, r as DeployEngine, rt as getDefaultStateBucketName, s as IMPLICIT_DELETE_DEPENDENCIES, st as resolveCaptureObservedState, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as Synthesizer, u as MULTI_REGION_RECREATE_BLOCKED_TYPES, ut as resolveStateBucketWithDefaultAndSource, v as red, vt as AssemblyReader, w as CloudControlProvider, x as collectInlinePolicyNamesManagedBySiblings, y as yellow, z as WorkGraph } from "./deploy-engine-Cbi5IzWV.js";
5
- import { t as ASGProvider } from "./asg-provider-Dd9Xze-T.js";
2
+ import { a as getLiveRenderer, c as PATTERN_B_RESOURCE_TYPES, d as generateResourceNameWithFallback, f as withSkipPrefix, i as runStackBuffered, n as getLogger, o as PATTERN_B_NAME_OPTIONS, p as withStackName, s as PATTERN_B_NAME_PROPERTIES, u as generateResourceName } from "./logger-BzO-joNR.js";
3
+ import { A as withErrorHandling, C as StackHasActiveImportsError, S as ResourceUpdateNotSupportedError, _ as MissingCdkCliError, a as normalizeAwsTagsToCfn, b as ProvisioningError, f as LocalInvokeBuildError$1, i as matchesCdkPath, k as normalizeAwsError, l as CdkdError, m as LocalStartServiceError, n as isTerminationProtectionPropagationError, o as resolveExplicitPhysicalId, p as LocalMigrateError, r as CDK_PATH_TAG, s as assertRegionMatch, t as disableInstanceApiTermination, v as NestedStackChildDirectDestroyError, w as StackTerminationProtectionError, x as ResourceTimeoutError, y as PartialFailureError } from "./ec2-termination-protection-q-WGWgxa.js";
4
+ import { a as setAwsClients, i as resetAwsClients, r as getAwsClients, t as AwsClients } from "./aws-clients-B15NAPbL.js";
5
+ import { $ as AssetManifestLoader, A as DiffCalculator, B as buildAssetRedirectMap, C as findActionableSilentDrops, D as refStateLookupFromResource, E as cfnRefValueFromPhysicalId, F as rebuildClientForBucketRegion, G as BOOTSTRAP_MARKER_PREFIX, H as loadPublishableAssetManifest, I as shouldRetainResource, J as buildDockerImage, K as ensureAssetStorage, L as AssetPublisher, M as TemplateParser, N as LockManager, O as WAFv2WebACLProvider, P as S3StateBackend, Q as runDockerStreaming, R as stringifyValue, S as ProviderRegistry, T as IntrinsicFunctionResolver, U as rewriteTemplateAssetReferences, V as createAssetRedirectResolver, W as AssetModeResolver, X as getDockerCmd, Y as formatDockerLoginError, Z as runDockerForeground, _ as green, _t as uploadCfnTemplate, a as withRetry, at as resolveApp, b as IAMRoleProvider, bt as resolveBucketRegion, c as computeImplicitDeleteEdges, ct as resolveSkipPrefix, d as isStatefulRecreateTargetSync, dt as resolveUseCdkBootstrapAssets, et as getDockerImageBySourceHash, f as renderStatefulReason, ft as warnDeprecatedNoPrefixCliFlag, g as gray, gt as findLargeInlineResources, h as cyan, ht as MIGRATE_TMP_PREFIX, i as withResourceDeadline, it as getLegacyStateBucketName, j as DagBuilder, k as applyRoleArnIfSet, l as extractDeploymentEventError, lt as resolveStateBucketWithDefault, m as bold, mt as CFN_TEMPLATE_URL_LIMIT, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as synthesisStatusMessage, o as isRetryableTransientError, ot as resolveAutoAssetStorage, p as formatResourceLine, pt as CFN_TEMPLATE_BODY_LIMIT, q as parseBootstrapMarker, r as DeployEngine, rt as getDefaultStateBucketName, s as IMPLICIT_DELETE_DEPENDENCIES, st as resolveCaptureObservedState, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as Synthesizer, u as MULTI_REGION_RECREATE_BLOCKED_TYPES, ut as resolveStateBucketWithDefaultAndSource, v as red, vt as AssemblyReader, w as CloudControlProvider, x as collectInlinePolicyNamesManagedBySiblings, y as yellow, z as WorkGraph } from "./deploy-engine-iahWC4C1.js";
6
+ import { t as expectedOwnerParam } from "./expected-bucket-owner-BjEfUnkA.js";
7
+ import { t as ASGProvider } from "./asg-provider-Dbl1_mwT.js";
6
8
  import { AsyncLocalStorage } from "node:async_hooks";
7
9
  import { createHash, randomBytes, randomUUID } from "node:crypto";
8
10
  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";
@@ -651,7 +653,10 @@ async function bootstrapCommand(options) {
651
653
  try {
652
654
  let bucketExists = false;
653
655
  try {
654
- await stateBucketS3.send(new HeadBucketCommand({ Bucket: bucketName }));
656
+ await stateBucketS3.send(new HeadBucketCommand({
657
+ Bucket: bucketName,
658
+ ExpectedBucketOwner: accountId
659
+ }));
655
660
  bucketExists = true;
656
661
  logger.info(`Bucket ${bucketName} already exists`);
657
662
  } catch (error) {
@@ -682,12 +687,14 @@ async function bootstrapCommand(options) {
682
687
  logger.debug("Enabling bucket versioning...");
683
688
  await stateBucketS3.send(new PutBucketVersioningCommand({
684
689
  Bucket: bucketName,
690
+ ExpectedBucketOwner: accountId,
685
691
  VersioningConfiguration: { Status: "Enabled" }
686
692
  }));
687
693
  logger.info("✓ Enabled bucket versioning");
688
694
  logger.debug("Enabling bucket encryption...");
689
695
  await stateBucketS3.send(new PutBucketEncryptionCommand({
690
696
  Bucket: bucketName,
697
+ ExpectedBucketOwner: accountId,
691
698
  ServerSideEncryptionConfiguration: { Rules: [{
692
699
  ApplyServerSideEncryptionByDefault: { SSEAlgorithm: "AES256" },
693
700
  BucketKeyEnabled: true
@@ -708,6 +715,7 @@ async function bootstrapCommand(options) {
708
715
  };
709
716
  await stateBucketS3.send(new PutBucketPolicyCommand({
710
717
  Bucket: bucketName,
718
+ ExpectedBucketOwner: accountId,
711
719
  Policy: JSON.stringify(bucketPolicy)
712
720
  }));
713
721
  logger.info("✓ Set bucket policy (deny external access)");
@@ -1526,7 +1534,7 @@ const FLUSH_INTERVAL_MS = 2e3;
1526
1534
  const FLUSH_EVENT_THRESHOLD = 50;
1527
1535
  /** Build-time cdkd version, with a dev fallback for non-built contexts. */
1528
1536
  function getCdkdVersion() {
1529
- return "0.235.0";
1537
+ return "0.235.1";
1530
1538
  }
1531
1539
  /**
1532
1540
  * Generate a time-sortable unique run id, e.g.
@@ -2157,6 +2165,14 @@ var ExportIndexStore = class {
2157
2165
  * `config.region()` shape (e.g. a hand-rolled test double) the resolution
2158
2166
  * is skipped and the original client is used unchanged.
2159
2167
  */
2168
+ /**
2169
+ * `ExpectedBucketOwner` spread for every state-bucket S3 call (squatting
2170
+ * hardening — see src/utils/expected-bucket-owner.ts). Best-effort:
2171
+ * resolves to an empty object for non-standard clients (test doubles).
2172
+ */
2173
+ async ownerParam() {
2174
+ return expectedOwnerParam(this.s3Client);
2175
+ }
2160
2176
  async ensureClientForBucket() {
2161
2177
  if (this.clientResolved) return;
2162
2178
  if (this.resolveInFlight) return this.resolveInFlight;
@@ -2302,6 +2318,7 @@ var ExportIndexStore = class {
2302
2318
  try {
2303
2319
  const response = await this.s3Client.send(new GetObjectCommand({
2304
2320
  Bucket: this.bucket,
2321
+ ...await this.ownerParam(),
2305
2322
  Key: this.indexKey()
2306
2323
  }));
2307
2324
  return {
@@ -2318,6 +2335,7 @@ var ExportIndexStore = class {
2318
2335
  const body = JSON.stringify(next, null, 2);
2319
2336
  return (await this.s3Client.send(new PutObjectCommand({
2320
2337
  Bucket: this.bucket,
2338
+ ...await this.ownerParam(),
2321
2339
  Key: this.indexKey(),
2322
2340
  Body: body,
2323
2341
  ContentLength: Buffer.byteLength(body),
@@ -41938,6 +41956,8 @@ async function stateMigrateCommand(options) {
41938
41956
  await newS3.send(new CopyObjectCommand({
41939
41957
  Bucket: newBucket,
41940
41958
  Key: obj.Key,
41959
+ ...await expectedOwnerParam(newS3),
41960
+ ExpectedSourceBucketOwner: accountId,
41941
41961
  CopySource: encodeURIComponent(`${legacyBucket}/${obj.Key}`)
41942
41962
  }));
41943
41963
  copied++;
@@ -41951,7 +41971,10 @@ async function stateMigrateCommand(options) {
41951
41971
  logger.info(`Emptying source bucket ${legacyBucket} (all versions + delete markers)...`);
41952
41972
  await emptyBucketAllVersions(legacyS3, legacyBucket);
41953
41973
  logger.info(`Deleting source bucket ${legacyBucket}...`);
41954
- await legacyS3.send(new DeleteBucketCommand({ Bucket: legacyBucket }));
41974
+ await legacyS3.send(new DeleteBucketCommand({
41975
+ Bucket: legacyBucket,
41976
+ ...await expectedOwnerParam(legacyS3)
41977
+ }));
41955
41978
  logger.info(`✓ Deleted source bucket: ${legacyBucket}`);
41956
41979
  } else logger.info(`Source bucket ${legacyBucket} kept. Pass --remove-legacy on a future run to delete it.`);
41957
41980
  logger.info(`✓ Migration complete: ${legacyBucket} -> ${newBucket}`);
@@ -41967,7 +41990,10 @@ async function stateMigrateCommand(options) {
41967
41990
  }
41968
41991
  async function bucketExists(s3, bucketName) {
41969
41992
  try {
41970
- await s3.send(new HeadBucketCommand({ Bucket: bucketName }));
41993
+ await s3.send(new HeadBucketCommand({
41994
+ Bucket: bucketName,
41995
+ ...await expectedOwnerParam(s3)
41996
+ }));
41971
41997
  return true;
41972
41998
  } catch (error) {
41973
41999
  const err = error;
@@ -41983,6 +42009,7 @@ async function listAllObjects(s3, bucket) {
41983
42009
  do {
41984
42010
  const resp = await s3.send(new ListObjectsV2Command({
41985
42011
  Bucket: bucket,
42012
+ ...await expectedOwnerParam(s3),
41986
42013
  ...continuationToken && { ContinuationToken: continuationToken }
41987
42014
  }));
41988
42015
  if (resp.Contents) all.push(...resp.Contents);
@@ -42025,10 +42052,12 @@ async function ensureDestinationBucket(bucketName, region, accountId, logger) {
42025
42052
  logger.info(`✓ Created destination bucket: ${bucketName}`);
42026
42053
  await s3.send(new PutBucketVersioningCommand({
42027
42054
  Bucket: bucketName,
42055
+ ...await expectedOwnerParam(s3),
42028
42056
  VersioningConfiguration: { Status: "Enabled" }
42029
42057
  }));
42030
42058
  await s3.send(new PutBucketEncryptionCommand({
42031
42059
  Bucket: bucketName,
42060
+ ...await expectedOwnerParam(s3),
42032
42061
  ServerSideEncryptionConfiguration: { Rules: [{
42033
42062
  ApplyServerSideEncryptionByDefault: { SSEAlgorithm: "AES256" },
42034
42063
  BucketKeyEnabled: true
@@ -42036,6 +42065,7 @@ async function ensureDestinationBucket(bucketName, region, accountId, logger) {
42036
42065
  }));
42037
42066
  await s3.send(new PutBucketPolicyCommand({
42038
42067
  Bucket: bucketName,
42068
+ ...await expectedOwnerParam(s3),
42039
42069
  Policy: JSON.stringify({
42040
42070
  Version: "2012-10-17",
42041
42071
  Statement: [{
@@ -42062,6 +42092,7 @@ async function emptyBucketAllVersions(s3, bucket) {
42062
42092
  do {
42063
42093
  const resp = await s3.send(new ListObjectVersionsCommand({
42064
42094
  Bucket: bucket,
42095
+ ...await expectedOwnerParam(s3),
42065
42096
  ...keyMarker && { KeyMarker: keyMarker },
42066
42097
  ...versionIdMarker && { VersionIdMarker: versionIdMarker }
42067
42098
  }));
@@ -42078,6 +42109,7 @@ async function emptyBucketAllVersions(s3, bucket) {
42078
42109
  const batch = ids.slice(i, i + 1e3);
42079
42110
  await s3.send(new DeleteObjectsCommand({
42080
42111
  Bucket: bucket,
42112
+ ...await expectedOwnerParam(s3),
42081
42113
  Delete: {
42082
42114
  Objects: batch,
42083
42115
  Quiet: true
@@ -45314,7 +45346,10 @@ function formatBucketSource(source) {
45314
45346
  */
45315
45347
  async function detectBucketRegion(awsClients, bucket) {
45316
45348
  try {
45317
- const constraint = (await awsClients.s3.send(new GetBucketLocationCommand({ Bucket: bucket }))).LocationConstraint;
45349
+ const constraint = (await awsClients.s3.send(new GetBucketLocationCommand({
45350
+ Bucket: bucket,
45351
+ ...await expectedOwnerParam(awsClients.s3)
45352
+ }))).LocationConstraint;
45318
45353
  if (!constraint) return "us-east-1";
45319
45354
  if (constraint === "EU") return "eu-west-1";
45320
45355
  return constraint;
@@ -45362,7 +45397,8 @@ async function readSchemaVersion(awsClients, bucket, keys) {
45362
45397
  try {
45363
45398
  const resp = await awsClients.s3.send(new GetObjectCommand({
45364
45399
  Bucket: bucket,
45365
- Key: keys[0]
45400
+ Key: keys[0],
45401
+ ...await expectedOwnerParam(awsClients.s3)
45366
45402
  }));
45367
45403
  if (!resp.Body) return "unknown";
45368
45404
  const body = await resp.Body.transformToString();
@@ -45397,7 +45433,8 @@ async function listAssetStorageMarkers(awsClients, bucket) {
45397
45433
  try {
45398
45434
  const marker = parseBootstrapMarker(await (await awsClients.s3.send(new GetObjectCommand({
45399
45435
  Bucket: bucket,
45400
- Key: key
45436
+ Key: key,
45437
+ ...await expectedOwnerParam(awsClients.s3)
45401
45438
  }))).Body?.transformToString() ?? "", key);
45402
45439
  entries.push({
45403
45440
  region,
@@ -56046,7 +56083,7 @@ function reorderArgs(argv) {
56046
56083
  async function main() {
56047
56084
  installPipeCloseHandler();
56048
56085
  const program = new Command();
56049
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.235.0");
56086
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.235.1");
56050
56087
  program.addCommand(createBootstrapCommand());
56051
56088
  program.addCommand(createSynthCommand());
56052
56089
  program.addCommand(createListCommand());