@go-to-k/cdkd 0.300.0 → 0.300.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.
Files changed (27) hide show
  1. package/dist/{asg-provider-COcKVcvZ.js → asg-provider-DJdNNqDe.js} +3 -3
  2. package/dist/{asg-provider-COcKVcvZ.js.map → asg-provider-DJdNNqDe.js.map} +1 -1
  3. package/dist/cli.js +2 -2
  4. package/dist/{deploy-engine-C-4ho8TJ.js → deploy-engine-DOBzE5TD.js} +702 -291
  5. package/dist/deploy-engine-DOBzE5TD.js.map +1 -0
  6. package/dist/{iam-policy-targets-BxP3yqlr.js → iam-policy-targets-DFk7zr0Q.js} +68 -2
  7. package/dist/iam-policy-targets-DFk7zr0Q.js.map +1 -0
  8. package/dist/{iam-role-provider-a-8z7Dpm.js → iam-role-provider-C8gNXG1G.js} +15 -10
  9. package/dist/iam-role-provider-C8gNXG1G.js.map +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -3
  12. package/dist/{neptune-provider-Bnr2VC6V.js → neptune-provider-UDy6HC5O.js} +3 -3
  13. package/dist/{neptune-provider-Bnr2VC6V.js.map → neptune-provider-UDy6HC5O.js.map} +1 -1
  14. package/dist/{program-BHjdsRtD.js → program-BDm58Wc8.js} +9 -9
  15. package/dist/{program-BHjdsRtD.js.map → program-BDm58Wc8.js.map} +1 -1
  16. package/dist/{provider-classes-CVC9_-km.js → provider-classes-DzoIZFZK.js} +315 -84
  17. package/dist/provider-classes-DzoIZFZK.js.map +1 -0
  18. package/dist/{rds-provider-QKN-WHF3.js → rds-provider-C-lGTdAb.js} +13 -7
  19. package/dist/rds-provider-C-lGTdAb.js.map +1 -0
  20. package/dist/{version-CXGQKplb.js → version-CZbKGFSS.js} +2 -2
  21. package/dist/{version-CXGQKplb.js.map → version-CZbKGFSS.js.map} +1 -1
  22. package/package.json +1 -1
  23. package/dist/deploy-engine-C-4ho8TJ.js.map +0 -1
  24. package/dist/iam-policy-targets-BxP3yqlr.js.map +0 -1
  25. package/dist/iam-role-provider-a-8z7Dpm.js.map +0 -1
  26. package/dist/provider-classes-CVC9_-km.js.map +0 -1
  27. package/dist/rds-provider-QKN-WHF3.js.map +0 -1
@@ -1,13 +1,13 @@
1
1
  import { r as getAwsClients } from "./aws-clients-B_CEQGE1.js";
2
2
  import { B as safeMsg, F as displaySafe, I as displayStackName, L as isPasteableIdent, O as SECRET_REF_MAX_CODE_POINTS, P as displayIdent, a as getLogger, b as generateResourceNameWithFallback, n as isAwsAuthoredFailure, r as safeStringify, t as describeAwsFailure, y as generateResourceName, z as plainIdentOr } from "./aws-failure-text-BEQfs6za.js";
3
- import { $ as protectedReplacementAdvice, $n as isAmbiguousOutcomeError, $t as credentialFingerprint, A as isQuotableImportValue, B as isTerminalDeleteFailure, Bn as withheldTargetClause, C as setBounded, D as VALUE_NOT_SHOWN, E as assertRegionMatch, F as resolveExplicitPhysicalId, Gt as injectiveKeyPrefix, H as observeThenDisableProtection, In as plainOrDescribed, L as ProtectionFlipRegistry, M as quotedRemedyLogicalId, Mn as hasClauseBreak, Mt as markCreatedBeforeFailure, N as refusalTypeShown, Nn as isInertUnquoted, O as isPlainImportJson, P as remedyLogicalId, Pn as pasteableCommand, Q as pasteableAwsCommand, Qt as clientDefaultsFor, S as replayedSendWindow, St as withDerivedNameMasks, T as RESOURCE_NOT_FOUND, Tt as clearCreatedBeforeFailure, U as protectionFlipKey, V as logGroupProtectionSite, W as rdsFamilyProtectionSite, Wt as injectiveKey, X as WITHHELD_AWS_COMMAND, Xn as markReplayMayCollide, Xt as ambientClientDefaults, Y as UNNAMEABLE_ID_CLAUSE, Yn as markNameCollision, Yt as withPasteableAwsProfile, Z as isAwsCliLiteral, Zt as ambientCredentialConfig, _ as RecentIdSet, _t as createMaskedLogSinks, a as onlySecretDerived, ar as isMarkedNonRetryable, at as startInterruptWatch, b as isInsideWindow, bt as maskDeep, c as recordedPrincipalsRepair, cr as markRedactedCause, ct as canonicalizeRoute53QueryName, dt as compositeIdSkipResult, en as AccountIdUnavailableError, et as renderDisableCommand, ft as logicalIdShown, g as AmbiguousCreateLatch, gn as ProvisioningError, gt as stateOrphanRecordRemedy, h as AMBIGUOUS_LATCH_TTL_MS, ht as segmentAfterAnchor, i as holdsSecretDerivedEntry, ir as THROTTLING_ERROR_NAMES, it as isInterruptedWaitError, j as normalizeAwsTagsToCfn, jn as commandHole, jt as markAuxiliaryFailure, k as isPlainImportValue, lr as wrapMaskedAwsError, lt as compositeIdFormatMessage, nn as CdkdError, nr as isTransientServerError, o as readPrincipalLists, or as isThrottlingError, ot as ElapsedBudgetRegistry, p as withRemovalDefaults, pt as packCompositeId, q as userPoolProtectionSite, r as SECRET_DERIVED_READ_LIVE, sr as markNonRetryable, tr as isRetryableTransientError, u as clearOnUpdateRemoval, ut as compositeIdSeparatorRefusal, v as ambiguousAttemptLead, vn as ResourceUpdateNotSupportedError, vt as createMaskedRetryLogger, w as withoutServerErrorRetries, x as replayFollowedAmbiguousAttempt, xt as maskerOrIdentity, y as createAttemptKey, yt as isSecretDerivedValue, z as deleteWithProtectionCompensation, zn as shellQuote } from "./iam-policy-targets-BxP3yqlr.js";
3
+ import { $ as protectedReplacementAdvice, $n as explicitDenyPolicyKind, $t as ambientCredentialConfig, A as isQuotableImportValue, B as isTerminalDeleteFailure, C as setBounded, D as VALUE_NOT_SHOWN, E as assertRegionMatch, F as resolveExplicitPhysicalId, Fn as isInertUnquoted, H as observeThenDisableProtection, Hn as withheldTargetClause, In as pasteableCommand, Kt as injectiveKey, L as ProtectionFlipRegistry, M as quotedRemedyLogicalId, Mt as markCreatedBeforeFailure, N as refusalTypeShown, Nn as commandHole, Nt as markSupersedesEarlierCreate, O as isPlainImportJson, P as remedyLogicalId, Pn as hasClauseBreak, Q as pasteableAwsCommand, Qn as markReplayMayCollide, Qt as ambientClientDefaults, Rn as plainOrDescribed, S as replayedSendWindow, St as withDerivedNameMasks, T as RESOURCE_NOT_FOUND, Tt as clearCreatedBeforeFailure, U as protectionFlipKey, V as logGroupProtectionSite, Vn as shellQuote, W as rdsFamilyProtectionSite, X as WITHHELD_AWS_COMMAND, Y as UNNAMEABLE_ID_CLAUSE, Z as isAwsCliLiteral, Zn as markNameCollision, Zt as withPasteableAwsProfile, _ as RecentIdSet, _t as createMaskedLogSinks, a as onlySecretDerived, ar as isRetryableTransientError, at as startInterruptWatch, b as isInsideWindow, bn as ResourceUpdateNotSupportedError, bt as maskDeep, c as recordedPrincipalsRepair, cr as THROTTLING_ERROR_NAMES, ct as canonicalizeRoute53QueryName, dr as markNonRetryable, dt as compositeIdSkipResult, en as clientDefaultsFor, et as renderDisableCommand, fr as markRedactedCause, ft as logicalIdShown, g as AmbiguousCreateLatch, gt as stateOrphanRecordRemedy, h as AMBIGUOUS_LATCH_TTL_MS, ht as segmentAfterAnchor, i as holdsSecretDerivedEntry, in as CdkdError, it as isInterruptedWaitError, j as normalizeAwsTagsToCfn, jt as markAuxiliaryFailure, k as isPlainImportValue, lr as isMarkedNonRetryable, lt as compositeIdFormatMessage, nn as AccountIdUnavailableError, nr as isAmbiguousOutcomeError, o as readPrincipalLists, or as isTransientServerError, ot as ElapsedBudgetRegistry, p as withRemovalDefaults, pr as wrapMaskedAwsError, pt as packCompositeId, q as userPoolProtectionSite, qt as injectiveKeyPrefix, r as SECRET_DERIVED_READ_LIVE, rr as isExplicitDenyError, tn as credentialFingerprint, u as clearOnUpdateRemoval, ur as isThrottlingError, ut as compositeIdSeparatorRefusal, v as ambiguousAttemptLead, vn as ProvisioningError, vt as createMaskedRetryLogger, w as withoutServerErrorRetries, x as replayFollowedAmbiguousAttempt, xt as maskerOrIdentity, y as createAttemptKey, yt as isSecretDerivedValue, z as deleteWithProtectionCompensation } from "./iam-policy-targets-DFk7zr0Q.js";
4
4
  import { s as ambientRegion } from "./aws-client-defaults-DBXBcg0J.js";
