@go-to-k/cdkd 0.296.1 → 0.296.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.
@@ -2,12 +2,12 @@ import { r as getAwsClients } from "./aws-clients-CnmtbrxD.js";
2
2
  import { A as displaySafe, F as safeMsg, M as isPasteableIdent, P as plainIdentOr, g as generateResourceNameWithFallback, h as generateResourceName, j as displayStackName, k as displayIdent, n as getLogger, v as getCurrentStackName, w as SECRET_REF_MAX_CODE_POINTS } from "./logger-Dvc7ddKe.js";
3
3
  import { $ as compositeIdFormatMessage, $n as markRedactedCause, A as isTerminalDeleteFailure, B as WITHHELD_AWS_COMMAND, C as refusalTypeShown, D as ProtectionFlipRegistry, Dn as shellQuote, H as pasteableAwsCommand, Ht as AccountIdUnavailableError, J as isInterruptedWaitError, Jn as safeStringify, Kn as describeAwsFailure, L as userPoolProtectionSite, Ln as markNameCollision, Lt as withPasteableAwsProfile, M as observeThenDisableProtection, Mt as injectiveKey, N as protectionFlipKey, Nt as injectiveKeyPrefix, On as withheldTargetClause, P as rdsFamilyProtectionSite, Q as canonicalizeRoute53QueryName, Qn as markNonRetryable, Rn as markReplayMayCollide, Rt as ambientClientDefaults, S as quotedRemedyLogicalId, Sn as pasteableCommand, T as resolveExplicitPhysicalId, U as protectedReplacementAdvice, Un as isRetryableTransientError, V as isAwsCliLiteral, Vn as isAmbiguousOutcomeError, Vt as credentialFingerprint, W as renderDisableCommand, Wn as isTransientServerError, Wt as CdkdError, X as ElapsedBudgetRegistry, Y as startInterruptWatch, Yn as THROTTLING_ERROR_NAMES, Zn as isThrottlingError, _ as VALUE_NOT_SHOWN, a as onlySecretDerived, at as segmentAfterAnchor, b as isQuotableImportValue, bn as hasClauseBreak, bt as markAuxiliaryFailure, c as recordedPrincipalsRepair, ct as createMaskedRetryLogger, dt as maskerOrIdentity, er as wrapMaskedAwsError, et as compositeIdSeparatorRefusal, ft as withDerivedNameMasks, g as assertRegionMatch, h as RESOURCE_NOT_FOUND, ht as clearCreatedBeforeFailure, i as holdsSecretDerivedEntry, in as ProvisioningError, j as logGroupProtectionSite, k as deleteWithProtectionCompensation, lt as isSecretDerivedValue, nt as logicalIdShown, o as readPrincipalLists, on as ResourceUpdateNotSupportedError, ot as stateOrphanRecordRemedy, p as withRemovalDefaults, qn as isAwsAuthoredFailure, r as SECRET_DERIVED_READ_LIVE, rt as packCompositeId, st as createMaskedLogSinks, tt as compositeIdSkipResult, u as clearOnUpdateRemoval, ut as maskDeep, v as isPlainImportJson, w as remedyLogicalId, wn as plainOrDescribed, x as normalizeAwsTagsToCfn, xn as isInertUnquoted, xt as markCreatedBeforeFailure, y as isPlainImportValue, yn as commandHole, z as UNNAMEABLE_ID_CLAUSE, zt as ambientCredentialConfig } from "./iam-policy-targets-DSDSdxXz.js";
4
4
  import { s as ambientRegion } from "./aws-client-defaults-D0q0z4dG.js";