5
- import { $ as S3_AUTO_DELETE_OBJECTS_TAG, $a as findSilentDropProperties, Ao as lambdaFunctionNameForMask, Ar as unchangedBehindSecretReference, At as withNestedStackContext, Br as ec2InstanceProtectionSite, Bt as awaitInFlightSibling, C as withApiLimit, Cl as derivePartitionAndUrlSuffix, Co as requireConfigObject, Cr as getCurrentResourceSecrets, Cs as physicalNameCopiesOf, Ds as carriesSecretMask, Fl as renderAssemblyPathEscape, Fr as deleteSkipReason, G as deleteBudgetKey, Gt as replacedDeleteFailureVerdict, H as DYNAMODB_DELETE_MIN_RESOURCE_TIMEOUT_MS, Hr as observeThenDisableInstanceApiTermination, Ht as getStackRecords, Il as resolveAssemblyPath, Ir as withIndeterminateGuard, J as DELETE_INDEX_WAIT_PROCEED_NOTE, K as resolveDynamoDbDeleteBudgetClock, Li as passedParameterClassesOf, Lr as isWaitAbandonedError, Nl as describeFileReadFailure, Oo as withRetry, Pi as parseWebACLArn, Pl as displayAssemblyPath, Q as ECR_AUTO_DELETE_IMAGES_TAG, Rr as markWaitAbandoned, S as lookupEachName, Sl as canonicalizeRegion, So as requireConfigArray, Ss as recoverMaskedOutput, St as getNestedRevertRun, Tt as revertNestedChildFromJournal, U as beginDeleteWait, Uo as passedNoEchoParametersOf, Ur as reDisableInstanceApiTermination, V as DynamoDBGlobalTableProvider, Vr as isTerminationProtectionPropagationError, W as compensateRemovedDeletionProtection, Wi as accountArgs, Wr as reEnableInstanceApiTermination, X as deleteTableWithIndexBusyRetry, Xo as hasMaskableValues, Y as INDEX_SETTLE_POLL_INTERVAL_MS, Z as waitForIndexesSettled, Za as withheldAccountClause, _c as rewriteTemplateAssetReferences, _o as configBooleanRefusal, an as getCurrentProducerRegions, ar as acquireIdempotencyToken, b as chunks, bo as readConfigString, c as isAbsoluteAssetPath, cn as isRedactedRecordedValue, cr as planTagDiff, cs as markSameGenerationBag, do as coerceWarmThroughput$1, dr as tagMapAsList, ds as redactSecretsForState, et as hasCdkAutoDeleteTag, fc as stringifyValue, fi as s3BucketArn, fo as isWarmThroughputDecrease, fr as tagPlanWarning, gi as s3BucketWebsiteUrl, go as coerceCfnInteger, gs as dynamicReferenceTokens, hi as s3BucketRegionalDomainName, ho as coerceCfnBoolean, jo as sameLambdaFunctionAddress, ko as canonicalLambdaFunctionName, kr as slowCcOperationTimeoutMs, kt as getCurrentNestedStackContext, l as listNestedTemplateRows, li as outputReferenceProvenanceOf, ln as redactedDeleteAddressFields, lr as readTagList, ls as recordReferenceProvenanceEntry, mi as s3BucketDualStackDomainName, mo as toFiniteNumber, mr as stringifyIfAssigned, ms as withoutPhysicalNameCopies, nt as getPriorAttempts, or as DBPROXY_TAGS_WHAT, pi as s3BucketDomainName, po as toCfnInteger, pr as definedAttributes, q as resolveDynamoDbDeleteBudgetMs, rr as reserveStackCreateToken, rt as markRefusedBeforeApplying, s as findNestedTemplateTreeDefect, si as isSettledInstanceState, sn as REDACTED_DELETE_ADDRESS_SKIP_REASON, sr as DBPROXY_TAG_OPTIONS, t as DeployEngine, to as withoutSilentDropProperties, tr as earliestDefined, tt as isTruthyCfnBoolean, u as renderNestedTemplateTreeDefect, un as redactedDeleteAddressSkip, uo as WARM_THROUGHPUT_MEMBERS, ur as refuseMalformedDesiredTags, us as snapshotPassProvenance, vo as configIntegerRefusal, wi as getAccountInfo, wo as requireConfigString, ws as recordAttributeIdCopy, x as isAccessDeniedError, xo as replayWarn, ya as refuseMalformedNestedChildOutputs, yl as decodeListingKey, yo as configStringRefusal, za as refuseMalformedResourcesForDestroy } from "./deploy-engine-C-4ho8TJ.js";
6
- import { n as collectInlinePolicyNamesManagedBySiblings, r as IamCreateClientCache, t as IAMRoleProvider } from "./iam-role-provider-a-8z7Dpm.js";
7
- import { a as resolveSecretDerivedPrincipals, i as isResolvableSecretPrincipalList, n as runDestroyForStack, o as canonicalizeIpProtocolValue, r as holdsUnprovenSecretPrincipalToken, s as resolvedResourceTimeoutMs, t as canonicalizeIpv4Cidr } from "./program-BHjdsRtD.js";
8
- import { RDSProvider } from "./rds-provider-QKN-WHF3.js";
9
- import { NeptuneProvider } from "./neptune-provider-Bnr2VC6V.js";
10
- import { ASGProvider } from "./asg-provider-COcKVcvZ.js";
5
+ import { $ as S3_AUTO_DELETE_OBJECTS_TAG, $a as withheldAccountClause, Ao as withRetry, At as withNestedStackContext, Br as markWaitAbandoned, Bt as awaitInFlightSibling, C as withApiLimit, Co as replayWarn, Ei as getAccountInfo, Eo as requireConfigString, Es as recordAttributeIdCopy, Fl as describeFileReadFailure, G as deleteBudgetKey, Go as passedNoEchoParametersOf, Gr as reDisableInstanceApiTermination, Gt as replacedDeleteFailureVerdict, H as DYNAMODB_DELETE_MIN_RESOURCE_TIMEOUT_MS, Hr as ec2InstanceProtectionSite, Ht as getStackRecords, Ii as parseWebACLArn, Il as displayAssemblyPath, J as DELETE_INDEX_WAIT_PROCEED_NOTE, K as resolveDynamoDbDeleteBudgetClock, Ki as accountArgs, Kr as reEnableInstanceApiTermination, Ll as renderAssemblyPathEscape, Lr as deleteSkipReason, Mo as lambdaFunctionNameForMask, Mr as unchangedBehindSecretReference, No as sameLambdaFunctionAddress, Q as ECR_AUTO_DELETE_IMAGES_TAG, Qo as hasMaskableValues, Rl as resolveAssemblyPath, Rr as withIndeterminateGuard, S as lookupEachName, So as readConfigString, St as getNestedRevertRun, Tl as derivePartitionAndUrlSuffix, To as requireConfigObject, Tr as getCurrentResourceSecrets, Ts as physicalNameCopiesOf, Tt as revertNestedChildFromJournal, U as beginDeleteWait, Ur as isTerminationProtectionPropagationError, V as DynamoDBGlobalTableProvider, Va as refuseMalformedResourcesForDestroy, W as compensateRemovedDeletionProtection, Wr as observeThenDisableInstanceApiTermination, X as deleteTableWithIndexBusyRetry, Y as INDEX_SETTLE_POLL_INTERVAL_MS, Z as waitForIndexesSettled, _i as s3BucketRegionalDomainName, _o as coerceCfnBoolean, an as getCurrentProducerRegions, ar as acquireIdempotencyToken, b as chunks, bo as configIntegerRefusal, c as isAbsoluteAssetPath, cn as isRedactedRecordedValue, cr as DBPROXY_TAGS_WHAT, di as outputReferenceProvenanceOf, dr as readTagList, ds as recordReferenceProvenanceEntry, et as hasCdkAutoDeleteTag, fo as WARM_THROUGHPUT_MEMBERS, fr as refuseMalformedDesiredTags, fs as snapshotPassProvenance, gi as s3BucketDualStackDomainName, go as toFiniteNumber, gr as stringifyIfAssigned, gs as withoutPhysicalNameCopies, hi as s3BucketDomainName, ho as toCfnInteger, hr as definedAttributes, jo as canonicalLambdaFunctionName, jr as slowCcOperationTimeoutMs, ks as carriesSecretMask, kt as getCurrentNestedStackContext, l as listNestedTemplateRows, li as isSettledInstanceState, ln as redactedDeleteAddressFields, lr as DBPROXY_TAG_OPTIONS, mc as stringifyValue, mi as s3BucketArn, mo as isWarmThroughputDecrease, mr as tagPlanWarning, nt as getPriorAttempts, or as isRefusedByName, po as coerceWarmThroughput$1, pr as tagMapAsList, ps as redactSecretsForState, q as resolveDynamoDbDeleteBudgetMs, ro as withoutSilentDropProperties, rr as reserveStackCreateToken, rt as markRefusedBeforeApplying, s as findNestedTemplateTreeDefect, sn as REDACTED_DELETE_ADDRESS_SKIP_REASON, sr as markDeleteStarted, t as DeployEngine, to as findSilentDropProperties, tr as earliestDefined, tt as isTruthyCfnBoolean, u as renderNestedTemplateTreeDefect, un as redactedDeleteAddressSkip, ur as planTagDiff, us as markSameGenerationBag, vi as s3BucketWebsiteUrl, vo as coerceCfnInteger, vs as dynamicReferenceTokens, wl as canonicalizeRegion, wo as requireConfigArray, ws as recoverMaskedOutput, x as isAccessDeniedError, xa as refuseMalformedNestedChildOutputs, xl as decodeListingKey, xo as configStringRefusal, yc as rewriteTemplateAssetReferences, yo as configBooleanRefusal, zi as passedParameterClassesOf, zr as isWaitAbandonedError } from "./deploy-engine-DOBzE5TD.js";
6
+ import { n as collectInlinePolicyNamesManagedBySiblings, r as IamCreateClientCache, t as IAMRoleProvider } from "./iam-role-provider-C8gNXG1G.js";
7
+ import { a as resolveSecretDerivedPrincipals, i as isResolvableSecretPrincipalList, n as runDestroyForStack, o as canonicalizeIpProtocolValue, r as holdsUnprovenSecretPrincipalToken, s as resolvedResourceTimeoutMs, t as canonicalizeIpv4Cidr } from "./program-BDm58Wc8.js";
8
+ import { RDSProvider } from "./rds-provider-C-lGTdAb.js";
9
+ import { NeptuneProvider } from "./neptune-provider-UDy6HC5O.js";
10
+ import { ASGProvider } from "./asg-provider-DJdNNqDe.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, ListBucketsCommand, 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";
@@ -417,7 +417,9 @@ var IAMPolicyProvider = class {
417
417
  }
418
418
  let secretPrincipalLacksGrant = false;
419
419
  const detached = context?.resolveSecretDerivedPrincipals?.retryMemo?.detached;
420
+ let removedAny = false;
420
421
  const onDetached = (kind, name) => {
422
+ removedAny = true;
421
423
  if (fromSecret(kind, name)) detached?.add(injectiveKey(kind, name));
422
424
  };
423
425
  const claimed = (kind, name) => {
@@ -505,7 +507,8 @@ var IAMPolicyProvider = class {
505
507
  this.logger.debug(`Successfully deleted IAM policy ${logicalId}`);
506
508
  } catch (error) {
507
509
  const cause = error instanceof Error ? error : void 0;
508
- throw maskError(new ProvisioningError(`Failed to delete IAM policy ${logicalId}: ${mask(error instanceof Error ? error.message : String(error))}`, resourceType, logicalId, physicalId, cause));
510
+ const failure = new ProvisioningError(`Failed to delete IAM policy ${logicalId}: ${mask(error instanceof Error ? error.message : String(error))}`, resourceType, logicalId, physicalId, cause);
511
+ throw maskError(removedAny ? markDeleteStarted(failure) : failure);
509
512
  }
510
513
  }
511
514
  async readCurrentState(physicalId, _logicalId, _resourceType, properties) {
@@ -772,6 +775,7 @@ var IAMManagedPolicyProvider = class {
772
775
  async delete(logicalId, physicalId, resourceType, _properties, context) {
773
776
  const mask = maskerOrIdentity(context?.maskSecrets);
774
777
  this.logger.debug(mask(`Deleting IAM managed policy ${logicalId}: ${physicalId}`));
778
+ const progress = { stripped: false };
775
779
  try {
776
780
  try {
777
781
  await this.iamClient.send(new GetPolicyCommand({ PolicyArn: physicalId }));
@@ -782,7 +786,7 @@ var IAMManagedPolicyProvider = class {
782
786
  }
783
787
  throw error;
784
788
  }
785
- await this.detachAllPrincipals(physicalId);
789
+ await this.detachAllPrincipals(physicalId, progress);
786
790
  await this.deleteAllNonDefaultVersions(physicalId);
787
791
  await this.iamClient.send(new DeletePolicyCommand({ PolicyArn: physicalId }));
788
792
  this.logger.debug(`Successfully deleted IAM managed policy ${logicalId}`);
@@ -792,7 +796,8 @@ var IAMManagedPolicyProvider = class {
792
796
  return;
793
797
  }
794
798
  const cause = error instanceof Error ? error : void 0;
795
- throw this.wrapMaskedError(mask, error, (text) => new ProvisioningError(`Failed to delete IAM managed policy ${logicalId}: ${text}`, resourceType, logicalId, physicalId, cause));
799
+ const failure = this.wrapMaskedError(mask, error, (text) => new ProvisioningError(`Failed to delete IAM managed policy ${logicalId}: ${text}`, resourceType, logicalId, physicalId, cause));
800
+ throw progress.stripped ? markDeleteStarted(failure) : failure;
796
801
  }
797
802
  }
798
803
  async goneOnDelete(logicalId, physicalId, resourceType, context, mask) {
@@ -1035,7 +1040,7 @@ var IAMManagedPolicyProvider = class {
1035
1040
  } while (marker);
1036
1041
  return live;
1037
1042
  }
1038
- async detachAllPrincipals(policyArn) {
1043
+ async detachAllPrincipals(policyArn, progress) {
1039
1044
  try {
1040
1045
  let marker;
1041
1046
  while (true) {
@@ -1050,6 +1055,7 @@ var IAMManagedPolicyProvider = class {
1050
1055
  GroupName: g.GroupName,
1051
1056
  PolicyArn: policyArn
1052
1057
  }));
1058
+ if (progress) progress.stripped = true;
1053
1059
  } catch (err) {
1054
1060
  if (!(err instanceof NoSuchEntityException)) throw err;
1055
1061
  }
@@ -1061,6 +1067,7 @@ var IAMManagedPolicyProvider = class {
1061
1067
  RoleName: r.RoleName,
1062
1068
  PolicyArn: policyArn
1063
1069
  }));
1070
+ if (progress) progress.stripped = true;
1064
1071
  } catch (err) {
1065
1072
  if (!(err instanceof NoSuchEntityException)) throw err;
1066
1073
  }
@@ -1072,6 +1079,7 @@ var IAMManagedPolicyProvider = class {
1072
1079
  UserName: u.UserName,
1073
1080
  PolicyArn: policyArn
1074
1081
  }));
1082
+ if (progress) progress.stripped = true;
1075
1083
  } catch (err) {
1076
1084
  if (!(err instanceof NoSuchEntityException)) throw err;
1077
1085
  }
@@ -1317,6 +1325,7 @@ var IAMInstanceProfileProvider = class {
1317
1325
  }
1318
1326
  async delete(logicalId, physicalId, resourceType, _properties, context) {
1319
1327
  this.logger.debug(`Deleting IAM instance profile ${logicalId}: ${physicalId}`);
1328
+ let stripped = false;
1320
1329
  try {
1321
1330
  let roles = [];
1322
1331
  try {
@@ -1335,6 +1344,7 @@ var IAMInstanceProfileProvider = class {
1335
1344
  InstanceProfileName: physicalId,
1336
1345
  RoleName: roleName
1337
1346
  }));
1347
+ stripped = true;
1338
1348
  this.logger.debug(`Removed role ${roleName} from instance profile ${physicalId}`);
1339
1349
  } catch (error) {
1340
1350
  if (!(error instanceof NoSuchEntityException)) throw error;
@@ -1349,7 +1359,8 @@ var IAMInstanceProfileProvider = class {
1349
1359
  return;
1350
1360
  }
1351
1361
  const cause = error instanceof Error ? error : void 0;
1352
- throw new ProvisioningError(`Failed to delete IAM instance profile ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
1362
+ const failure = new ProvisioningError(`Failed to delete IAM instance profile ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
1363
+ throw stripped ? markDeleteStarted(failure) : failure;
1353
1364
  }
1354
1365
  }
1355
1366
  logGoneOnDelete(logicalId, physicalId, context) {
@@ -1513,7 +1524,10 @@ var IAMAccessKeyProvider = class {
1513
1524
  if (leftBehindKeyId !== void 0 && reconciled.has(leftBehindKeyId)) leftBehindKeyId = void 0;
1514
1525
  const cause = error instanceof Error ? error : void 0;
1515
1526
  const thrown = this.wrapMaskedError(log.mask, error, (text) => new ProvisioningError(`Failed to create IAM access key ${logicalId}: ${text}`, resourceType, logicalId, void 0, cause));
1516
- if (leftBehindKeyId !== void 0) markCreatedBeforeFailure(thrown, logicalId, resourceType, leftBehindKeyId);
1527
+ if (leftBehindKeyId !== void 0) {
1528
+ markCreatedBeforeFailure(thrown, logicalId, resourceType, leftBehindKeyId);
1529
+ markNonRetryable(thrown);
1530
+ }
1517
1531
  throw thrown;
1518
1532
  }
1519
1533
  }