5
- import { $a as dynamicReferenceTokens, $i as withoutSilentDropProperties, $n as reEnableInstanceApiTermination, A as resolveDynamoDbDeleteBudgetClock, An as definedAttributes, B as getPriorAttempts, Bo as rewriteTemplateAssetReferences, Bs as decodeListingKey, Cn as DBPROXY_TAGS_WHAT, Ct as getStackRecords, D as beginDeleteWait, Da as canonicalLambdaFunctionName, Dn as refuseMalformedDesiredTags, E as DYNAMODB_DELETE_MIN_RESOURCE_TIMEOUT_MS, Ea as withRetry, En as readTagList, F as waitForIndexesSettled, Fo as stringifyValue, Fr as parseWebACLArn, Gn as withIndeterminateGuard, Gt as redactedDeleteAddressFields, I as ECR_AUTO_DELETE_IMAGES_TAG, Ja as markSameGenerationBag, Kn as isWaitAbandonedError, Kt as redactedDeleteAddressSkip, L as S3_AUTO_DELETE_OBJECTS_TAG, La as hasMaskableValues, Ln as getCurrentResourceSecrets, M as DELETE_INDEX_WAIT_PROCEED_NOTE, Mt as getCurrentProducerRegions, N as INDEX_SETTLE_POLL_INTERVAL_MS, O as compensateRemovedDeletionProtection, Oa as lambdaFunctionNameForMask, On as tagMapAsList, P as deleteTableWithIndexBusyRetry, Qn as reDisableInstanceApiTermination, R as hasCdkAutoDeleteTag, Ri as refuseMalformedResourcesForDestroy, Rr as passedParameterClassesOf, Sa as requireConfigString, Sn as acquireIdempotencyToken, T as DynamoDBGlobalTableProvider, Tn as planTagDiff, Tr as getAccountInfo, Us as canonicalizeRegion, Ut as REDACTED_DELETE_ADDRESS_SKIP_REASON, V as markRefusedBeforeApplying, Vn as unchangedBehindSecretReference, Wn as deleteSkipReason, Ws as derivePartitionAndUrlSuffix, Wt as isRedactedRecordedValue, Xn as isTerminationProtectionPropagationError, Ya as redactSecretsForState, Yn as ec2InstanceProtectionSite, Za as recoverMaskedOutput, Zi as findSilentDropProperties, Zn as observeThenDisableInstanceApiTermination, _a as configStringRefusal, _r as s3BucketArn, _t as getCurrentNestedStackContext, a as findNestedTemplateTreeDefect, ba as requireConfigArray, bn as reserveStackCreateToken, br as s3BucketRegionalDomainName, c as renderNestedTemplateTreeDefect, ca as WARM_THROUGHPUT_MEMBERS, da as toCfnInteger, dt as getNestedRevertRun, ec as describeFileReadFailure, fa as toFiniteNumber, ga as configIntegerRefusal, gr as isSettledInstanceState, ha as configBooleanRefusal, j as resolveDynamoDbDeleteBudgetMs, jn as stringifyIfAssigned, k as deleteBudgetKey, ka as sameLambdaFunctionAddress, kn as tagPlanWarning, la as coerceWarmThroughput$1, ma as coerceCfnInteger, mt as revertNestedChildFromJournal, nc as renderAssemblyPathEscape, o as isAbsoluteAssetPath, pa as coerceCfnBoolean, qn as markWaitAbandoned, rc as resolveAssemblyPath, ro as carriesSecretMask, s as listNestedTemplateRows, t as DeployEngine, tc as displayAssemblyPath, ua as isWarmThroughputDecrease, va as readConfigString, vi as refuseMalformedNestedChildOutputs, vn as earliestDefined, vr as s3BucketDomainName, vt as withNestedStackContext, wn as DBPROXY_TAG_OPTIONS, xa as requireConfigObject, xr as s3BucketWebsiteUrl, xt as awaitInFlightSibling, ya as replayWarn, yr as s3BucketDualStackDomainName, z as isTruthyCfnBoolean, zn as slowCcOperationTimeoutMs } from "./deploy-engine-xlct0Hcm.js";
6
- import { n as collectInlinePolicyNamesManagedBySiblings, t as IAMRoleProvider } from "./iam-role-provider-BRVCTUZu.js";
7
- import { a as canonicalizeIpProtocolValue, i as resolveSecretDerivedPrincipals, n as runDestroyForStack, o as resolvedResourceTimeoutMs, r as isResolvableSecretPrincipalList, t as canonicalizeIpv4Cidr } from "./program-DXRavuSm.js";
8
- import { RDSProvider } from "./rds-provider-McCDKyXN.js";
9
- import { NeptuneProvider } from "./neptune-provider-Cdp4jX8S.js";
10
- import { ASGProvider } from "./asg-provider-BwWy0pBH.js";
5
+ import { $a as recoverMaskedOutput, $i as findSilentDropProperties, $n as observeThenDisableInstanceApiTermination, A as resolveDynamoDbDeleteBudgetClock, Aa as lambdaFunctionNameForMask, An as tagMapAsList, B as getPriorAttempts, Bi as refuseMalformedResourcesForDestroy, Br as passedParameterClassesOf, Ca as requireConfigObject, Cr as s3BucketWebsiteUrl, Ct as getStackRecords, D as beginDeleteWait, Dn as planTagDiff, Dr as getAccountInfo, E as DYNAMODB_DELETE_MIN_RESOURCE_TIMEOUT_MS, En as DBPROXY_TAG_OPTIONS, F as waitForIndexesSettled, Gs as canonicalizeRegion, Gt as REDACTED_DELETE_ADDRESS_SKIP_REASON, Ho as rewriteTemplateAssetReferences, Hs as decodeListingKey, I as ECR_AUTO_DELETE_IMAGES_TAG, Jn as isWaitAbandonedError, Jt as redactedDeleteAddressSkip, Kn as deleteSkipReason, Ks as derivePartitionAndUrlSuffix, Kt as isRedactedRecordedValue, L as S3_AUTO_DELETE_OBJECTS_TAG, Lo as stringifyValue, Lr as parseWebACLArn, M as DELETE_INDEX_WAIT_PROCEED_NOTE, Mn as definedAttributes, N as INDEX_SETTLE_POLL_INTERVAL_MS, Nn as stringifyIfAssigned, O as compensateRemovedDeletionProtection, Oa as withRetry, On as readTagList, P as deleteTableWithIndexBusyRetry, Pt as getCurrentProducerRegions, Qn as isTerminationProtectionPropagationError, R as hasCdkAutoDeleteTag, Sa as requireConfigArray, Sn as reserveStackCreateToken, Sr as s3BucketRegionalDomainName, T as DynamoDBGlobalTableProvider, Tn as DBPROXY_TAGS_WHAT, Un as unchangedBehindSecretReference, V as markRefusedBeforeApplying, Vn as slowCcOperationTimeoutMs, Xa as markSameGenerationBag, Yn as markWaitAbandoned, Za as redactSecretsForState, Zn as ec2InstanceProtectionSite, _a as configBooleanRefusal, _t as getCurrentNestedStackContext, a as findNestedTemplateTreeDefect, ac as resolveAssemblyPath, ao as carriesSecretMask, ba as readConfigString, bi as refuseMalformedNestedChildOutputs, bn as earliestDefined, br as s3BucketDomainName, c as renderNestedTemplateTreeDefect, da as coerceWarmThroughput$1, dt as getNestedRevertRun, er as reDisableInstanceApiTermination, fa as isWarmThroughputDecrease, ga as coerceCfnInteger, ha as coerceCfnBoolean, ic as renderAssemblyPathEscape, j as resolveDynamoDbDeleteBudgetMs, ja as sameLambdaFunctionAddress, jn as tagPlanWarning, k as deleteBudgetKey, ka as canonicalLambdaFunctionName, kn as refuseMalformedDesiredTags, ma as toFiniteNumber, mt as revertNestedChildFromJournal, nc as describeFileReadFailure, o as isAbsoluteAssetPath, pa as toCfnInteger, qn as withIndeterminateGuard, qt as redactedDeleteAddressFields, rc as displayAssemblyPath, s as listNestedTemplateRows, t as DeployEngine, ta as withoutSilentDropProperties, to as dynamicReferenceTokens, tr as reEnableInstanceApiTermination, ua as WARM_THROUGHPUT_MEMBERS, va as configIntegerRefusal, vr as isSettledInstanceState, vt as withNestedStackContext, wa as requireConfigString, wn as acquireIdempotencyToken, xa as replayWarn, xr as s3BucketDualStackDomainName, xt as awaitInFlightSibling, ya as configStringRefusal, yr as s3BucketArn, z as isTruthyCfnBoolean, za as hasMaskableValues, zn as getCurrentResourceSecrets } from "./deploy-engine-C_Eg-RHm.js";
6
+ import { n as collectInlinePolicyNamesManagedBySiblings, t as IAMRoleProvider } from "./iam-role-provider-COoTgydF.js";
7
+ import { a as canonicalizeIpProtocolValue, i as resolveSecretDerivedPrincipals, n as runDestroyForStack, o as resolvedResourceTimeoutMs, r as isResolvableSecretPrincipalList, t as canonicalizeIpv4Cidr } from "./program-CiMVZi4n.js";
8
+ import { RDSProvider } from "./rds-provider-DQwvPJXB.js";
9
+ import { NeptuneProvider } from "./neptune-provider-D2SmeISr.js";
10
+ import { ASGProvider } from "./asg-provider-DedWRf1j.js";
11
11
  import { createHash, randomUUID } from "node:crypto";
12
12
  import { CreateBucketCommand, DeleteBucketAnalyticsConfigurationCommand, DeleteBucketCommand, DeleteBucketCorsCommand, DeleteBucketEncryptionCommand, DeleteBucketIntelligentTieringConfigurationCommand, DeleteBucketInventoryConfigurationCommand, DeleteBucketLifecycleCommand, DeleteBucketMetricsConfigurationCommand, DeleteBucketOwnershipControlsCommand, DeleteBucketPolicyCommand, DeleteBucketReplicationCommand, DeleteBucketTaggingCommand, DeleteBucketWebsiteCommand, DeleteObjectsCommand, GetBucketAccelerateConfigurationCommand, GetBucketCorsCommand, GetBucketEncryptionCommand, GetBucketLifecycleConfigurationCommand, GetBucketLocationCommand, GetBucketLoggingCommand, GetBucketNotificationConfigurationCommand, GetBucketOwnershipControlsCommand, GetBucketPolicyCommand, GetBucketReplicationCommand, GetBucketTaggingCommand, GetBucketVersioningCommand, GetBucketWebsiteCommand, GetObjectCommand, GetObjectLockConfigurationCommand, GetPublicAccessBlockCommand, HeadBucketCommand, ListBucketAnalyticsConfigurationsCommand, ListBucketIntelligentTieringConfigurationsCommand, ListBucketInventoryConfigurationsCommand, ListBucketMetricsConfigurationsCommand, ListObjectVersionsCommand, ListObjectsV2Command, NoSuchBucket, PutBucketAccelerateConfigurationCommand, PutBucketAnalyticsConfigurationCommand, PutBucketCorsCommand, PutBucketEncryptionCommand, PutBucketIntelligentTieringConfigurationCommand, PutBucketInventoryConfigurationCommand, PutBucketLifecycleConfigurationCommand, PutBucketLoggingCommand, PutBucketMetricsConfigurationCommand, PutBucketNotificationConfigurationCommand, PutBucketOwnershipControlsCommand, PutBucketPolicyCommand, PutBucketReplicationCommand, PutBucketTaggingCommand, PutBucketVersioningCommand, PutBucketWebsiteCommand, PutObjectLockConfigurationCommand, PutPublicAccessBlockCommand, S3Client } from "@aws-sdk/client-s3";
13
13
  import { AddRoleToInstanceProfileCommand, AddUserToGroupCommand, AttachGroupPolicyCommand, AttachRolePolicyCommand, AttachUserPolicyCommand, CreateAccessKeyCommand, CreateGroupCommand, CreateInstanceProfileCommand, CreateLoginProfileCommand, CreatePolicyCommand, CreatePolicyVersionCommand, CreateUserCommand, DeleteAccessKeyCommand, DeleteGroupCommand, DeleteGroupPolicyCommand, DeleteInstanceProfileCommand, DeleteLoginProfileCommand, DeletePolicyCommand, DeletePolicyVersionCommand, DeleteRolePolicyCommand, DeleteUserCommand, DeleteUserPermissionsBoundaryCommand, DeleteUserPolicyCommand, DetachGroupPolicyCommand, DetachRolePolicyCommand, DetachUserPolicyCommand, GetAccessKeyLastUsedCommand, GetGroupCommand, GetGroupPolicyCommand, GetInstanceProfileCommand, GetPolicyCommand, GetPolicyVersionCommand, GetRolePolicyCommand, GetUserCommand, GetUserPolicyCommand, IAMClient, ListAccessKeysCommand, ListAttachedGroupPoliciesCommand, ListAttachedUserPoliciesCommand, ListEntitiesForPolicyCommand, ListGroupPoliciesCommand, ListGroupsForUserCommand, ListPoliciesCommand, ListPolicyTagsCommand, ListPolicyVersionsCommand, ListUserPoliciesCommand, NoSuchEntityException, PutGroupPolicyCommand, PutRolePolicyCommand, PutUserPermissionsBoundaryCommand, PutUserPolicyCommand, RemoveRoleFromInstanceProfileCommand, RemoveUserFromGroupCommand, TagPolicyCommand, TagUserCommand, UntagPolicyCommand, UntagUserCommand, UpdateAccessKeyCommand, UpdateLoginProfileCommand } from "@aws-sdk/client-iam";