@@ -1999,9 +2013,11 @@ var IAMUserGroupProvider = class {
1999
2013
  const log = createMaskedLogSinks(this.logger, context?.maskSecrets);
2000
2014
  const { value: v } = log;
2001
2015
  log.debug(`Deleting IAM user ${logicalId}: ${v(physicalId)}`);
2016
+ const progress = { stripped: false };
2017
+ let hadBoundary = false;
2002
2018
  try {
2003
2019
  try {
2004
- await this.iamClient.send(new GetUserCommand({ UserName: physicalId }));
2020
+ hadBoundary = (await this.iamClient.send(new GetUserCommand({ UserName: physicalId }))).User?.PermissionsBoundary !== void 0;
2005
2021
  } catch (error) {
2006
2022
  if (error instanceof NoSuchEntityException) {
2007
2023
  const clientRegion = await this.iamClient.config.region();
@@ -2012,18 +2028,20 @@ var IAMUserGroupProvider = class {
2012
2028
  }
2013
2029
  throw error;
2014
2030
  }
2015
- await this.removeUserFromAllGroups(physicalId, log);
2016
- await this.detachAllUserPolicies(physicalId, log);
2017
- await this.deleteAllUserInlinePolicies(physicalId, log);
2031
+ await this.removeUserFromAllGroups(physicalId, log, progress);
2032
+ await this.detachAllUserPolicies(physicalId, log, progress);
2033
+ await this.deleteAllUserInlinePolicies(physicalId, log, progress);
2018
2034
  try {
2019
2035
  await this.iamClient.send(new DeleteLoginProfileCommand({ UserName: physicalId }));
2036
+ progress.stripped = true;
2020
2037
  log.debug(`Deleted login profile for user ${v(physicalId)}`);
2021
2038
  } catch (error) {
2022
2039
  if (!(error instanceof NoSuchEntityException)) throw error;
2023
2040
  }
2024
- await this.deleteAllAccessKeys(physicalId, log);
2041
+ await this.deleteAllAccessKeys(physicalId, log, progress);
2025
2042
  try {
2026
2043
  await this.iamClient.send(new DeleteUserPermissionsBoundaryCommand({ UserName: physicalId }));
2044
+ if (hadBoundary) progress.stripped = true;
2027
2045
  } catch (error) {
2028
2046
  if (!(error instanceof NoSuchEntityException)) throw error;
2029
2047
  }
@@ -2031,7 +2049,8 @@ var IAMUserGroupProvider = class {
2031
2049
  log.debug(`Successfully deleted IAM user ${logicalId}`);
2032
2050
  } catch (error) {
2033
2051
  const cause = error instanceof Error ? error : void 0;
2034
- throw new ProvisioningError(log.mask(`Failed to delete IAM user ${logicalId}: ${error instanceof Error ? error.message : String(error)}`), resourceType, logicalId, physicalId, cause);
2052
+ const failure = new ProvisioningError(log.mask(`Failed to delete IAM user ${logicalId}: ${error instanceof Error ? error.message : String(error)}`), resourceType, logicalId, physicalId, cause);
2053
+ throw progress.stripped ? markDeleteStarted(failure) : failure;
2035
2054
  }
2036
2055
  }
2037
2056
  async readLiveGroups(userName) {
@@ -2047,7 +2066,7 @@ var IAMUserGroupProvider = class {
2047
2066
  } while (marker);
2048
2067
  return groups;
2049
2068
  }
2050
- async removeUserFromAllGroups(userName, log) {
2069
+ async removeUserFromAllGroups(userName, log, progress) {
2051
2070
  const { value: v } = log;
2052
2071
  try {
2053
2072
  const groups = (await this.iamClient.send(new ListGroupsForUserCommand({ UserName: userName }))).Groups || [];
@@ -2056,6 +2075,7 @@ var IAMUserGroupProvider = class {
2056
2075
  UserName: userName,
2057
2076
  GroupName: group.GroupName
2058
2077
  }));
2078
+ if (progress) progress.stripped = true;
2059
2079
  log.debug(`Removed user ${v(userName)} from group ${v(group.GroupName)}`);
2060
2080
  } catch (error) {
2061
2081
  if (!(error instanceof NoSuchEntityException)) throw error;
@@ -2065,7 +2085,7 @@ var IAMUserGroupProvider = class {
2065
2085
  throw error;
2066
2086
  }
2067
2087
  }
2068
- async deleteAllAccessKeys(userName, log) {
2088
+ async deleteAllAccessKeys(userName, log, progress) {
2069
2089
  const { value: v } = log;
2070
2090
  try {
2071
2091
  const keys = (await this.iamClient.send(new ListAccessKeysCommand({ UserName: userName }))).AccessKeyMetadata || [];
@@ -2074,6 +2094,7 @@ var IAMUserGroupProvider = class {
2074
2094
  UserName: userName,
2075
2095
  AccessKeyId: key.AccessKeyId
2076
2096
  }));
2097
+ if (progress) progress.stripped = true;
2077
2098
  log.debug(`Deleted access key ${key.AccessKeyId} for user ${v(userName)}`);
2078
2099
  }
2079
2100
  } catch (error) {
@@ -2081,7 +2102,7 @@ var IAMUserGroupProvider = class {
2081
2102
  throw error;
2082
2103
  }
2083
2104
  }
2084
- async detachAllUserPolicies(userName, log) {
2105
+ async detachAllUserPolicies(userName, log, progress) {
2085
2106
  const { value: v } = log;
2086
2107
  try {
2087
2108
  const policies = (await this.iamClient.send(new ListAttachedUserPoliciesCommand({ UserName: userName }))).AttachedPolicies || [];
@@ -2090,6 +2111,7 @@ var IAMUserGroupProvider = class {
2090
2111
  UserName: userName,
2091
2112
  PolicyArn: policy.PolicyArn
2092
2113
  }));
2114
+ if (progress) progress.stripped = true;
2093
2115
  log.debug(`Detached managed policy ${v(policy.PolicyArn)} from user ${v(userName)}`);
2094
2116
  } catch (error) {
2095
2117
  if (!(error instanceof NoSuchEntityException)) throw error;
@@ -2099,7 +2121,7 @@ var IAMUserGroupProvider = class {
2099
2121
  throw error;
2100
2122
  }
2101
2123
  }
2102
- async deleteAllUserInlinePolicies(userName, log) {
2124
+ async deleteAllUserInlinePolicies(userName, log, progress) {
2103
2125
  const { value: v } = log;
2104
2126
  try {
2105
2127
  const policyNames = (await this.iamClient.send(new ListUserPoliciesCommand({ UserName: userName }))).PolicyNames || [];
@@ -2108,6 +2130,7 @@ var IAMUserGroupProvider = class {
2108
2130
  UserName: userName,
2109
2131
  PolicyName: policyName
2110
2132
  }));
2133
+ if (progress) progress.stripped = true;
2111
2134
  log.debug(`Deleted inline policy ${v(policyName)} from user ${v(userName)}`);
2112
2135
  } catch (error) {
2113
2136
  if (!(error instanceof NoSuchEntityException)) throw error;
@@ -2291,10 +2314,11 @@ var IAMUserGroupProvider = class {
2291
2314
  const log = createMaskedLogSinks(this.logger, context?.maskSecrets);
2292
2315
  const { value: v } = log;
2293
2316
  log.debug(`Deleting IAM group ${logicalId}: ${v(physicalId)}`);
2317
+ const progress = { stripped: false };
2294
2318
  try {
2295
- await this.detachAllGroupPolicies(physicalId, log);
2296
- await this.deleteAllGroupInlinePolicies(physicalId, log);
2297
- await this.removeAllUsersFromGroup(physicalId, log);
2319
+ await this.detachAllGroupPolicies(physicalId, log, progress);
2320
+ await this.deleteAllGroupInlinePolicies(physicalId, log, progress);
2321
+ await this.removeAllUsersFromGroup(physicalId, log, progress);
2298
2322
  await this.iamClient.send(new DeleteGroupCommand({ GroupName: physicalId }));
2299
2323
  log.debug(`Successfully deleted IAM group ${logicalId}`);
2300
2324
  } catch (error) {
@@ -2306,10 +2330,11 @@ var IAMUserGroupProvider = class {
2306
2330
  return;
2307
2331
  }
2308
2332
  const cause = error instanceof Error ? error : void 0;
2309
- throw new ProvisioningError(log.mask(`Failed to delete IAM group ${logicalId}: ${error instanceof Error ? error.message : String(error)}`), resourceType, logicalId, physicalId, cause);
2333
+ const failure = new ProvisioningError(log.mask(`Failed to delete IAM group ${logicalId}: ${error instanceof Error ? error.message : String(error)}`), resourceType, logicalId, physicalId, cause);
2334
+ throw progress.stripped ? markDeleteStarted(failure) : failure;
2310
2335
  }
2311
2336
  }
2312
- async detachAllGroupPolicies(groupName, log) {
2337
+ async detachAllGroupPolicies(groupName, log, progress) {
2313
2338
  const { value: v } = log;
2314
2339
  try {
2315
2340
  const policies = (await this.iamClient.send(new ListAttachedGroupPoliciesCommand({ GroupName: groupName }))).AttachedPolicies || [];
@@ -2318,6 +2343,7 @@ var IAMUserGroupProvider = class {
2318
2343
  GroupName: groupName,
2319
2344
  PolicyArn: policy.PolicyArn
2320
2345
  }));
2346
+ if (progress) progress.stripped = true;
2321
2347
  log.debug(`Detached managed policy ${v(policy.PolicyArn)} from group ${v(groupName)}`);
2322
2348
  } catch (error) {
2323
2349
  if (!(error instanceof NoSuchEntityException)) throw error;
@@ -2327,7 +2353,7 @@ var IAMUserGroupProvider = class {
2327
2353
  throw error;
2328
2354
  }
2329
2355
  }
2330
- async removeAllUsersFromGroup(groupName, log) {
2356
+ async removeAllUsersFromGroup(groupName, log, progress) {
2331
2357
  const { value: v } = log;
2332
2358
  try {
2333
2359
  const users = (await this.iamClient.send(new GetGroupCommand({ GroupName: groupName }))).Users || [];
@@ -2336,6 +2362,7 @@ var IAMUserGroupProvider = class {
2336
2362
  GroupName: groupName,
2337
2363
  UserName: user.UserName
2338
2364
  }));
2365
+ if (progress) progress.stripped = true;
2339
2366
  log.debug(`Removed user ${v(user.UserName)} from group ${v(groupName)}`);
2340
2367
  } catch (error) {
2341
2368
  if (!(error instanceof NoSuchEntityException)) throw error;
@@ -2364,7 +2391,7 @@ var IAMUserGroupProvider = class {
2364
2391
  log.debug(`Detached managed policy ${v(policyArn)} from group ${v(groupName)}`);
2365
2392
  }
2366
2393
  }
2367
- async deleteAllGroupInlinePolicies(groupName, log) {
2394
+ async deleteAllGroupInlinePolicies(groupName, log, progress) {
2368
2395
  const { value: v } = log;
2369
2396
  try {
2370
2397
  const policyNames = (await this.iamClient.send(new ListGroupPoliciesCommand({ GroupName: groupName }))).PolicyNames || [];
@@ -2373,6 +2400,7 @@ var IAMUserGroupProvider = class {
2373
2400
  GroupName: groupName,
2374
2401
  PolicyName: policyName
2375
2402
  }));
2403
+ if (progress) progress.stripped = true;
2376
2404
  log.debug(`Deleted inline policy ${v(policyName)} from group ${v(groupName)}`);
2377
2405
  } catch (error) {
2378
2406
  if (!(error instanceof NoSuchEntityException)) throw error;
@@ -2546,6 +2574,7 @@ var IAMUserGroupProvider = class {
2546
2574
  };
2547
2575
  }
2548
2576
  let secretUserNotMember = false;
2577
+ let removedAny = false;
2549
2578
  try {
2550
2579
  for (const userName of users ?? []) {
2551
2580
  if (resolvedNames.has(userName) && memo?.detached.has(injectiveKey("Users", userName)) !== true) {
@@ -2567,6 +2596,7 @@ var IAMUserGroupProvider = class {
2567
2596
  GroupName: groupName,
2568
2597
  UserName: userName
2569
2598
  }));
2599
+ removedAny = true;
2570
2600
  if (resolvedNames.has(userName)) memo?.detached.add(injectiveKey("Users", userName));
2571
2601
  this.logger.debug(`Removed user ${mask(userName)} from group ${groupName}`);
2572
2602
  } catch (error) {
@@ -2584,7 +2614,8 @@ var IAMUserGroupProvider = class {
2584
2614
  this.logger.debug(`Successfully deleted IAM UserToGroupAddition ${logicalId}`);
2585
2615
  } catch (error) {
2586
2616
  const cause = error instanceof Error ? error : void 0;
2587
- throw maskError(new ProvisioningError(`Failed to delete IAM UserToGroupAddition ${logicalId}: ${mask(error instanceof Error ? error.message : String(error))}`, resourceType, logicalId, physicalId, cause));
2617
+ const failure = new ProvisioningError(`Failed to delete IAM UserToGroupAddition ${logicalId}: ${mask(error instanceof Error ? error.message : String(error))}`, resourceType, logicalId, physicalId, cause);
2618
+ throw maskError(removedAny ? markDeleteStarted(failure) : failure);
2588
2619
  }
2589
2620
  }
2590
2621
  async isSameResource(journaledPhysicalId, record, resourceType, context) {
@@ -3228,6 +3259,8 @@ function isPlainBucketName(value) {
3228
3259
  const BUCKET_LIST_IDENTITY_ATTEMPTS = 3;
3229
3260
  const BUCKET_LIST_IDENTITY_DELAY_MS = 1500;
3230
3261
  const BUCKET_LIST_IDENTITY_BUDGET_MS = 6e3;
3262
+ const OWN_WRITE_HEAD_ATTEMPTS = 5;
3263
+ const OWN_WRITE_HEAD_DELAY_MS = 500;
3231
3264
  function isNoSuchBucketError(error) {
3232
3265
  return error?.name === "NoSuchBucket";
3233
3266
  }
@@ -3293,6 +3326,15 @@ function takeOwnLeftoverBucket(logicalId) {
3293
3326
  ownLeftoverBuckets.delete(key);
3294
3327
  return held !== void 0 && Date.now() - held.heldAtMs <= 18e5 ? held.identity : void 0;
3295
3328
  }
3329
+ function isCreateTagResourceDenial(error) {
3330
+ return error instanceof Error && error.name === "AccessDenied" && describeAwsFailure(error).detail.includes("s3:TagResource");
3331
+ }
3332
+ function isCreateTagsShapeRefusal(error) {
3333
+ if (!(error instanceof Error)) return false;
3334
+ if (error.name === "MalformedXML" || error.name === "NotImplemented") return true;
3335
+ return (error.name === "InvalidArgument" || error.name === "InvalidRequest") && /\btags?\b/i.test(describeAwsFailure(error).detail);
3336
+ }
3337
+ const untaggedExplicitDeny = /* @__PURE__ */ new WeakMap();
3296
3338
  var S3BucketProvider = class S3BucketProvider {
3297
3339
  s3Client;
3298
3340
  createClientHolder = {};
@@ -4572,6 +4614,11 @@ var S3BucketProvider = class S3BucketProvider {
4572
4614
  const canonicalRegion = canonicalizeRegion(region);
4573
4615
  if (canonicalRegion !== "us-east-1") createParams.CreateBucketConfiguration = { LocationConstraint: canonicalRegion };
4574
4616
  if (declaresBucketObjectLock(properties)) createParams.ObjectLockEnabledForBucket = true;
4617
+ if (desiredTags.length > 0) createParams.CreateBucketConfiguration = {
4618
+ ...createParams.CreateBucketConfiguration,
4619
+ Tags: desiredTags
4620
+ };
4621
+ let tagsAppliedOnCreate = false;
4575
4622
  const preflight = canonicalizeRegion(region) === "us-east-1" ? await this.probeBucketRegion(bucketName) : { kind: "absent" };
4576
4623
  let createdNewBucket = false;
4577
4624
  const createClient = await this.getCreateClient();
@@ -4597,11 +4644,40 @@ var S3BucketProvider = class S3BucketProvider {
4597
4644
  }
4598
4645
  try {
4599
4646
  const attemptStartMs = Date.now();
4600
- if (!adoptedOwnLeftover) try {
4601
- await createClient.send(new CreateBucketCommand(createParams));
4602
- } catch (sendError) {
4603
- createBucketLatch.noteFailure(logicalId, sendError, attemptStartMs, ambiguousWindow);
4604
- throw sendError;
4647
+ if (!adoptedOwnLeftover) {
4648
+ let tagsSent = createParams.CreateBucketConfiguration?.Tags !== void 0;
4649
+ try {
4650
+ try {
4651
+ await createClient.send(new CreateBucketCommand(createParams));
4652
+ } catch (taggedError) {
4653
+ const tagResourceDenied = isCreateTagResourceDenial(taggedError);
4654
+ if (!tagsSent || !(tagResourceDenied || isCreateTagsShapeRefusal(taggedError))) throw taggedError;
4655
+ this.logger.debug(safeMsg`CreateBucket with tags was ${tagResourceDenied ? "denied s3:TagResource" : "refused for its Tags member"} for ${displaySafe(logicalId)}; ` + `retrying without tags and applying them with PutBucketTagging`);
4656
+ const { Tags: _omitted, ...rest } = createParams.CreateBucketConfiguration ?? {};
4657
+ const untagged = { ...createParams };
4658
+ if (Object.keys(rest).length > 0) untagged.CreateBucketConfiguration = rest;
4659
+ else delete untagged.CreateBucketConfiguration;
4660
+ tagsSent = false;
4661
+ try {
4662
+ await createClient.send(new CreateBucketCommand(untagged));
4663
+ } catch (untaggedError) {
4664
+ if (tagResourceDenied && untaggedError instanceof Error && untaggedError.name === "AccessDenied") {
4665
+ this.logger.debug(safeMsg`CreateBucket without tags was denied too for ${displaySafe(logicalId)}; ` + `reporting the s3:TagResource denial`);
4666
+ const untaggedText = describeAwsFailure(untaggedError).detail;
4667
+ if (isExplicitDenyError(untaggedText) && taggedError instanceof Error) {
4668
+ untaggedExplicitDeny.set(taggedError, explicitDenyPolicyKind(untaggedText) ?? null);
4669
+ markNonRetryable(taggedError);
4670
+ }
4671
+ throw taggedError;
4672
+ }
4673
+ throw untaggedError;
4674
+ }
4675
+ }
4676
+ } catch (sendError) {
4677
+ createBucketLatch.noteFailure(logicalId, sendError, attemptStartMs, ambiguousWindow);
4678
+ throw sendError;
4679
+ }
4680
+ tagsAppliedOnCreate = tagsSent && preflight.kind === "absent";
4605
4681
  }
4606
4682
  createdNewBucket = adoptedOwnLeftover || preflight.kind === "absent";
4607
4683
  bucketLeftBehind = createdNewBucket;
@@ -4627,7 +4703,7 @@ var S3BucketProvider = class S3BucketProvider {
4627
4703
  try {
4628
4704
  effectiveOverrides = await this.applyConfiguration(bucketName, properties, {
4629
4705
  ...context ? { context } : {},
4630
- desiredTags
4706
+ ...tagsAppliedOnCreate ? { skipTags: true } : { desiredTags }
4631
4707
  });
4632
4708
  for (const [key, value] of await this.applyAllSubConfigsForCreate(bucketName, properties, context)) effectiveOverrides.set(key, value);
4633
4709
  } catch (innerError) {
@@ -4734,7 +4810,12 @@ var S3BucketProvider = class S3BucketProvider {
4734
4810
  wrapOperationError(operation, logicalId, resourceType, physicalId, error) {
4735
4811
  const failure = describeAwsFailure(error);
4736
4812
  if (failure.redacted) this.logger.debug(`Failed to ${operation} S3 bucket ${displaySafe(logicalId)} (${this.shown(physicalId)}): ${this.maskRaw(failure.detail)}`);
4737
- const wrapped = new ProvisioningError(`Failed to ${operation} S3 bucket ${displaySafe(logicalId)}: ${this.maskRaw(failure.summary)}`, resourceType, logicalId, physicalId, error instanceof Error ? error : void 0);
4813
+ const denyKind = failure.redacted ? explicitDenyPolicyKind(failure.detail) : void 0;
4814
+ const denyNote = failure.redacted && isExplicitDenyError(failure.detail) ? ` Refused by an explicit deny${denyKind !== void 0 ? ` (${denyKind})` : ""}, which retrying cannot clear.` : "";
4815
+ const tagResourceNote = failure.redacted && isCreateTagResourceDenial(error) ? " Creating a bucket with tags needs s3:TagResource." : "";
4816
+ const untaggedDenyKind = error instanceof Error ? untaggedExplicitDeny.get(error) : void 0;
4817
+ const untaggedDenyNote = untaggedDenyKind !== void 0 ? ` The untagged retry was refused by an explicit deny${untaggedDenyKind !== null ? ` (${untaggedDenyKind})` : ""}, which retrying cannot clear.` : "";
4818
+ const wrapped = new ProvisioningError(`Failed to ${operation} S3 bucket ${displaySafe(logicalId)}: ${this.maskRaw(failure.summary)}${denyNote}${tagResourceNote}${untaggedDenyNote}`, resourceType, logicalId, physicalId, error instanceof Error ? error : void 0);
4738
4819
  return failure.redacted ? markRedactedCause(wrapped) : wrapped;
4739
4820
  }
4740
4821
  canonicalizeDesiredProperties(resourceType, properties) {
@@ -4746,12 +4827,20 @@ var S3BucketProvider = class S3BucketProvider {
4746
4827
  out = canonicalizeBlock(out, "LifecycleConfiguration", effectiveLifecycleConfiguration);
4747
4828
  return out;
4748
4829
  }
4749
- async readCurrentState(physicalId, _logicalId, _resourceType) {
4750
- try {
4830
+ async readCurrentState(physicalId, _logicalId, _resourceType, _properties, context) {
4831
+ const headAttempts = context?.afterOwnWrite === true ? OWN_WRITE_HEAD_ATTEMPTS : 1;
4832
+ for (let attempt = 1;; attempt++) try {
4751
4833
  await this.s3Client.send(new HeadBucketCommand({ Bucket: physicalId }));
4834
+ break;
4752
4835
  } catch (err) {
4753
4836
  const e = err;
4754
- if (err instanceof NoSuchBucket || e.name === "NotFound" || e.name === "NoSuchBucket" || e.$metadata?.httpStatusCode === 404) return RESOURCE_NOT_FOUND;
4837
+ if (err instanceof NoSuchBucket || e.name === "NotFound" || e.name === "NoSuchBucket" || e.$metadata?.httpStatusCode === 404) {
4838
+ if (attempt < headAttempts) {
4839
+ await new Promise((r) => setTimeout(r, OWN_WRITE_HEAD_DELAY_MS));
4840
+ continue;
4841
+ }
4842
+ return RESOURCE_NOT_FOUND;
4843
+ }
4755
4844
  throw err;
4756
4845
  }
4757
4846
  const [versioning, encryption, ownership, pab, tags, lifecycle, cors, website, logging, notification, replication, objectLock, accelerate, metrics, analytics, intelligentTier, inventory] = await Promise.all([
@@ -6136,11 +6225,13 @@ var SQSQueuePolicyProvider = class {
6136
6225
  const named = physicalId.includes(",") ? splitQueueUrls(physicalId) : recordedQueues(physicalId, context?.recordedAttributes);
6137
6226
  const queueUrls = [...physicalId.includes(",") ? [] : await this.queuesCarryingDocument(listedQueues(properties ?? {}).filter((url) => !named.includes(url)), properties?.["PolicyDocument"], logicalId), ...named];
6138
6227
  if (queueUrls.length === 0) throw new ProvisioningError(`Failed to delete SQS queue policy ${logicalId}: its physical id names no queue URL`, resourceType, logicalId, physicalId);
6228
+ let clearedAny = false;
6139
6229
  for (const queueUrl of queueUrls) try {
6140
6230
  await this.clearQueuePolicy(queueUrl, resourceType, logicalId, context?.expectedRegion);
6231
+ clearedAny = true;
6141
6232
  } catch (error) {
6142
- if (error instanceof ProvisioningError) throw error;
6143
- throw this.wrapOperationError("delete", logicalId, resourceType, physicalId, error, context?.maskSecrets);
6233
+ const failure = error instanceof ProvisioningError ? error : this.wrapOperationError("delete", logicalId, resourceType, physicalId, error, context?.maskSecrets);
6234
+ throw clearedAny ? markDeleteStarted(failure) : failure;
6144
6235
  }
6145
6236
  this.logger.debug(`Successfully deleted SQS queue policy ${logicalId}`);
6146
6237
  }
@@ -7251,11 +7342,13 @@ var SNSTopicPolicyProvider = class {
7251
7342
  if (named.length === 0) throw markNonRetryable(new ProvisioningError(`Failed to delete SNS topic policy ${logicalId}: its physical id is empty, so cdkd changed no topic. Set each topic the policy is attached to back to its default policy by hand, then drop the record with ${stateOrphanRecordRemedy(context, logicalId)}.`, resourceType, logicalId, physicalId));
7252
7343
  const topicArns = named.every((arn) => isSnsTopicArn(arn)) ? named : [.../* @__PURE__ */ new Set([...named.filter((arn) => isSnsTopicArn(arn)), ...listedTopics(properties ?? {})])];
7253
7344
  if (topicArns.length === 0) throw markNonRetryable(new ProvisioningError(`Failed to delete SNS topic policy ${logicalId}: its physical id names no SNS topic ARN and its Topics lists none either, so cdkd changed no topic. Set each topic the policy is attached to back to its default policy by hand, then drop the record with ${stateOrphanRecordRemedy(context, logicalId)}.`, resourceType, logicalId, physicalId));
7345
+ let clearedAny = false;
7254
7346
  for (const topicArn of topicArns) try {
7255
7347
  await this.resetTopicPolicy(topicArn, resourceType, logicalId, context?.expectedRegion);
7348
+ clearedAny = true;
7256
7349
  } catch (error) {
7257
- if (error instanceof ProvisioningError) throw error;
7258
- throw this.wrapOperationError("delete", logicalId, resourceType, physicalId, error, context?.maskSecrets);
7350
+ const failure = error instanceof ProvisioningError ? error : this.wrapOperationError("delete", logicalId, resourceType, physicalId, error, context?.maskSecrets);
7351
+ throw clearedAny ? markDeleteStarted(failure) : failure;
7259
7352
  }
7260
7353
  this.logger.debug(`Successfully deleted SNS topic policy ${logicalId}`);
7261
7354
  }
@@ -8038,8 +8131,10 @@ var LambdaFunctionProvider = class {
8038
8131
  async delete(logicalId, physicalId, resourceType, properties, context) {
8039
8132
  this.logger.debug(`Deleting Lambda function ${logicalId}: ${physicalId}`);
8040
8133
  const hasVpcConfig = this.hasVpcConfig(properties?.["VpcConfig"]);
8134
+ let stripped = false;
8041
8135
  if (hasVpcConfig) {
8042
8136
  try {
8137
+ stripped = true;
8043
8138
  await this.lambdaClient.send(new UpdateFunctionConfigurationCommand({
8044
8139
  FunctionName: physicalId,
8045
8140
  VpcConfig: {
@@ -8055,6 +8150,7 @@ var LambdaFunctionProvider = class {
8055
8150
  this.logFunctionGone(logicalId, physicalId, context);
8056
8151
  return;
8057
8152
  }
8153
+ if (isRefusedByName(error)) stripped = false;
8058
8154
  this.logger.warn(`Pre-delete VPC detach failed for ${physicalId}: ${describeAwsFailure(error).detail} — continuing with delete`);
8059
8155
  }
8060
8156
  await this.waitForLambdaUpdateCompleted(physicalId);
@@ -8070,7 +8166,8 @@ var LambdaFunctionProvider = class {
8070
8166
  return;
8071
8167
  }
8072
8168
  const cause = error instanceof Error ? error : void 0;
8073
- throw new ProvisioningError(`Failed to delete Lambda function ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
8169
+ const failure = new ProvisioningError(`Failed to delete Lambda function ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
8170
+ throw stripped ? markDeleteStarted(failure) : failure;
8074
8171
  }
8075
8172
  if (hasVpcConfig) await this.cleanupLambdaEnis(physicalId);
8076
8173
  }
@@ -10270,7 +10367,17 @@ var LambdaWebFunctionRevisionProvider = class {
10270
10367
  };
10271
10368
  } catch (error) {
10272
10369
  const thrown = this.wrapError("create", logicalId, resourceType, void 0, error);
10273
- if (createdArn) markCreatedBeforeFailure(thrown, logicalId, resourceType, createdArn);
10370
+ let leftBehindArn = createdArn;
10371
+ if (leftBehindArn) try {
10372
+ await this.delete(logicalId, leftBehindArn, resourceType);
10373
+ leftBehindArn = void 0;
10374
+ } catch (cleanupError) {
10375
+ log.warn(safeMsg`Failed to delete partially-created Lambda web function revision ${logicalId}: ${describeAwsFailure(cleanupError).detail}. The failed deploy records it for \`cdkd rollback --revert-failed\`, or delete it by hand`);
10376
+ }
10377
+ if (leftBehindArn) {
10378
+ markCreatedBeforeFailure(thrown, logicalId, resourceType, leftBehindArn);
10379
+ markNonRetryable(thrown);
10380
+ }
10274
10381
  throw thrown;
10275
10382
  }
10276
10383
  }
@@ -15080,6 +15187,7 @@ var EventBridgeRuleProvider = class {
15080
15187
  this.logger.debug(`Deleting EventBridge rule ${logicalId}: ${physicalId}`);
15081
15188
  const ruleName = this.extractRuleNameFromArn(physicalId);
15082
15189
  const busParam = this.busParamFromArn(physicalId);
15190
+ let stripped = false;
15083
15191
  try {
15084
15192
  let targetIds = [];
15085
15193
  try {
@@ -15102,6 +15210,7 @@ var EventBridgeRuleProvider = class {
15102
15210
  Ids: targetIds,
15103
15211
  ...busParam
15104
15212
  }));
15213
+ stripped = true;
15105
15214
  this.logger.debug(`Removed ${targetIds.length} targets from rule ${ruleName}`);
15106
15215
  }
15107
15216
  await this.eventBridgeClient.send(new DeleteRuleCommand({
@@ -15117,7 +15226,8 @@ var EventBridgeRuleProvider = class {
15117
15226
  return;
15118
15227
  }
15119
15228
  const cause = error instanceof Error ? error : void 0;
15120
- throw new ProvisioningError(`Failed to delete EventBridge rule ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
15229
+ const failure = new ProvisioningError(`Failed to delete EventBridge rule ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
15230
+ throw stripped ? markDeleteStarted(failure) : failure;
15121
15231
  }
15122
15232
  }
15123
15233
  async getAttribute(physicalId, _resourceType, attributeName) {
@@ -15383,8 +15493,9 @@ var EventBridgeBusProvider = class {
15383
15493
  }
15384
15494
  async delete(logicalId, physicalId, resourceType, _properties, context) {
15385
15495
  this.logger.debug(`Deleting EventBus ${logicalId}: ${physicalId}`);
15496
+ let stripped = false;
15386
15497
  try {
15387
- await this.cleanupRulesOnBus(physicalId);
15498
+ stripped = await this.cleanupRulesOnBus(physicalId);
15388
15499
  await this.eventBridgeClient.send(new DeleteEventBusCommand({ Name: physicalId }));
15389
15500
  this.logger.debug(`Successfully deleted EventBus ${logicalId}`);
15390
15501
  } catch (error) {
@@ -15402,7 +15513,8 @@ var EventBridgeBusProvider = class {
15402
15513
  return;
15403
15514
  }
15404
15515
  const cause = error instanceof Error ? error : void 0;
15405
- throw new ProvisioningError(`Failed to delete EventBus ${logicalId}: ${msg}`, resourceType, logicalId, physicalId, cause);
15516
+ const failure = new ProvisioningError(`Failed to delete EventBus ${logicalId}: ${msg}`, resourceType, logicalId, physicalId, cause);
15517
+ throw stripped ? markDeleteStarted(failure) : failure;
15406
15518
  }
15407
15519
  }
15408
15520
  getAttribute(physicalId, _resourceType, attributeName) {
@@ -15411,9 +15523,11 @@ var EventBridgeBusProvider = class {
15411
15523
  return Promise.resolve(void 0);
15412
15524
  }
15413
15525
  async cleanupRulesOnBus(busName) {
15526
+ let found = false;
15414
15527
  try {
15415
15528
  const rules = (await this.eventBridgeClient.send(new ListRulesCommand({ EventBusName: busName }))).Rules ?? [];
15416
- if (rules.length === 0) return;
15529
+ if (rules.length === 0) return false;
15530
+ found = true;
15417
15531
  this.logger.debug(`Cleaning up ${rules.length} rule(s) on bus ${busName}`);
15418
15532
  for (const rule of rules) {
15419
15533
  if (!rule.Name) continue;
@@ -15436,9 +15550,10 @@ var EventBridgeBusProvider = class {
15436
15550
  } catch {}
15437
15551
  }
15438
15552
  } catch (error) {
15439
- if (error instanceof ResourceNotFoundException$2) return;
15553
+ if (error instanceof ResourceNotFoundException$2) return found;
15440
15554
  this.logger.debug(`Failed to list rules on bus ${busName}: ${describeAwsFailure(error).detail}`);
15441
15555
  }
15556
+ return found;
15442
15557
  }
15443
15558
  async readCurrentState(physicalId, _logicalId, _resourceType) {
15444
15559
  try {
@@ -16143,7 +16258,10 @@ var EC2Provider = class {
16143
16258
  } catch (error) {
16144
16259
  const cause = error instanceof Error ? error : void 0;
16145
16260
  const thrown = new ProvisioningError(`Failed to create VPC ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, void 0, cause);
16146
- if (leftBehindId !== void 0) markCreatedBeforeFailure(thrown, logicalId, resourceType, leftBehindId);
16261
+ if (leftBehindId !== void 0) {
16262
+ markCreatedBeforeFailure(thrown, logicalId, resourceType, leftBehindId);
16263
+ markNonRetryable(thrown);
16264
+ }
16147
16265
  throw thrown;
16148
16266
  }
16149
16267
  }
@@ -16489,6 +16607,7 @@ var EC2Provider = class {
16489
16607
  let publicIp;
16490
16608
  let created = false;
16491
16609
  let createdId;
16610
+ let allocatedId;
16492
16611
  try {
16493
16612
  const input = {
16494
16613
  Domain: requireConfigString(properties["Domain"], "vpc", "AWS::EC2::EIP Domain", replayWarn(this.logger, context)),
@@ -16508,6 +16627,7 @@ var EC2Provider = class {
16508
16627
  }
16509
16628
  created = true;
16510
16629
  allocationId = response.AllocationId;
16630
+ allocatedId = allocationId;
16511
16631
  publicIp = response.PublicIp;
16512
16632
  try {
16513
16633
  createdId = this.eipPhysicalId(logicalId, publicIp, allocationId);
@@ -16532,9 +16652,31 @@ var EC2Provider = class {
16532
16652
  this.logger.debug(`Successfully created EIP ${logicalId}: ${allocationId} (${publicIp})`);
16533
16653
  } catch (error) {
16534
16654
  if (created) markAuxiliaryFailure(error, logicalId);
16655
+ if (createdId !== void 0 && allocatedId !== void 0) try {
16656
+ const releaseId = allocatedId;
16657
+ const watch = startInterruptWatch(`EIP ${logicalId} release`);
16658
+ try {
16659
+ await withRetry(() => this.ec2Client.send(new ReleaseAddressCommand({ AllocationId: releaseId })), logicalId, {
16660
+ maxRetries: 4,
16661
+ initialDelayMs: 500,
16662
+ isRetryable: (_text, releaseError) => isThrottlingError(releaseError),
16663
+ isInterrupted: watch.isInterrupted,
16664
+ onInterrupted: watch.onInterrupted
16665
+ });
16666
+ } finally {
16667
+ watch.dispose();
16668
+ }
16669
+ createdId = void 0;
16670
+ this.logger.debug(safeMsg`Released partially-created EIP ${logicalId} (${allocatedId})`);
16671
+ } catch (cleanupError) {
16672
+ this.logger.warn(safeMsg`Failed to release partially-created EIP ${logicalId} (${allocatedId}): ${describeAwsFailure(cleanupError).detail}. Manual release may be required: ${pasteableAwsCommand(context?.maskSecrets)`aws ec2 release-address --allocation-id ${allocatedId}`.render()}`);
16673
+ }
16535
16674
  const cause = error instanceof Error ? error : void 0;
16536
16675
  const thrown = new ProvisioningError(`Failed to create EIP ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, void 0, cause);
16537
- if (createdId !== void 0) markCreatedBeforeFailure(thrown, logicalId, resourceType, createdId);
16676
+ if (createdId !== void 0) {
16677
+ markCreatedBeforeFailure(thrown, logicalId, resourceType, createdId);
16678
+ markNonRetryable(thrown);
16679
+ }
16538
16680
  throw thrown;
16539
16681
  }
16540
16682
  return {
@@ -22205,6 +22347,7 @@ var CloudFrontDistributionProvider = class {
22205
22347
  }
22206
22348
  async delete(logicalId, physicalId, resourceType, _properties, context) {
22207
22349
  this.logger.debug(`Deleting CloudFront Distribution ${logicalId}: ${physicalId}`);
22350
+ let stripped = false;
22208
22351
  try {
22209
22352
  let etag;
22210
22353
  let config;
@@ -22224,11 +22367,13 @@ var CloudFrontDistributionProvider = class {
22224
22367
  if (config.Enabled) {
22225
22368
  this.logger.debug(`Disabling CloudFront Distribution ${physicalId} before deletion`);
22226
22369
  config.Enabled = false;
22227
- etag = (await this.cloudFrontClient.send(new UpdateDistributionCommand({
22370
+ const updateResponse = await this.cloudFrontClient.send(new UpdateDistributionCommand({
22228
22371
  Id: physicalId,
22229
22372
  IfMatch: etag,
22230
22373
  DistributionConfig: config
22231
- }))).ETag;
22374
+ }));
22375
+ stripped = true;
22376
+ etag = updateResponse.ETag;
22232
22377
  if (!await this.waitForDistributionStable(physicalId, false)) this.logger.warn(`Distribution ${shownId(physicalId)} disable did not settle (Deployed + disabled) within the wait budget; attempting delete anyway. If it fails with DistributionNotDisabled, retry the destroy or raise the budget with --resource-timeout AWS::CloudFront::Distribution=${commandHole("duration")}.`);
22233
22378
  etag = (await this.cloudFrontClient.send(new GetDistributionConfigCommand({ Id: physicalId }))).ETag;
22234
22379
  } else {
@@ -22248,7 +22393,8 @@ var CloudFrontDistributionProvider = class {
22248
22393
  return;
22249
22394
  }
22250
22395
  const cause = error instanceof Error ? error : void 0;
22251
- throw new ProvisioningError(`Failed to delete CloudFront Distribution ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
22396
+ const failure = new ProvisioningError(`Failed to delete CloudFront Distribution ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
22397
+ throw stripped ? markDeleteStarted(failure) : failure;
22252
22398
  }
22253
22399
  }
22254
22400
  async readCurrentState(physicalId, _logicalId, resourceType, _properties) {
@@ -24183,6 +24329,7 @@ var ECSProvider = class {
24183
24329
  if (skip) return skip;
24184
24330
  }
24185
24331
  } else cluster = recordedCluster;
24332
+ let stripped = false;
24186
24333
  try {
24187
24334
  try {
24188
24335
  await client.send(new UpdateServiceCommand({
@@ -24190,6 +24337,8 @@ var ECSProvider = class {
24190
24337
  service: physicalId,
24191
24338
  desiredCount: 0
24192
24339
  }));
24340
+ const recordedCount = properties?.["DesiredCount"];
24341
+ stripped = !(recordedCount === 0 || recordedCount === "0");
24193
24342
  this.logger.debug(`Scaled down ECS service ${physicalId} to 0`);
24194
24343
  } catch (error) {
24195
24344
  if (this.isServiceNotFoundException(error)) {
@@ -24214,7 +24363,8 @@ var ECSProvider = class {
24214
24363
  return;
24215
24364
  }
24216
24365
  const cause = error instanceof Error ? error : void 0;
24217
- throw new ProvisioningError(`Failed to delete ECS service ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
24366
+ const failure = new ProvisioningError(`Failed to delete ECS service ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
24367
+ throw stripped ? markDeleteStarted(failure) : failure;
24218
24368
  }
24219
24369
  }
24220
24370
  async getServiceAttribute(physicalId, attributeName) {
@@ -28487,9 +28637,10 @@ var Route53Provider = class {
28487
28637
  }
28488
28638
  async deleteHostedZone(logicalId, physicalId, resourceType, context) {
28489
28639
  this.logger.debug(`Deleting Route 53 hosted zone ${logicalId}: ${physicalId}`);
28640
+ const progress = { stripped: false };
28490
28641
  try {
28491
- await this.deleteQueryLoggingConfigForZone(physicalId, logicalId);
28492
- await this.ensureAcceleratedRecoveryDisabledForDelete(physicalId, logicalId);
28642
+ await this.deleteQueryLoggingConfigForZone(physicalId, logicalId, progress);
28643
+ await this.ensureAcceleratedRecoveryDisabledForDelete(physicalId, logicalId, progress);
28493
28644
  await this.getClient().send(new DeleteHostedZoneCommand({ Id: physicalId }));
28494
28645
  this.logger.debug(`Successfully deleted hosted zone ${logicalId}`);
28495
28646
  } catch (error) {
@@ -28499,12 +28650,12 @@ var Route53Provider = class {
28499
28650
  this.logger.debug(`Hosted zone ${physicalId} does not exist, skipping deletion`);
28500
28651
  return;
28501
28652
  }
28502
- if (error instanceof ProvisioningError) throw error;
28503
28653
  const cause = error instanceof Error ? error : void 0;
28504
- throw new ProvisioningError(`Failed to delete hosted zone ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
28654
+ const failure = error instanceof ProvisioningError ? error : new ProvisioningError(`Failed to delete hosted zone ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
28655
+ throw progress.stripped ? markDeleteStarted(failure) : failure;
28505
28656
  }
28506
28657
  }
28507
- async ensureAcceleratedRecoveryDisabledForDelete(physicalId, logicalId) {
28658
+ async ensureAcceleratedRecoveryDisabledForDelete(physicalId, logicalId, progress) {
28508
28659
  const client = this.getClient();
28509
28660
  const pollIntervalMs = Number.parseInt(process.env["CDKD_R53_ACCEL_RECOVERY_POLL_INTERVAL_MS"] ?? "15000", 10);
28510
28661
  const timeoutMs = Number.parseInt(process.env["CDKD_R53_ACCEL_RECOVERY_POLL_TIMEOUT_MS"] ?? "600000", 10);
@@ -28547,6 +28698,7 @@ var Route53Provider = class {
28547
28698
  HostedZoneId: physicalId,
28548
28699
  EnableAcceleratedRecovery: false
28549
28700
  }));
28701
+ progress.stripped = true;
28550
28702
  } else if (current === "DISABLING" || current === "DISABLING_HOSTED_ZONE_LOCKED") this.logger.debug(`Hosted zone ${physicalId} AcceleratedRecovery is already ${current} (a disabling phase); waiting for settle`);
28551
28703
  const settled = await waitFor(/* @__PURE__ */ new Set(["DISABLED"]), "DISABLED");
28552
28704
  this.logger.debug(`Hosted zone ${physicalId} AcceleratedRecoveryStatus settled to ${settled ?? "undefined (zone gone)"}`);
@@ -28899,11 +29051,18 @@ var Route53Provider = class {
28899
29051
  throw error;
28900
29052
  }
28901
29053
  }
28902
- async deleteQueryLoggingConfigForZone(zoneId, logicalId) {
29054
+ async deleteQueryLoggingConfigForZone(zoneId, logicalId, progress) {
28903
29055
  try {
28904
29056
  const configs = (await this.getClient().send(new ListQueryLoggingConfigsCommand({ HostedZoneId: zoneId }))).QueryLoggingConfigs ?? [];
28905
29057
  for (const config of configs) if (config.Id) {
28906
- await this.getClient().send(new DeleteQueryLoggingConfigCommand({ Id: config.Id }));
29058
+ const before = progress?.stripped;
29059
+ if (progress) progress.stripped = true;
29060
+ try {
29061
+ await this.getClient().send(new DeleteQueryLoggingConfigCommand({ Id: config.Id }));
29062
+ } catch (deleteError) {
29063
+ if (progress && before !== void 0 && isRefusedByName(deleteError)) progress.stripped = before;
29064
+ throw deleteError;
29065
+ }
28907
29066
  this.logger.debug(`Deleted query logging config ${config.Id} for hosted zone ${logicalId}`);
28908
29067
  }
28909
29068
  } catch (error) {
@@ -29720,6 +29879,8 @@ function customAcrLevels(acr) {
29720
29879
  }));
29721
29880
  return Object.keys(custom).length > 0 ? custom : void 0;
29722
29881
  }
29882
+ const EMAIL_RESET_CLAUSE = "reset to Cognito's default sender (EmailSendingAccount COGNITO_DEFAULT), dropping its SES SourceArn, and a redeploy will not restore it. Put the SES settings back with an UpdateUserPool that also carries the pool's other settings, since that call resets what it omits.";
29883
+ const EMAIL_RESET_BEFORE_DELETE_CLAUSE = "reset to Cognito's default sender (EmailSendingAccount COGNITO_DEFAULT), dropping its SES SourceArn, which stays that way if the delete fails.";
29723
29884
  const sentWithoutEmail = /* @__PURE__ */ new WeakSet();
29724
29885
  const createUserPoolLatch = new AmbiguousCreateLatch("CreateUserPool");
29725
29886
  const userPoolsCreatedByThisProcess = new RecentIdSet();
@@ -29930,6 +30091,7 @@ var CognitoUserPoolProvider = class {
29930
30091
  logger = getLogger().child("CognitoUserPoolProvider");
29931
30092
  protectionFlips = new ProtectionFlipRegistry();
29932
30093
  preFlipPools = /* @__PURE__ */ new WeakMap();
30094
+ emailOmittedFlips = /* @__PURE__ */ new WeakMap();
29933
30095
  handledProperties = /* @__PURE__ */ new Map([["AWS::Cognito::UserPool", /* @__PURE__ */ new Set([
29934
30096
  "UserPoolName",
29935
30097
  "AutoVerifiedAttributes",
@@ -30085,7 +30247,10 @@ var CognitoUserPoolProvider = class {
30085
30247
  }
30086
30248
  const cause = error instanceof Error ? error : void 0;
30087
30249
  const thrown = new ProvisioningError(`Failed to create Cognito User Pool ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, poolName, cause);
30088
- if (poolLeftBehind && createdUserPoolId) markCreatedBeforeFailure(thrown, logicalId, resourceType, createdUserPoolId);
30250
+ if (poolLeftBehind && createdUserPoolId) {
30251
+ markCreatedBeforeFailure(thrown, logicalId, resourceType, createdUserPoolId);
30252
+ markNonRetryable(thrown);
30253
+ }
30089
30254
  throw thrown;
30090
30255
  }
30091
30256
  }
@@ -30383,10 +30548,12 @@ var CognitoUserPoolProvider = class {
30383
30548
  if (bareFlip && pool.DeletionProtection !== "ACTIVE") bareFlip.ambiguous = false;
30384
30549
  const resetConfirmed = bareFlip !== void 0 && !bareFlip.ambiguous;
30385
30550
  if (bareFlip) this.reportSettingsResetByBareFlip(physicalId, bareFlip.pool, reportKind(bareFlip));
30551
+ if (flipRecord && this.emailOmittedFlips.has(flipRecord) && !echoesDeveloperEmail(pool) && !(bareFlip && echoesDeveloperEmail(bareFlip.pool))) this.logger.error(safeMsg`Cognito User Pool ${physicalId} is LIVE with its SES email configuration reset: ` + safeMsg`--remove-protection turned DeletionProtection off with an UpdateUserPool that left ` + safeMsg`out its DEVELOPER EmailConfiguration (sending it was refused), and the delete then ` + safeMsg`failed. The pool's email configuration was ${EMAIL_RESET_CLAUSE}`);
30386
30552
  const bareLicensed = resetConfirmed && bareFlip.echoedSince !== true;
30387
30553
  const readOn = pool.DeletionProtection === "ACTIVE";
30388
30554
  try {
30389
- await this.sendEchoedDeletionProtection(physicalId, pool, "ACTIVE");
30555
+ const emailAlreadyReset = flipRecord !== void 0 && this.emailOmittedFlips.get(flipRecord) === "definite";
30556
+ await this.sendEchoedDeletionProtection(physicalId, pool, "ACTIVE", { emailFallback: !readOn || emailAlreadyReset });
30390
30557
  } catch (echoError) {
30391
30558
  let failure = echoError;
30392
30559
  if (bareLicensed && isRefusedEcho(echoError)) try {
@@ -30422,8 +30589,10 @@ var CognitoUserPoolProvider = class {
30422
30589
  }
30423
30590
  const mode = before.UserPoolAddOns?.AdvancedSecurityMode;
30424
30591
  if (mode) held.push(`AdvancedSecurityMode=${mode}`);
30592
+ if (echoesDeveloperEmail(before)) held.push("EmailConfiguration.EmailSendingAccount=DEVELOPER (SES)");
30425
30593
  const heldText = held.length > 0 ? held.join(", ") : "none of these settings";
30426
- const state = kind === "unclear" ? safeMsg`is LIVE and its self sign-up, Lambda triggers and advanced security MAY have been reset: ` + safeMsg`--remove-protection sent UpdateUserPool with DeletionProtection alone (the pool's own ` + safeMsg`configuration was refused) and got no clear answer, and the delete then failed. Check it ` + safeMsg`with aws cognito-idp describe-user-pool.` : kind === "earlier" ? safeMsg`is LIVE; its self sign-up, Lambda triggers and advanced security were reset by an ` + safeMsg`earlier UpdateUserPool that --remove-protection sent with DeletionProtection alone (the ` + safeMsg`pool's own configuration was refused); they may have been restored since. Check it with ` + safeMsg`aws cognito-idp describe-user-pool.` : safeMsg`is LIVE with its self sign-up, Lambda triggers and advanced security reset: ` + safeMsg`--remove-protection had to turn DeletionProtection off with UpdateUserPool alone (the ` + safeMsg`pool's own configuration was refused), and the delete then failed.`;
30594
+ const what = echoesDeveloperEmail(before) ? "self sign-up, Lambda triggers, advanced security and SES email configuration" : "self sign-up, Lambda triggers and advanced security";
30595
+ const state = kind === "unclear" ? safeMsg`is LIVE and its ${what} MAY have been reset: ` + safeMsg`--remove-protection sent UpdateUserPool with DeletionProtection alone (the pool's own ` + safeMsg`configuration was refused) and got no clear answer, and the delete then failed. Check it ` + safeMsg`with aws cognito-idp describe-user-pool.` : kind === "earlier" ? safeMsg`is LIVE; its ${what} were reset by an ` + safeMsg`earlier UpdateUserPool that --remove-protection sent with DeletionProtection alone (the ` + safeMsg`pool's own configuration was refused); they may have been restored since. Check it with ` + safeMsg`aws cognito-idp describe-user-pool.` : safeMsg`is LIVE with its ${what} reset: ` + safeMsg`--remove-protection had to turn DeletionProtection off with UpdateUserPool alone (the ` + safeMsg`pool's own configuration was refused), and the delete then failed.`;
30427
30596
  this.logger.error(safeMsg`Cognito User Pool ${physicalId} ` + state + safeMsg` Before that write the pool held: ${heldText}. Put them back with ` + safeMsg`aws cognito-idp update-user-pool, sending the pool's complete configuration -- a ` + safeMsg`cdkd deploy will NOT restore them, because its recorded properties still match the template.`);
30428
30597
  }
30429
30598
  async deleteOnce(logicalId, physicalId, resourceType, context, flip) {
@@ -30488,31 +30657,38 @@ var CognitoUserPoolProvider = class {
30488
30657
  throw new ProvisioningError(`Failed to delete Cognito User Pool ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
30489
30658
  }
30490
30659
  }
30491
- async sendEchoedDeletionProtection(physicalId, pool, value) {
30660
+ async sendEchoedDeletionProtection(physicalId, pool, value, opts = {}) {
30492
30661
  try {
30493
30662
  await this.getClient().send(new UpdateUserPoolCommand(userPoolDeletionProtectionUpdate(physicalId, pool, value)));
30663
+ return "echoed";
30494
30664
  } catch (echoError) {
30495
30665
  if (!echoesDeveloperEmail(pool) || !isRefusedEcho(echoError)) throw echoError;
30666
+ if (opts.emailFallback === false) throw echoError;
30667
+ const resetClause = value === "ACTIVE" ? EMAIL_RESET_CLAUSE : EMAIL_RESET_BEFORE_DELETE_CLAUSE;
30496
30668
  this.logger.debug(safeMsg`UpdateUserPool refused the SES EmailConfiguration of ${physicalId}: ${describeAwsFailure(echoError).summary}`);
30497
30669
  try {
30498
30670
  await this.getClient().send(new UpdateUserPoolCommand(userPoolDeletionProtectionUpdate(physicalId, pool, value, { withoutDeveloperEmail: true })));
30499
30671
  } catch (resendError) {
30500
30672
  if (typeof resendError === "object" && resendError !== null) sentWithoutEmail.add(resendError);
30673
+ if (isAmbiguousWriteFailure(resendError) && (value === "ACTIVE" || isTransientCognitoFailure(resendError))) this.logger.warn(safeMsg`Cognito User Pool ${physicalId}: UpdateUserPool refused the write carrying the ` + safeMsg`pool's SES EmailConfiguration (${describeAwsFailure(echoError).summary}), and the ` + safeMsg`write re-sent without it answered ${describeAwsFailure(resendError).summary}. If ` + safeMsg`that write landed, the pool's email configuration was ${resetClause}`);
30501
30674
  throw resendError;
30502
30675
  }
30503
- this.logger.warn(safeMsg`Cognito User Pool ${physicalId}: UpdateUserPool refused the write (possibly the ` + safeMsg`pool's SES EmailConfiguration, ${describeAwsFailure(echoError).summary}), so ` + safeMsg`DeletionProtection was set to ${value} with the pool's other settings but without ` + safeMsg`that EmailConfiguration. Whether that resets the email configuration is not ` + safeMsg`measured; check it with aws cognito-idp describe-user-pool.`);
30676
+ this.logger.warn(safeMsg`Cognito User Pool ${physicalId}: UpdateUserPool refused the write (possibly the ` + safeMsg`pool's SES EmailConfiguration, ${describeAwsFailure(echoError).summary}), so ` + safeMsg`DeletionProtection was set to ${value} with the pool's other settings but without ` + safeMsg`that EmailConfiguration. The pool's email configuration was ${resetClause}`);
30677
+ return "without-email";
30504
30678
  }
30505
30679
  }
30506
30680
  async disableUserPoolDeletionProtection(physicalId, pool, flip) {
30507
30681
  if (this.preFlipPools.get(flip)?.ambiguous) this.preFlipPools.delete(flip);
30508
30682
  const observedOn = pool.DeletionProtection === "ACTIVE";
30509
30683
  try {
30510
- await this.sendEchoedDeletionProtection(physicalId, pool, "INACTIVE");
30684
+ if (await this.sendEchoedDeletionProtection(physicalId, pool, "INACTIVE") === "without-email") this.emailOmittedFlips.set(flip, "definite");
30685
+ else if (echoesDeveloperEmail(pool)) this.emailOmittedFlips.delete(flip);
30511
30686
  const earlier = this.preFlipPools.get(flip);
30512
30687
  if (earlier) earlier.echoedSince = true;
30513
30688
  return;
30514
30689
  } catch (echoError) {
30515
30690
  if (echoError instanceof ResourceNotFoundException$11) throw echoError;
30691
+ if (typeof echoError === "object" && echoError !== null && sentWithoutEmail.has(echoError) && isAmbiguousWriteFailure(echoError) && !this.emailOmittedFlips.has(flip)) this.emailOmittedFlips.set(flip, "ambiguous");
30516
30692
  if (observedOn && isAmbiguousWriteFailure(echoError)) flip.flippedOffByThisRun = true;
30517
30693
  if (isTransientCognitoFailure(echoError)) throw echoError;
30518
30694
  if (!isRefusedEcho(echoError)) {
@@ -30559,7 +30735,7 @@ var CognitoUserPoolProvider = class {
30559
30735
  const echoClause = echoError === void 0 ? "" : safeMsg`; the pool's own settings sent back were refused first (${describeAwsFailure(echoError).summary})`;
30560
30736
  this.logger.debug(safeMsg`UpdateUserPool did not turn DeletionProtection off on ${physicalId}: ${describeAwsFailure(error).detail}`);
30561
30737
  const refused = error instanceof Error && isAwsAuthoredFailure(error);
30562
- this.logger.warn(refused ? safeMsg`Cognito User Pool ${physicalId}: DeletionProtection was left on, because UpdateUserPool ` + safeMsg`refused to turn it off (${describeAwsFailure(error).summary})` + echoClause + safeMsg`. The delete will be refused while it is on.${accessHint}` : safeMsg`Cognito User Pool ${physicalId}: UpdateUserPool failed without an answer from AWS ` + safeMsg`(${describeAwsFailure(error).summary})` + echoClause + (echoError === void 0 ? typeof error === "object" && error !== null && sentWithoutEmail.has(error) ? safeMsg`, so whether DeletionProtection was turned off is unknown. Its other settings were ` + safeMsg`not reset, except possibly the SES EmailConfiguration, which that write omitted.` : safeMsg`, so whether DeletionProtection was turned off is unknown. Its other settings were ` + safeMsg`not reset.` : safeMsg`, so whether DeletionProtection was turned off ALONE is unknown; if it was, the ` + safeMsg`pool's self sign-up, Lambda triggers and advanced security were reset.`) + safeMsg` If the delete then fails, cdkd turns the guard back on. Check the pool with ` + safeMsg`aws cognito-idp describe-user-pool.`);
30738
+ this.logger.warn(refused ? safeMsg`Cognito User Pool ${physicalId}: DeletionProtection was left on, because UpdateUserPool ` + safeMsg`refused to turn it off (${describeAwsFailure(error).summary})` + echoClause + safeMsg`. The delete will be refused while it is on.${accessHint}` : safeMsg`Cognito User Pool ${physicalId}: UpdateUserPool failed without an answer from AWS ` + safeMsg`(${describeAwsFailure(error).summary})` + echoClause + (echoError === void 0 ? typeof error === "object" && error !== null && sentWithoutEmail.has(error) ? safeMsg`, so whether DeletionProtection was turned off is unknown. Its other settings were ` + safeMsg`not reset, except the SES EmailConfiguration, which that write omitted: if it ` + safeMsg`landed, the pool's email configuration was ${EMAIL_RESET_BEFORE_DELETE_CLAUSE}` : safeMsg`, so whether DeletionProtection was turned off is unknown. Its other settings were ` + safeMsg`not reset.` : safeMsg`, so whether DeletionProtection was turned off ALONE is unknown; if it was, the ` + safeMsg`pool's self sign-up, Lambda triggers and advanced security were reset.`) + safeMsg` If the delete then fails, cdkd turns the guard back on. Check the pool with ` + safeMsg`aws cognito-idp describe-user-pool.`);
30563
30739
  }
30564
30740
  async readCurrentState(physicalId, _logicalId, resourceType) {
30565
30741
  if (resourceType !== "AWS::Cognito::UserPool") return void 0;
@@ -32940,7 +33116,10 @@ var AppSyncProvider = class {
32940
33116
  }
32941
33117
  const cause = error instanceof Error ? error : void 0;
32942
33118
  const thrown = new ProvisioningError(`Failed to create GraphQL API ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, void 0, cause);
32943
- if (apiLeftBehind && createdApiId) markCreatedBeforeFailure(thrown, logicalId, resourceType, createdApiId);
33119
+ if (apiLeftBehind && createdApiId) {
33120
+ markCreatedBeforeFailure(thrown, logicalId, resourceType, createdApiId);
33121
+ markNonRetryable(thrown);
33122
+ }
32944
33123
  throw thrown;
32945
33124
  }
32946
33125
  }
@@ -35693,10 +35872,17 @@ var GlueTriggerProvider = class {
35693
35872
  async delete(logicalId, physicalId, resourceType, _properties, context) {
35694
35873
  this.logger.debug(`Deleting Glue Trigger ${logicalId}: ${physicalId}`);
35695
35874
  assertRegionMatch(context?.expectedRegion ? await this.getClient().config.region() : void 0, context?.expectedRegion, resourceType, logicalId, physicalId, "pre-delete");
35875
+ let stripped = false;
35696
35876
  try {
35697
35877
  try {
35698
35878
  if ((await this.getClient().send(new GetTriggerCommand({ Name: physicalId }))).Trigger?.State === "ACTIVATED") {
35699
- await this.getClient().send(new StopTriggerCommand({ Name: physicalId }));
35879
+ stripped = true;
35880
+ try {
35881
+ await this.getClient().send(new StopTriggerCommand({ Name: physicalId }));
35882
+ } catch (stopError) {
35883
+ if (isRefusedByName(stopError)) stripped = false;
35884
+ throw stopError;
35885
+ }
35700
35886
  await this.waitForTriggerDeactivated(physicalId);
35701
35887
  }
35702
35888
  } catch (err) {
@@ -35711,7 +35897,8 @@ var GlueTriggerProvider = class {
35711
35897
  return;
35712
35898
  }
35713
35899
  const cause = error instanceof Error ? error : void 0;
35714
- throw new ProvisioningError(`Failed to delete Glue Trigger ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
35900
+ const failure = new ProvisioningError(`Failed to delete Glue Trigger ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
35901
+ throw stripped ? markDeleteStarted(failure) : failure;
35715
35902
  }
35716
35903
  }
35717
35904
  async getAttribute(physicalId, _resourceType, attributeName) {
@@ -35766,6 +35953,7 @@ var GlueTriggerProvider = class {
35766
35953
  const createKeyLatch = new AmbiguousCreateLatch("CreateKey");
35767
35954
  const keysCreatedByThisProcess = new RecentIdSet();
35768
35955
  const pendingKeys = /* @__PURE__ */ new Map();
35956
+ const supersededAttempts = /* @__PURE__ */ new Map();
35769
35957
  const RESUMABLE_KEY_STATES = /* @__PURE__ */ new Set([
35770
35958
  "Enabled",
35771
35959
  "Disabled",
@@ -35860,11 +36048,12 @@ var KMSProvider = class {
35860
36048
  enabled: properties["Enabled"] !== false
35861
36049
  })).digest("hex");
35862
36050
  let createdKeyId;
36051
+ let supersededPending = false;
35863
36052
  try {
35864
36053
  const resumed = await this.resumeKeyFromFailedAttempt(logicalId, attemptKey, inputDigest);
35865
36054
  let keyId;
35866
36055
  let keyArn;
35867
- if (resumed) ({keyId, keyArn} = resumed);
36056
+ if (resumed && resumed !== "superseded") ({keyId, keyArn} = resumed);
35868
36057
  else {
35869
36058
  const orphanWindow = createKeyLatch.take(logicalId);
35870
36059
  if (orphanWindow !== void 0) await this.reportPossibleOrphanKeys(logicalId, input, orphanWindow);
@@ -35885,6 +36074,9 @@ var KMSProvider = class {
35885
36074
  heldAtMs: Date.now()
35886
36075
  });
35887
36076
  createdKeyId = keyId;
36077
+ const declinedAtMs = supersededAttempts.get(attemptKey);
36078
+ supersededAttempts.delete(attemptKey);
36079
+ supersededPending = declinedAtMs !== void 0 && Date.now() - declinedAtMs <= 18e5;
35888
36080
  const replayWindow = replayedSendWindow(result, attemptStartMs);
35889
36081
  if (replayWindow !== void 0) await this.reportPossibleOrphanKeys(logicalId, input, replayWindow);
35890
36082
  }
@@ -35920,7 +36112,10 @@ var KMSProvider = class {
35920
36112
  }
35921
36113
  const cause = error instanceof Error ? error : void 0;
35922
36114
  const thrown = new ProvisioningError(`Failed to create KMS Key ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, void 0, cause);
35923
- if (createdKeyId !== void 0) markCreatedBeforeFailure(thrown, logicalId, resourceType, createdKeyId);
36115
+ if (createdKeyId !== void 0) {
36116
+ markCreatedBeforeFailure(thrown, logicalId, resourceType, createdKeyId);
36117
+ if (supersededPending) markSupersedesEarlierCreate(thrown);
36118
+ }
35924
36119
  throw thrown;
35925
36120
  }
35926
36121
  }
@@ -35943,6 +36138,8 @@ var KMSProvider = class {
35943
36138
  const deletion = aws`aws kms schedule-key-deletion --key-id ${pending.keyId}${region} --pending-window-in-days 7`.render();
35944
36139
  const notReused = (reason) => {
35945
36140
  this.logger.warn(safeMsg`KMS key ${pending.keyId} was created for ${logicalId} by an earlier attempt of this deploy, but ${reason}, so this attempt creates a new key and that one is not recorded in cdkd state. If it is unused, schedule its deletion with: ${deletion}`);
36141
+ setBounded(supersededAttempts, attemptKey, Date.now());
36142
+ return "superseded";
35946
36143
  };
35947
36144
  if (pending.inputDigest !== inputDigest) return notReused("this attempt was asked for a key with different inputs");
35948
36145
  let metadata;
@@ -40598,7 +40795,10 @@ var EMRClusterProvider = class {
40598
40795
  this.logger.warn(`Failed to roll back partially-created EMR Cluster ${clusterId}: ${describeAwsFailure(cleanupError).detail} — terminate it manually to stop billing`);
40599
40796
  }
40600
40797
  if (error instanceof ProvisioningError) {
40601
- if (survivorId !== void 0) markCreatedBeforeFailure(error, logicalId, resourceType, survivorId);
40798
+ if (survivorId !== void 0) {
40799
+ markCreatedBeforeFailure(error, logicalId, resourceType, survivorId);
40800
+ markNonRetryable(error);
40801
+ }
40602
40802
  throw error;
40603
40803
  }
40604
40804
  const cause = error instanceof Error ? error : void 0;
@@ -40606,6 +40806,7 @@ var EMRClusterProvider = class {
40606
40806
  if (survivorId !== void 0) {
40607
40807
  const thrown = new ProvisioningError(message, resourceType, logicalId, void 0, cause);
40608
40808
  markCreatedBeforeFailure(thrown, logicalId, resourceType, survivorId);
40809
+ markNonRetryable(thrown);
40609
40810
  throw thrown;
40610
40811
  }
40611
40812
  throw new ProvisioningError(message, resourceType, logicalId, void 0, cause);
@@ -41274,7 +41475,27 @@ var EMRInstanceGroupConfigProvider = class {
41274
41475
  };
41275
41476
  } catch (error) {
41276
41477
  const thrown = error instanceof ProvisioningError ? error : new ProvisioningError(`Failed to add EMR instance group ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, void 0, error instanceof Error ? error : void 0);
41277
- if (createdGroupId) markCreatedBeforeFailure(thrown, logicalId, resourceType, createdGroupId);
41478
+ let leftBehindGroupId = createdGroupId;
41479
+ if (leftBehindGroupId && properties["InstanceRole"] === "TASK") {
41480
+ const log = createMaskedLogSinks(this.logger, context?.maskSecrets);
41481
+ try {
41482
+ await this.getClient().send(new ModifyInstanceGroupsCommand({
41483
+ ClusterId: jobFlowId,
41484
+ InstanceGroups: [{
41485
+ InstanceGroupId: leftBehindGroupId,
41486
+ InstanceCount: 0
41487
+ }]
41488
+ }));
41489
+ log.warn(safeMsg`Scaled partially-created EMR TASK instance group ${logicalId} (${leftBehindGroupId}) to 0; EMR has no delete API, so the empty group stays on cluster ${log.value(jobFlowId)} until it terminates`);
41490
+ leftBehindGroupId = void 0;
41491
+ } catch (cleanupError) {
41492
+ log.warn(safeMsg`Failed to scale partially-created EMR TASK instance group ${logicalId} (${leftBehindGroupId}) to 0: ${describeAwsFailure(cleanupError).detail} — its instances are released when the parent cluster terminates`);
41493
+ }
41494
+ }
41495
+ if (leftBehindGroupId) {
41496
+ markCreatedBeforeFailure(thrown, logicalId, resourceType, leftBehindGroupId);
41497
+ markNonRetryable(thrown);
41498
+ }
41278
41499
  throw thrown;
41279
41500
  }
41280
41501
  }
@@ -41580,7 +41801,10 @@ var EMRInstanceFleetConfigProvider = class {
41580
41801
  };
41581
41802
  } catch (error) {
41582
41803
  const thrown = error instanceof ProvisioningError ? error : new ProvisioningError(`Failed to add EMR instance fleet ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, void 0, error instanceof Error ? error : void 0);
41583
- if (createdFleetId) markCreatedBeforeFailure(thrown, logicalId, resourceType, createdFleetId);
41804
+ if (createdFleetId) {
41805
+ markCreatedBeforeFailure(thrown, logicalId, resourceType, createdFleetId);
41806
+ markNonRetryable(thrown);
41807
+ }
41584
41808
  throw thrown;
41585
41809
  }
41586
41810
  }
@@ -42857,12 +43081,18 @@ var CloudTrailProvider = class {
42857
43081
  throw new ProvisioningError(`Failed to update CloudTrail Trail ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
42858
43082
  }
42859
43083
  }
42860
- async delete(logicalId, physicalId, resourceType, _properties, context) {
43084
+ async delete(logicalId, physicalId, resourceType, properties, context) {
42861
43085
  this.logger.debug(`Deleting CloudTrail Trail ${logicalId}: ${physicalId}`);
43086
+ const recordedIsLogging = properties?.["IsLogging"];
43087
+ const recordedStopped = recordedIsLogging === false || recordedIsLogging === "false";
43088
+ let stripped = false;
42862
43089
  try {
42863
43090
  try {
43091
+ stripped = !recordedStopped;
42864
43092
  await this.getClient().send(new StopLoggingCommand({ Name: physicalId }));
42865
- } catch {}
43093
+ } catch (stopError) {
43094
+ if (isRefusedByName(stopError)) stripped = false;
43095
+ }
42866
43096
  await this.getClient().send(new DeleteTrailCommand({ Name: physicalId }));
42867
43097
  this.logger.debug(`Successfully deleted CloudTrail Trail ${logicalId}`);
42868
43098
  } catch (error) {
@@ -42873,7 +43103,8 @@ var CloudTrailProvider = class {
42873
43103
  return;
42874
43104
  }
42875
43105
  const cause = error instanceof Error ? error : void 0;
42876
- throw new ProvisioningError(`Failed to delete CloudTrail Trail ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
43106
+ const failure = new ProvisioningError(`Failed to delete CloudTrail Trail ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
43107
+ throw stripped ? markDeleteStarted(failure) : failure;
42877
43108
  }
42878
43109
  }
42879
43110
  getAttribute(_physicalId, _resourceType, attributeName) {
@@ -46433,4 +46664,4 @@ var ACMCertificateProvider = class {
46433
46664
 
46434
46665
  //#endregion
46435
46666
  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, LambdaNetworkConnectorProvider, LambdaPermissionProvider, LambdaUrlProvider, LambdaWebFunctionEndpointProvider, LambdaWebFunctionRevisionProvider, 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 };
46436
- //# sourceMappingURL=provider-classes-CVC9_-km.js.map
46667
+ //# sourceMappingURL=provider-classes-DzoIZFZK.js.map