@@ -2606,7 +2606,7 @@ function manualBucketDeletionClause(bucketName, maskSecrets, journaled) {
2606
2606
  identifier: bucketName,
2607
2607
  maskSecrets
2608
2608
  });
2609
- const lead = journaled ? "On a first-time create the failed deploy's rollback journal records the bucket for `cdkd rollback --revert-failed`; otherwise delete it yourself before the next deploy" : "Manual deletion may be required before the next deploy";
2609
+ const lead = journaled ? "Outside a rollback's re-create, the failed deploy's rollback journal records the bucket for `cdkd rollback --revert-failed`; otherwise delete it yourself before the next deploy" : "Manual deletion may be required before the next deploy";
2610
2610
  return command ? `${lead}: ${command}` : `${lead}, via the console: the bucket name cannot be reproduced safely on a command line, so any command shown here could act on a different bucket or run part of the name as shell.`;
2611
2611
  }
2612
2612
  function configItemId(item) {
@@ -5518,7 +5518,7 @@ var SQSQueuePolicyProvider = class {
5518
5518
  this.logger.debug(`Successfully created SQS queue policy ${logicalId}`);
5519
5519
  return {
5520
5520
  physicalId: queues[0],
5521
- attributes: {}
5521
+ attributes: { [WRITTEN_QUEUES_KEY]: queues.join(",") }
5522
5522
  };
5523
5523
  } catch (error) {
5524
5524
  const cause = error instanceof Error ? error : void 0;
@@ -5527,12 +5527,15 @@ var SQSQueuePolicyProvider = class {
5527
5527
  throw thrown;
5528
5528
  }
5529
5529
  }
5530
- async update(logicalId, physicalId, resourceType, properties, _previousProperties) {
5530
+ async update(logicalId, physicalId, resourceType, properties, previousProperties, context) {
5531
5531
  this.logger.debug(`Updating SQS queue policy ${logicalId}: ${physicalId}`);
5532
5532
  const queues = properties["Queues"];
5533
5533
  const policyDocument = properties["PolicyDocument"];
5534
5534
  if (!queues || queues.length === 0) throw new ProvisioningError(`Queues is required for SQS queue policy ${logicalId}`, resourceType, logicalId, physicalId);
5535
5535
  if (!policyDocument) throw new ProvisioningError(`PolicyDocument is required for SQS queue policy ${logicalId}`, resourceType, logicalId, physicalId);
5536
+ const written = recordedQueues(physicalId, context?.recordedAttributes);
5537
+ const listedOnly = await this.queuesCarryingDocument(listedQueues(previousProperties).filter((url) => !written.includes(url) && !queues.includes(url)), previousProperties["PolicyDocument"], logicalId);
5538
+ const removed = [...written.filter((url) => !queues.includes(url)), ...listedOnly];
5536
5539
  try {
5537
5540
  const policyDoc = typeof policyDocument === "string" ? policyDocument : JSON.stringify(policyDocument);
5538
5541
  for (const queueUrl of queues) {
@@ -5542,21 +5545,35 @@ var SQSQueuePolicyProvider = class {
5542
5545
  Attributes: { Policy: policyDoc }
5543
5546
  }));
5544
5547
  }
5548
+ for (const queueUrl of removed) await this.clearQueuePolicy(queueUrl, resourceType, logicalId, context?.expectedRegion, "pre-update");
5545
5549
  this.logger.debug(`Successfully updated SQS queue policy ${logicalId}`);
5546
5550
  return {
5547
5551
  physicalId: queues[0],
5548
5552
  wasReplaced: false,
5549
- attributes: {}
5553
+ attributes: { [WRITTEN_QUEUES_KEY]: queues.join(",") }
5550
5554
  };
5551
5555
  } catch (error) {
5556
+ if (error instanceof ProvisioningError) throw error;
5552
5557
  const cause = error instanceof Error ? error : void 0;
5553
5558
  throw new ProvisioningError(`Failed to update SQS queue policy ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
5554
5559
  }
5555
5560
  }
5556
- async delete(logicalId, physicalId, resourceType, _properties, context) {
5561
+ async delete(logicalId, physicalId, resourceType, properties, context) {
5557
5562
  this.logger.debug(`Deleting SQS queue policy ${logicalId}: ${physicalId}`);
5558
- const queueUrls = physicalId.split(",");
5563
+ const named = physicalId.includes(",") ? splitQueueUrls(physicalId) : recordedQueues(physicalId, context?.recordedAttributes);
5564
+ const queueUrls = [...physicalId.includes(",") ? [] : await this.queuesCarryingDocument(listedQueues(properties ?? {}).filter((url) => !named.includes(url)), properties?.["PolicyDocument"], logicalId), ...named];
5565
+ if (queueUrls.length === 0) throw new ProvisioningError(`Failed to delete SQS queue policy ${logicalId}: its physical id names no queue URL`, resourceType, logicalId, physicalId);
5559
5566
  for (const queueUrl of queueUrls) try {
5567
+ await this.clearQueuePolicy(queueUrl, resourceType, logicalId, context?.expectedRegion);
5568
+ } catch (error) {
5569
+ if (error instanceof ProvisioningError) throw error;
5570
+ const cause = error instanceof Error ? error : void 0;
5571
+ throw new ProvisioningError(`Failed to delete SQS queue policy ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
5572
+ }
5573
+ this.logger.debug(`Successfully deleted SQS queue policy ${logicalId}`);
5574
+ }
5575
+ async clearQueuePolicy(queueUrl, resourceType, logicalId, expectedRegion, phase = "not-found") {
5576
+ try {
5560
5577
  await this.sqsClient.send(new SetQueueAttributesCommand({
5561
5578
  QueueUrl: queueUrl,
5562
5579
  Attributes: { Policy: "" }
@@ -5564,33 +5581,77 @@ var SQSQueuePolicyProvider = class {
5564
5581
  } catch (error) {
5565
5582
  if (error instanceof Error && (error.name === "QueueDoesNotExist" || error.message.includes("does not exist"))) {
5566
5583
  const clientRegion = await this.sqsClient.config.region();
5567
- assertRegionMatch(clientRegion, context?.expectedRegion, resourceType, logicalId, queueUrl);
5584
+ assertRegionMatch(clientRegion, expectedRegion, resourceType, logicalId, queueUrl, phase);
5568
5585
  this.logger.debug(`Queue ${queueUrl} does not exist, skipping policy deletion`);
5569
- continue;
5586
+ return;
5570
5587
  }
5571
- const cause = error instanceof Error ? error : void 0;
5572
- throw new ProvisioningError(`Failed to delete SQS queue policy ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
5588
+ throw error;
5573
5589
  }
5574
- this.logger.debug(`Successfully deleted SQS queue policy ${logicalId}`);
5575
5590
  }
5576
- async readCurrentState(physicalId, _logicalId, _resourceType) {
5577
- let policyAttr;
5591
+ async queuesCarryingDocument(candidates, document, logicalId) {
5592
+ if (candidates.length === 0) return [];
5593
+ let reference;
5594
+ if (typeof document === "string" && document.length > 0) reference = canonicalPolicy(document);
5595
+ else if (document !== null && typeof document === "object") reference = canonicalJson$1(document);
5596
+ if (reference === void 0) {
5597
+ this.logger.warn(safeMsg`The queues ${candidates.join(", ")} listed by ${logicalId} were not checked (no policy document recorded to compare with) and may still carry its policy.`);
5598
+ return [];
5599
+ }
5600
+ const carrying = [];
5601
+ for (const queueUrl of candidates) {
5602
+ const current = await this.readPolicyForWidening(queueUrl);
5603
+ if (current.kind === "policy" && canonicalPolicy(current.policy) === reference) carrying.push(queueUrl);
5604
+ else if (current.kind === "unreadable") this.logger.warn(safeMsg`Could not read the policy of queue ${queueUrl} (${current.reason}), so it is not cleared: it may still carry the policy of ${logicalId}.`);
5605
+ else this.logger.debug(safeMsg`Queue ${queueUrl} does not carry the policy of ${logicalId}; left as is`);
5606
+ }
5607
+ return carrying;
5608
+ }
5609
+ async readPolicyForWidening(queueUrl) {
5578
5610
  try {
5579
- policyAttr = (await this.sqsClient.send(new GetQueueAttributesCommand({
5580
- QueueUrl: physicalId,
5611
+ const policy = (await this.sqsClient.send(new GetQueueAttributesCommand({
5612
+ QueueUrl: queueUrl,
5581
5613
  AttributeNames: ["Policy"]
5582
5614
  }))).Attributes?.["Policy"];
5615
+ return policy ? {
5616
+ kind: "policy",
5617
+ policy
5618
+ } : { kind: "none" };
5583
5619
  } catch (err) {
5584
- const e = err;
5585
- if (e.name === "QueueDoesNotExist" || e.name === "AWS.SimpleQueueService.NonExistentQueue") return RESOURCE_NOT_FOUND;
5586
- throw err;
5620
+ const name = err.name;
5621
+ if (name === "QueueDoesNotExist" || name === "AWS.SimpleQueueService.NonExistentQueue") return { kind: "none" };
5622
+ return {
5623
+ kind: "unreadable",
5624
+ reason: name ?? "error"
5625
+ };
5626
+ }
5627
+ }
5628
+ async readCurrentState(physicalId, _logicalId, _resourceType) {
5629
+ const queueUrls = splitQueueUrls(physicalId);
5630
+ if (queueUrls.length === 0) return void 0;
5631
+ const held = [];
5632
+ let firstPolicy;
5633
+ for (const queueUrl of queueUrls) {
5634
+ let policyAttr;
5635
+ try {
5636
+ policyAttr = (await this.sqsClient.send(new GetQueueAttributesCommand({
5637
+ QueueUrl: queueUrl,
5638
+ AttributeNames: ["Policy"]
5639
+ }))).Attributes?.["Policy"];
5640
+ } catch (err) {
5641
+ const e = err;
5642
+ if (e.name === "QueueDoesNotExist" || e.name === "AWS.SimpleQueueService.NonExistentQueue") continue;
5643
+ throw err;
5644
+ }
5645
+ if (!policyAttr) continue;
5646
+ held.push(queueUrl);
5647
+ firstPolicy ??= policyAttr;
5587
5648
  }
5588
- if (!policyAttr) return RESOURCE_NOT_FOUND;
5589
- const result = { Queues: [physicalId] };
5649
+ if (firstPolicy === void 0) return RESOURCE_NOT_FOUND;
5650
+ const result = { Queues: held };
5590
5651
  try {
5591
- result["PolicyDocument"] = JSON.parse(policyAttr);
5652
+ result["PolicyDocument"] = JSON.parse(firstPolicy);
5592
5653
  } catch {
5593
- result["PolicyDocument"] = policyAttr;
5654
+ result["PolicyDocument"] = firstPolicy;
5594
5655
  }
5595
5656
  return result;
5596
5657
  }
@@ -5615,6 +5676,49 @@ var SQSQueuePolicyProvider = class {
5615
5676
  function isSqsQueueUrl(value) {
5616
5677
  return value.startsWith("https://sqs.") && value.includes("/");
5617
5678
  }
5679
+ const WRITTEN_QUEUES_KEY = "cdkd:WrittenQueues";
5680
+ function recordedQueues(physicalId, attributes) {
5681
+ const named = splitQueueUrls(physicalId);
5682
+ const value = attributes?.[WRITTEN_QUEUES_KEY];
5683
+ if (typeof value !== "string") return named;
5684
+ const recorded = splitQueueUrls(value);
5685
+ if (recorded.length === 0 || !recorded.every(isListedQueueUrl)) return named;
5686
+ for (const url of recorded) if (!named.includes(url)) named.push(url);
5687
+ return named;
5688
+ }
5689
+ function listedQueues(bag) {
5690
+ const listed = bag["Queues"];
5691
+ if (!Array.isArray(listed)) return [];
5692
+ const out = [];
5693
+ for (const entry of listed) if (typeof entry === "string" && isListedQueueUrl(entry) && !out.includes(entry)) out.push(entry);
5694
+ return out;
5695
+ }
5696
+ function isListedQueueUrl(value) {
5697
+ return isSqsQueueUrl(value) && !value.includes(",") && !value.includes("*");
5698
+ }
5699
+ function canonicalJson$1(value) {
5700
+ const sortKeys = (v) => {
5701
+ if (Array.isArray(v)) return v.map(sortKeys);
5702
+ if (v !== null && typeof v === "object") {
5703
+ const out = Object.create(null);
5704
+ for (const key of Object.keys(v).sort()) out[key] = sortKeys(v[key]);
5705
+ return out;
5706
+ }
5707
+ return v;
5708
+ };
5709
+ const sorted = sortKeys(value);
5710
+ return JSON.stringify(sorted);
5711
+ }
5712
+ function canonicalPolicy(text) {
5713
+ try {
5714
+ return canonicalJson$1(JSON.parse(text));
5715
+ } catch {
5716
+ return `raw:${text}`;
5717
+ }
5718
+ }
5719
+ function splitQueueUrls(physicalId) {
5720
+ return physicalId.split(",").filter((url) => url.length > 0);
5721
+ }
5618
5722
 
5619
5723
  //#endregion
5620
5724
  //#region src/provisioning/providers/create-ownership.ts
@@ -5748,7 +5852,7 @@ var SNSTopicProvider = class {
5748
5852
  this.logger.debug(`Cleaned up partially-created SNS topic ${logicalId} (${topicArn}) after wiring failure`);
5749
5853
  } catch (cleanupError) {
5750
5854
  leftBehindArn = topicArn;
5751
- warn(`Failed to clean up partially-created SNS topic ${logicalId} (${topicArn}): ${describeAwsFailure(cleanupError).detail}. On a first-time create the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself before the next deploy: ${pasteableAwsCommand(maskSecrets)`aws sns delete-topic --topic-arn ${topicArn}`.render()}`);
5855
+ warn(`Failed to clean up partially-created SNS topic ${logicalId} (${topicArn}): ${describeAwsFailure(cleanupError).detail}. Outside a rollback's re-create, the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself before the next deploy: ${pasteableAwsCommand(maskSecrets)`aws sns delete-topic --topic-arn ${topicArn}`.render()}`);
5752
5856
  }
5753
5857
  throw markAuxiliaryFailure(innerError, logicalId);
5754
5858
  }
@@ -11185,7 +11289,7 @@ var LogsLogGroupProvider = class {
11185
11289
  identifier: logGroupName,
11186
11290
  maskSecrets: mask
11187
11291
  });
11188
- const manualStep = deleteCommand ? `On a first-time create the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself before the next deploy: ${deleteCommand}` : "On a first-time create the failed deploy's rollback journal records it for `cdkd rollback --revert-failed`; otherwise delete it yourself before the next deploy, via the console: the log group name cannot be reproduced safely on a command line.";
11292
+ const manualStep = deleteCommand ? `Outside a rollback's re-create, the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself before the next deploy: ${deleteCommand}` : "Outside a rollback's re-create, the failed deploy's rollback journal records it for `cdkd rollback --revert-failed`; otherwise delete it yourself before the next deploy, via the console: the log group name cannot be reproduced safely on a command line.";
11189
11293
  this.logger.warn(mask(`Failed to clean up partially-created log group ${displaySafe(logicalId)} (${displaySafe(mask(logGroupName))}): ${describeAwsFailure(cleanupError).detail}. ${manualStep}`));
11190
11294
  }
11191
11295
  throw markAuxiliaryFailure(innerError, logicalId);
@@ -12371,7 +12475,7 @@ var SSMParameterProvider = class SSMParameterProvider {
12371
12475
  identifier: name,
12372
12476
  maskSecrets: mask
12373
12477
  });
12374
- const manualStep = deleteCommand ? `On a first-time create the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself before the next deploy: ${deleteCommand}` : "On a first-time create the failed deploy's rollback journal records it for `cdkd rollback --revert-failed`; otherwise delete it yourself before the next deploy, via the console: the parameter name cannot be reproduced safely on a command line: a command naming the sanitized form would delete a DIFFERENT parameter, and one naming a name that is not inert unquoted could run part of it as shell.";
12478
+ const manualStep = deleteCommand ? `Outside a rollback's re-create, the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself before the next deploy: ${deleteCommand}` : "Outside a rollback's re-create, the failed deploy's rollback journal records it for `cdkd rollback --revert-failed`; otherwise delete it yourself before the next deploy, via the console: the parameter name cannot be reproduced safely on a command line: a command naming the sanitized form would delete a DIFFERENT parameter, and one naming a name that is not inert unquoted could run part of it as shell.";
12375
12479
  warn(`Failed to clean up partially-created SSM parameter ${displaySafe(logicalId)} (${displaySafe(mask(name))}): ${describeAwsFailure(cleanupError).detail}. ${manualStep}`);
12376
12480
  }
12377
12481
  throw markAuxiliaryFailure(innerError, logicalId);
@@ -23210,13 +23314,13 @@ var ELBv2Provider = class {
23210
23314
  this.logger.warn(maskerOrIdentity(maskSecrets)(skippedCleanupText(heldBefore, `Listener ${logicalId} (${listenerArn})`, pasteableAwsCommand(maskSecrets)`aws elbv2 delete-listener --listener-arn ${listenerArn}`.render())));
23211
23315
  throw markAuxiliaryFailure(innerError, logicalId);
23212
23316
  }
23213
- if (isInterruptedWaitError(innerError)) this.logger.warn(maskerOrIdentity(maskSecrets)(`Interrupted after creating Listener ${logicalId} (${listenerArn}) but before its attributes were applied. Nothing in cdkd state refers to it, so cdkd is deleting it now — left behind it would fail the next deploy with DuplicateListener and destroy could not reach it. If that delete fails, on a first-time create the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise remove it yourself: ${pasteableAwsCommand(maskSecrets)`aws elbv2 delete-listener --listener-arn ${listenerArn}`.render()}`));
23317
+ if (isInterruptedWaitError(innerError)) this.logger.warn(maskerOrIdentity(maskSecrets)(`Interrupted after creating Listener ${logicalId} (${listenerArn}) but before its attributes were applied. Nothing in cdkd state refers to it, so cdkd is deleting it now — left behind it would fail the next deploy with DuplicateListener and destroy could not reach it. If that delete fails, outside a rollback's re-create, the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise remove it yourself: ${pasteableAwsCommand(maskSecrets)`aws elbv2 delete-listener --listener-arn ${listenerArn}`.render()}`));
23214
23318
  try {
23215
23319
  await this.getClient().send(new DeleteListenerCommand({ ListenerArn: listenerArn }));
23216
23320
  this.logger.debug(`Cleaned up partially-created Listener ${logicalId} (${listenerArn}) after attributes-wiring failure`);
23217
23321
  } catch (cleanupError) {
23218
23322
  leftBehindArn = listenerArn;
23219
- this.logger.warn(`Failed to clean up partially-created Listener ${logicalId} (${listenerArn}): ${this.maskErrorMessage(cleanupError, maskSecrets)}. On a first-time create the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself before the next deploy: ${pasteableAwsCommand(maskSecrets)`aws elbv2 delete-listener --listener-arn ${listenerArn}`.render()}`);
23323
+ this.logger.warn(`Failed to clean up partially-created Listener ${logicalId} (${listenerArn}): ${this.maskErrorMessage(cleanupError, maskSecrets)}. Outside a rollback's re-create, the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself before the next deploy: ${pasteableAwsCommand(maskSecrets)`aws elbv2 delete-listener --listener-arn ${listenerArn}`.render()}`);
23220
23324
  }
23221
23325
  throw markAuxiliaryFailure(innerError, logicalId);
23222
23326
  }
@@ -28738,13 +28842,13 @@ var ServiceDiscoveryProvider = class ServiceDiscoveryProvider {
28738
28842
  this.logger.debug(`Applied ${Object.keys(attrs).length} ServiceAttribute(s) for ${logicalId}`);
28739
28843
  }
28740
28844
  } catch (innerError) {
28741
- if (isInterruptedWaitError(innerError)) this.logger.warn(maskerOrIdentity(maskSecrets)(`Interrupted after creating ServiceDiscovery Service ${logicalId} (${serviceId}) but before its ServiceAttributes were applied. Nothing in cdkd state refers to it, so cdkd is deleting it now — left behind it would fail the next deploy on a name collision AND block deletion of its namespace with ResourceInUse. If that delete fails, on a first-time create the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise remove it yourself: ${pasteableAwsCommand(maskSecrets)`aws servicediscovery delete-service --id ${serviceId}`.render()}`));
28845
+ if (isInterruptedWaitError(innerError)) this.logger.warn(maskerOrIdentity(maskSecrets)(`Interrupted after creating ServiceDiscovery Service ${logicalId} (${serviceId}) but before its ServiceAttributes were applied. Nothing in cdkd state refers to it, so cdkd is deleting it now — left behind it would fail the next deploy on a name collision AND block deletion of its namespace with ResourceInUse. If that delete fails, outside a rollback's re-create, the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise remove it yourself: ${pasteableAwsCommand(maskSecrets)`aws servicediscovery delete-service --id ${serviceId}`.render()}`));
28742
28846
  try {
28743
28847
  await client.send(new DeleteServiceCommand$1({ Id: serviceId }));
28744
28848
  leftBehindServiceId = void 0;
28745
28849
  this.logger.debug(`Cleaned up partially-created ServiceDiscovery Service ${logicalId} (${serviceId}) after ServiceAttributes wiring failure`);
28746
28850
  } catch (cleanupError) {
28747
- this.logger.warn(`Failed to clean up partially-created ServiceDiscovery Service ${logicalId} (${serviceId}) after ServiceAttributes wiring failure: ${this.maskErrorMessage(cleanupError, maskSecrets)}. On a first-time create the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself before the next deploy: ${pasteableAwsCommand(maskSecrets)`aws servicediscovery delete-service --id ${serviceId}`.render()}`);
28851
+ this.logger.warn(`Failed to clean up partially-created ServiceDiscovery Service ${logicalId} (${serviceId}) after ServiceAttributes wiring failure: ${this.maskErrorMessage(cleanupError, maskSecrets)}. Outside a rollback's re-create, the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself before the next deploy: ${pasteableAwsCommand(maskSecrets)`aws servicediscovery delete-service --id ${serviceId}`.render()}`);
28748
28852
  }
28749
28853
  throw markAuxiliaryFailure(innerError, logicalId);
28750
28854
  }
@@ -33007,7 +33111,7 @@ var KMSProvider = class {
33007
33111
  markAuxiliaryFailure(error, logicalId);
33008
33112
  const aws = pasteableAwsCommand();
33009
33113
  const region = await this.regionArg(aws);
33010
- this.logger.warn(safeMsg`KMS key ${createdKeyId} was created for ${logicalId}, but a follow-up call failed. A retry of this create reuses that key instead of creating another, so do not delete it while the deploy is still retrying. If the deploy then FAILS on a first-time create, its rollback journal records the key for \`cdkd rollback --revert-failed\` to schedule its deletion; otherwise schedule it yourself with: ${aws`aws kms schedule-key-deletion --key-id ${createdKeyId}${region} --pending-window-in-days 7`.render()}`);
33114
+ this.logger.warn(safeMsg`KMS key ${createdKeyId} was created for ${logicalId}, but a follow-up call failed. A retry of this create reuses that key instead of creating another, so do not delete it while the deploy is still retrying. If the deploy then FAILS (outside a rollback's re-create), its rollback journal records the key for \`cdkd rollback --revert-failed\` to schedule its deletion; otherwise schedule it yourself with: ${aws`aws kms schedule-key-deletion --key-id ${createdKeyId}${region} --pending-window-in-days 7`.render()}`);
33011
33115
  }
33012
33116
  const cause = error instanceof Error ? error : void 0;
33013
33117
  const thrown = new ProvisioningError(`Failed to create KMS Key ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, void 0, cause);
@@ -35458,7 +35562,7 @@ var PipesPipeProvider = class {
35458
35562
  const orphaned = async (why) => {
35459
35563
  const aws = pasteableAwsCommand(mask);
35460
35564
  const command = aws`aws pipes delete-pipe --name ${name}${await orphanCommandRegionArg(this.getClient(), aws)}`;
35461
- original.message += ` (cdkd could not delete the pipe it had created: ${why}; on a first-time create the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`. ` + (command.text !== void 0 ? `Otherwise delete it yourself with: ${command.text})` : `Otherwise delete it yourself from the EventBridge Pipes console.)`);
35565
+ original.message += ` (cdkd could not delete the pipe it had created: ${why}; outside a rollback's re-create, the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`. ` + (command.text !== void 0 ? `Otherwise delete it yourself with: ${command.text})` : `Otherwise delete it yourself from the EventBridge Pipes console.)`);
35462
35566
  return leftBehind();
35463
35567
  };
35464
35568
  try {
@@ -36492,7 +36596,7 @@ var FSxFileSystemProvider = class {
36492
36596
  this.logger.warn(`Rolled back partially-created FSx FileSystem ${fileSystemId}`);
36493
36597
  } catch (cleanupError) {
36494
36598
  survivorId = fileSystemId;
36495
- this.logger.warn(`Failed to roll back partially-created FSx FileSystem ${fileSystemId}: ${describeAwsFailure(cleanupError).detail} — on a first-time create the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself to stop billing`);
36599
+ this.logger.warn(`Failed to roll back partially-created FSx FileSystem ${fileSystemId}: ${describeAwsFailure(cleanupError).detail} — outside a rollback's re-create, the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`; otherwise delete it yourself to stop billing`);
36496
36600
  }
36497
36601
  if (error instanceof ProvisioningError) {
36498
36602
  if (survivorId !== void 0) markCreatedBeforeFailure(error, logicalId, resourceType, survivorId);
@@ -43136,4 +43240,4 @@ var ACMCertificateProvider = class {
43136
43240
 
43137
43241
  //#endregion
43138
43242
  export { ACMCertificateProvider, ASGProvider, AgentCoreBrowserProvider, AgentCoreCodeInterpreterProvider, AgentCoreEvaluatorProvider, AgentCoreRuntimeProvider, ApiGatewayProvider, ApiGatewayV2Provider, AppSyncProvider, BudgetsBudgetProvider, CloudFrontDistributionProvider, CloudFrontOACProvider, CloudFrontOAIProvider, CloudTrailProvider, CloudWatchAlarmProvider, CloudWatchAnomalyDetectorProvider, CodeBuildProvider, CodeCommitRepositoryProvider, CognitoUserPoolProvider, DLMLifecyclePolicyProvider, DocDBProvider, DocDBSubnetGroupProvider, DynamoDBGlobalTableProvider, DynamoDBTableProvider, EC2Provider, ECRProvider, ECSProvider, EFSProvider, ELBv2Provider, EMRClusterProvider, EMRInstanceFleetConfigProvider, EMRInstanceGroupConfigProvider, ElastiCacheProvider, EventBridgeBusProvider, EventBridgeRuleProvider, FSxFileSystemProvider, FirehoseProvider, GlueConnectionProvider, GlueCrawlerProvider, GlueJobProvider, GlueProvider, GlueSecurityConfigurationProvider, GlueTriggerProvider, GlueWorkflowProvider, IAMAccessKeyProvider, IAMInstanceProfileProvider, IAMManagedPolicyProvider, IAMPolicyProvider, IAMRoleProvider, IAMUserGroupProvider, KMSProvider, KinesisStreamConsumerProvider, KinesisStreamProvider, LambdaEventInvokeConfigProvider, LambdaEventSourceMappingProvider, LambdaFunctionProvider, LambdaLayerVersionProvider, LambdaMicrovmImageProvider, LambdaPermissionProvider, LambdaUrlProvider, LogsLogGroupProvider, NeptuneProvider, NestedStackProvider, PipesPipeProvider, RDSDBProxyEndpointProvider, RDSDBProxyProvider, RDSDBProxyTargetGroupProvider, RDSProvider, Route53Provider, S3BucketPolicyProvider, S3BucketProvider, S3DirectoryBucketProvider, S3TablesProvider, S3VectorsProvider, SNSSubscriptionProvider, SNSTopicPolicyProvider, SNSTopicProvider, SQSQueuePolicyProvider, SQSQueueProvider, SSMParameterProvider, SchedulerScheduleProvider, SecretsManagerSecretProvider, ServiceDiscoveryProvider, StepFunctionsProvider, WAFv2WebACLProvider, WaitConditionHandleProvider };
43139
- //# sourceMappingURL=provider-classes-DNkoEEo4.js.map
43243
+ //# sourceMappingURL=provider-classes-CtsCylnp.js.map