@go-to-k/cdkd 0.299.2 → 0.299.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/{asg-provider-C6USPLiS.js → asg-provider-BtUUjRnI.js} +2 -2
  2. package/dist/{asg-provider-C6USPLiS.js.map → asg-provider-BtUUjRnI.js.map} +1 -1
  3. package/dist/cli.js +2 -2
  4. package/dist/{deploy-engine-DlLwYRJk.js → deploy-engine-DWIbDQdg.js} +708 -150
  5. package/dist/deploy-engine-DWIbDQdg.js.map +1 -0
  6. package/dist/{iam-role-provider-D5B5lEmu.js → iam-role-provider-DTQlG8qe.js} +2 -2
  7. package/dist/{iam-role-provider-D5B5lEmu.js.map → iam-role-provider-DTQlG8qe.js.map} +1 -1
  8. package/dist/index.d.ts +11 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +2 -2
  11. package/dist/{neptune-provider-Ba5va85p.js → neptune-provider-Bkrw65eO.js} +2 -2
  12. package/dist/{neptune-provider-Ba5va85p.js.map → neptune-provider-Bkrw65eO.js.map} +1 -1
  13. package/dist/{program-TA6lNkLr.js → program-B4_qJpAO.js} +31 -12
  14. package/dist/program-B4_qJpAO.js.map +1 -0
  15. package/dist/{provider-classes-WJRB6zvO.js → provider-classes-SNKb1al7.js} +116 -15
  16. package/dist/provider-classes-SNKb1al7.js.map +1 -0
  17. package/dist/{rds-provider-DcUEh3d2.js → rds-provider-B9gz-giS.js} +2 -2
  18. package/dist/{rds-provider-DcUEh3d2.js.map → rds-provider-B9gz-giS.js.map} +1 -1
  19. package/dist/{version-Dz0rTkus.js → version-B-AQELPJ.js} +2 -2
  20. package/dist/{version-Dz0rTkus.js.map → version-B-AQELPJ.js.map} +1 -1
  21. package/package.json +1 -1
  22. package/dist/deploy-engine-DlLwYRJk.js.map +0 -1
  23. package/dist/program-TA6lNkLr.js.map +0 -1
  24. package/dist/provider-classes-WJRB6zvO.js.map +0 -1
@@ -2,12 +2,12 @@ import { r as getAwsClients } from "./aws-clients-Bj7qH5Ph.js";
2
2
  import { F as displayStackName, I as isPasteableIdent, N as displayIdent, O as SECRET_REF_MAX_CODE_POINTS, P as displaySafe, R as plainIdentOr, a as getLogger, b as generateResourceNameWithFallback, n as isAwsAuthoredFailure, r as safeStringify, t as describeAwsFailure, y as generateResourceName, z as safeMsg } from "./aws-failure-text-DtvlUugx.js";
3
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-Pn2m0R67.js";
4
4
  import { s as ambientRegion } from "./aws-client-defaults-DBXBcg0J.js";
5
- import { $ as isTruthyCfnBoolean, Al as displayAssemblyPath, B as DYNAMODB_DELETE_MIN_RESOURCE_TIMEOUT_MS, Bo as passedNoEchoParametersOf, Br as reDisableInstanceApiTermination, Bt as getStackRecords, Cs as carriesSecretMask, Ct as revertNestedChildFromJournal, Do as lambdaFunctionNameForMask, Dr as unchangedBehindSecretReference, Dt as getCurrentNestedStackContext, Eo as canonicalLambdaFunctionName, Er as slowCcOperationTimeoutMs, Fr as markWaitAbandoned, G as resolveDynamoDbDeleteBudgetMs, H as compensateRemovedDeletionProtection, Ia as refuseMalformedResourcesForDestroy, J as deleteTableWithIndexBusyRetry, Ja as withheldAccountClause, K as DELETE_INDEX_WAIT_PROCEED_NOTE, Lr as ec2InstanceProtectionSite, Ml as resolveAssemblyPath, Mr as deleteSkipReason, Nr as withIndeterminateGuard, Oo as sameLambdaFunctionAddress, Ot as withNestedStackContext, Pi as passedParameterClassesOf, Pr as isWaitAbandonedError, Q as hasCdkAutoDeleteTag, Qa as withoutSilentDropProperties, Qn as earliestDefined, Rr as isTerminationProtectionPropagationError, Rt as awaitInFlightSibling, To as withRetry, U as deleteBudgetKey, V as beginDeleteWait, Vi as accountArgs, Vr as reEnableInstanceApiTermination, W as resolveDynamoDbDeleteBudgetClock, X as ECR_AUTO_DELETE_IMAGES_TAG, Xa as findSilentDropProperties, Y as waitForIndexesSettled, Z as S3_AUTO_DELETE_OBJECTS_TAG, _o as readConfigString, a as findNestedTemplateTreeDefect, an as isRedactedRecordedValue, ar as planTagDiff, as as recordReferenceProvenanceEntry, b as lookupEachName, bo as requireConfigObject, br as getCurrentResourceSecrets, bs as recordAttributeIdCopy, bt as getNestedRevertRun, c as renderNestedTemplateTreeDefect, cc as stringifyValue, co as coerceWarmThroughput$1, cr as tagMapAsList, di as s3BucketDualStackDomainName, do as toFiniteNumber, dr as stringifyIfAssigned, er as reserveStackCreateToken, et as getPriorAttempts, fi as s3BucketRegionalDomainName, fo as coerceCfnBoolean, fs as dynamicReferenceTokens, ga as refuseMalformedNestedChildOutputs, go as configStringRefusal, hl as decodeListingKey, ho as configIntegerRefusal, ii as isSettledInstanceState, in as REDACTED_DELETE_ADDRESS_SKIP_REASON, ir as DBPROXY_TAG_OPTIONS, is as markSameGenerationBag, ji as parseWebACLArn, jl as renderAssemblyPathEscape, kl as describeFileReadFailure, li as s3BucketArn, lo as isWarmThroughputDecrease, lr as tagPlanWarning, mo as configBooleanRefusal, nn as getCurrentProducerRegions, nr as acquireIdempotencyToken, o as isAbsoluteAssetPath, oi as outputReferenceProvenanceOf, on as redactedDeleteAddressFields, or as readTagList, os as snapshotPassProvenance, pc as rewriteTemplateAssetReferences, pi as s3BucketWebsiteUrl, po as coerceCfnInteger, q as INDEX_SETTLE_POLL_INTERVAL_MS, qo as hasMaskableValues, rr as DBPROXY_TAGS_WHAT, s as listNestedTemplateRows, sn as redactedDeleteAddressSkip, so as WARM_THROUGHPUT_MEMBERS, sr as refuseMalformedDesiredTags, ss as redactSecretsForState, t as DeployEngine, tt as markRefusedBeforeApplying, ui as s3BucketDomainName, uo as toCfnInteger, ur as definedAttributes, us as withoutPhysicalNameCopies, v as chunks, vl as canonicalizeRegion, vo as replayWarn, vs as recoverMaskedOutput, x as withApiLimit, xi as getAccountInfo, xo as requireConfigString, y as isAccessDeniedError, yl as derivePartitionAndUrlSuffix, yo as requireConfigArray, ys as physicalNameCopiesOf, z as DynamoDBGlobalTableProvider, zr as observeThenDisableInstanceApiTermination } from "./deploy-engine-DlLwYRJk.js";
6
- import { n as collectInlinePolicyNamesManagedBySiblings, r as IamCreateClientCache, t as IAMRoleProvider } from "./iam-role-provider-D5B5lEmu.js";
7
- import { a as canonicalizeIpProtocolValue, i as resolveSecretDerivedPrincipals, n as runDestroyForStack, o as resolvedResourceTimeoutMs, r as isResolvableSecretPrincipalList, t as canonicalizeIpv4Cidr } from "./program-TA6lNkLr.js";
8
- import { RDSProvider } from "./rds-provider-DcUEh3d2.js";
9
- import { NeptuneProvider } from "./neptune-provider-Ba5va85p.js";
10
- import { ASGProvider } from "./asg-provider-C6USPLiS.js";
5
+ import { $ as S3_AUTO_DELETE_OBJECTS_TAG, Ao as sameLambdaFunctionAddress, At as withNestedStackContext, Br as isTerminationProtectionPropagationError, Bt as awaitInFlightSibling, C as withApiLimit, Ci as getAccountInfo, Co as requireConfigString, Do as withRetry, Fr as withIndeterminateGuard, G as deleteBudgetKey, H as DYNAMODB_DELETE_MIN_RESOURCE_TIMEOUT_MS, Ho as passedNoEchoParametersOf, Hr as reDisableInstanceApiTermination, Ht as getStackRecords, Ii as passedParameterClassesOf, Ir as isWaitAbandonedError, J as DELETE_INDEX_WAIT_PROCEED_NOTE, K as resolveDynamoDbDeleteBudgetClock, Lr as markWaitAbandoned, Ml as displayAssemblyPath, Ni as parseWebACLArn, Nl as renderAssemblyPathEscape, Oo as canonicalLambdaFunctionName, Or as slowCcOperationTimeoutMs, Pl as resolveAssemblyPath, Pr as deleteSkipReason, Q as ECR_AUTO_DELETE_IMAGES_TAG, Qa as findSilentDropProperties, Ra as refuseMalformedResourcesForDestroy, S as lookupEachName, So as requireConfigObject, Sr as getCurrentResourceSecrets, Ss as recordAttributeIdCopy, St as getNestedRevertRun, Ts as carriesSecretMask, Tt as revertNestedChildFromJournal, U as beginDeleteWait, Ui as accountArgs, Ur as reEnableInstanceApiTermination, V as DynamoDBGlobalTableProvider, Vr as observeThenDisableInstanceApiTermination, W as compensateRemovedDeletionProtection, X as deleteTableWithIndexBusyRetry, Xa as withheldAccountClause, Y as INDEX_SETTLE_POLL_INTERVAL_MS, Yo as hasMaskableValues, Z as waitForIndexesSettled, _l as decodeListingKey, _o as configIntegerRefusal, ar as DBPROXY_TAGS_WHAT, b as chunks, bl as canonicalizeRegion, bo as replayWarn, bs as recoverMaskedOutput, c as isAbsoluteAssetPath, ci as outputReferenceProvenanceOf, cn as redactedDeleteAddressFields, cr as readTagList, cs as snapshotPassProvenance, di as s3BucketArn, do as isWarmThroughputDecrease, dr as tagPlanWarning, eo as withoutSilentDropProperties, er as earliestDefined, et as hasCdkAutoDeleteTag, fi as s3BucketDomainName, fo as toCfnInteger, fr as definedAttributes, fs as withoutPhysicalNameCopies, go as configBooleanRefusal, hc as rewriteTemplateAssetReferences, hi as s3BucketWebsiteUrl, ho as coerceCfnInteger, in as getCurrentProducerRegions, ir as acquireIdempotencyToken, jl as describeFileReadFailure, ko as lambdaFunctionNameForMask, kr as unchangedBehindSecretReference, kt as getCurrentNestedStackContext, l as listNestedTemplateRows, ln as redactedDeleteAddressSkip, lo as WARM_THROUGHPUT_MEMBERS, lr as refuseMalformedDesiredTags, ls as redactSecretsForState, mi as s3BucketRegionalDomainName, mo as coerceCfnBoolean, ms as dynamicReferenceTokens, nr as reserveStackCreateToken, nt as getPriorAttempts, oi as isSettledInstanceState, on as REDACTED_DELETE_ADDRESS_SKIP_REASON, or as DBPROXY_TAG_OPTIONS, os as markSameGenerationBag, pi as s3BucketDualStackDomainName, po as toFiniteNumber, pr as stringifyIfAssigned, q as resolveDynamoDbDeleteBudgetMs, rt as markRefusedBeforeApplying, s as findNestedTemplateTreeDefect, sn as isRedactedRecordedValue, sr as planTagDiff, ss as recordReferenceProvenanceEntry, t as DeployEngine, tt as isTruthyCfnBoolean, u as renderNestedTemplateTreeDefect, uc as stringifyValue, uo as coerceWarmThroughput$1, ur as tagMapAsList, va as refuseMalformedNestedChildOutputs, vo as configStringRefusal, x as isAccessDeniedError, xl as derivePartitionAndUrlSuffix, xo as requireConfigArray, xs as physicalNameCopiesOf, yo as readConfigString, zr as ec2InstanceProtectionSite } from "./deploy-engine-DWIbDQdg.js";
6
+ import { n as collectInlinePolicyNamesManagedBySiblings, r as IamCreateClientCache, t as IAMRoleProvider } from "./iam-role-provider-DTQlG8qe.js";
7
+ import { a as canonicalizeIpProtocolValue, i as resolveSecretDerivedPrincipals, n as runDestroyForStack, o as resolvedResourceTimeoutMs, r as isResolvableSecretPrincipalList, t as canonicalizeIpv4Cidr } from "./program-B4_qJpAO.js";
8
+ import { RDSProvider } from "./rds-provider-B9gz-giS.js";
9
+ import { NeptuneProvider } from "./neptune-provider-Bkrw65eO.js";
10
+ import { ASGProvider } from "./asg-provider-BtUUjRnI.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";
@@ -571,6 +571,11 @@ const principalsOf = (bag) => readPrincipalLists({
571
571
  });
572
572
  const PRINCIPAL_NAMES = "group / role / user names";
573
573
  const AWS_MANAGED_POLICY_ARN_RE = /^arn:aws[a-z0-9-]*:iam::aws:/;
574
+ const MANAGED_POLICY_TYPE = "AWS::IAM::ManagedPolicy";
575
+ const CUSTOMER_POLICY_ARN_RE = /^(arn:aws[a-z0-9-]*:iam::\d{12}):policy\/(?:[!-~]{0,510}\/)?([\w+=,.@-]{1,128})$/;
576
+ function policyIdentityToken(id) {
577
+ return typeof id === "string" && id !== "" ? id : void 0;
578
+ }
574
579
  var IAMManagedPolicyProvider = class {
575
580
  iamClient;
576
581
  createClient = new IamCreateClientCache(() => this.iamClient);
@@ -604,6 +609,7 @@ var IAMManagedPolicyProvider = class {
604
609
  if ("malformed" in principals) throw new ProvisioningError(`${principals.malformed.join(" / ")} of IAM managed policy ${logicalId} is not a list of IAM names — no managed policy was created or attached`, resourceType, logicalId);
605
610
  const policyDoc = typeof policyDocument === "string" ? policyDocument : JSON.stringify(policyDocument);
606
611
  let leftBehindArn;
612
+ let createdPolicyIdentity;
607
613
  try {
608
614
  const createParams = {
609
615
  PolicyName: policyName,
@@ -612,9 +618,11 @@ var IAMManagedPolicyProvider = class {
612
618
  if (properties["Description"]) createParams.Description = properties["Description"];
613
619
  if (properties["Path"]) createParams.Path = properties["Path"];
614
620
  if (tags.length > 0) createParams.Tags = tags;
615
- const policyArn = (await (await this.createClient.get()).send(new CreatePolicyCommand(createParams))).Policy?.Arn;
621
+ const response = await (await this.createClient.get()).send(new CreatePolicyCommand(createParams));
622
+ const policyArn = response.Policy?.Arn;
616
623
  if (!policyArn) throw new ProvisioningError(`CreatePolicy succeeded but no Arn returned for ${logicalId}`, resourceType, logicalId, policyName);
617
624
  leftBehindArn = policyArn;
625
+ createdPolicyIdentity = policyIdentityToken(response.Policy?.PolicyId);
618
626
  log.debug(`Created IAM managed policy: ${v(policyArn)}`);
619
627
  try {
620
628
  await this.attachToPrincipals(policyArn, principals.lists.Groups, principals.lists.Roles, principals.lists.Users, log);
@@ -636,7 +644,7 @@ var IAMManagedPolicyProvider = class {
636
644
  attributes: { PolicyArn: policyArn }
637
645
  };
638
646
  } catch (error) {
639
- const markLeftBehind = (e) => leftBehindArn !== void 0 ? markCreatedBeforeFailure(e, logicalId, resourceType, leftBehindArn) : e;
647
+ const markLeftBehind = (e) => leftBehindArn !== void 0 ? markCreatedBeforeFailure(e, logicalId, resourceType, leftBehindArn, createdPolicyIdentity) : e;
640
648
  if (error instanceof CdkdError) {
641
649
  markLeftBehind(error);
642
650
  throw error;
@@ -764,9 +772,7 @@ var IAMManagedPolicyProvider = class {
764
772
  await this.iamClient.send(new GetPolicyCommand({ PolicyArn: physicalId }));
765
773
  } catch (error) {
766
774
  if (error instanceof NoSuchEntityException) {
767
- const clientRegion = await this.iamClient.config.region();
768
- assertRegionMatch(clientRegion, context?.expectedRegion, resourceType, logicalId, physicalId);
769
- this.logger.debug(mask(`Managed policy ${physicalId} does not exist, skipping deletion`));
775
+ await this.goneOnDelete(logicalId, physicalId, resourceType, context, mask);
770
776
  return;
771
777
  }
772
778
  throw error;
@@ -776,10 +782,20 @@ var IAMManagedPolicyProvider = class {
776
782
  await this.iamClient.send(new DeletePolicyCommand({ PolicyArn: physicalId }));
777
783
  this.logger.debug(`Successfully deleted IAM managed policy ${logicalId}`);
778
784
  } catch (error) {
785
+ if (error instanceof NoSuchEntityException) {
786
+ await this.goneOnDelete(logicalId, physicalId, resourceType, context, mask);
787
+ return;
788
+ }
779
789
  const cause = error instanceof Error ? error : void 0;
780
790
  throw this.wrapMaskedError(mask, error, (text) => new ProvisioningError(`Failed to delete IAM managed policy ${logicalId}: ${text}`, resourceType, logicalId, physicalId, cause));
781
791
  }
782
792
  }
793
+ async goneOnDelete(logicalId, physicalId, resourceType, context, mask) {
794
+ const clientRegion = await this.iamClient.config.region();
795
+ assertRegionMatch(clientRegion, context?.expectedRegion, resourceType, logicalId, physicalId);
796
+ if (context?.failedCreateOrphan === true) this.logger.info(mask(safeMsg` IAM managed policy ${physicalId} (${logicalId}), which a failed deploy created, is already gone; nothing to delete`));
797
+ else this.logger.debug(mask(`Managed policy ${physicalId} does not exist, skipping deletion`));
798
+ }
783
799
  async getAttribute(physicalId, _resourceType, attributeName) {
784
800
  if (attributeName === "PolicyArn") return physicalId;
785
801
  }
@@ -877,6 +893,43 @@ var IAMManagedPolicyProvider = class {
877
893
  }
878
894
  return null;
879
895
  }
896
+ async isSameResource(journaledPhysicalId, record, resourceType, context) {
897
+ if (resourceType !== MANAGED_POLICY_TYPE) return "unknown";
898
+ const journaled = CUSTOMER_POLICY_ARN_RE.exec(journaledPhysicalId);
899
+ const recorded = CUSTOMER_POLICY_ARN_RE.exec(record.physicalId);
900
+ if (journaled === null || recorded === null) return "unknown";
901
+ if (journaledPhysicalId === record.physicalId) return "same";
902
+ if (journaled[1] !== recorded[1]) return "unknown";
903
+ if (journaled[2].toLowerCase() === recorded[2].toLowerCase()) return "unknown";
904
+ if (await this.iamClient.config.region() !== context.expectedRegion) return "unknown";
905
+ const recordId = await this.readPolicyIdIfExists(record.physicalId);
906
+ if (recordId === void 0) return "unknown";
907
+ const journaledId = await this.readPolicyIdIfExists(journaledPhysicalId);
908
+ if (journaledId === void 0) return "different";
909
+ return journaledId === recordId ? "same" : "different";
910
+ }
911
+ async resourceIdentity(physicalId, resourceType, context) {
912
+ if (resourceType !== MANAGED_POLICY_TYPE || !CUSTOMER_POLICY_ARN_RE.test(physicalId)) return;
913
+ if (await this.iamClient.config.region() !== context.expectedRegion) return void 0;
914
+ const id = await this.readPolicyIdIfExists(physicalId);
915
+ return id === void 0 ? RESOURCE_NOT_FOUND : id;
916
+ }
917
+ async readPolicyIdIfExists(policyArn) {
918
+ let answeredArn;
919
+ let id;
920
+ try {
921
+ const response = await this.iamClient.send(new GetPolicyCommand({ PolicyArn: policyArn }));
922
+ answeredArn = response.Policy?.Arn;
923
+ id = response.Policy?.PolicyId;
924
+ } catch (error) {
925
+ if (error instanceof NoSuchEntityException) return void 0;
926
+ throw error;
927
+ }
928
+ if (answeredArn !== policyArn) throw new Error("IAM answered for another managed policy than the one asked for");
929
+ const token = policyIdentityToken(id);
930
+ if (token === void 0) throw new Error("IAM returned no PolicyId");
931
+ return token;
932
+ }
880
933
  async attachToPrincipals(policyArn, groups, roles, users, log) {
881
934
  const { value: v } = log;
882
935
  if (groups && Array.isArray(groups)) for (const groupName of groups) {
@@ -1113,6 +1166,13 @@ function recordedNonRootPath(arn) {
1113
1166
 
1114
1167
  //#endregion
1115
1168
  //#region src/provisioning/providers/iam-instance-profile-provider.ts
1169
+ const INSTANCE_PROFILE_TYPE = "AWS::IAM::InstanceProfile";
1170
+ function isInstanceProfileName(id) {
1171
+ return /^[\w+=,.@-]{1,128}$/.test(id);
1172
+ }
1173
+ function instanceProfileIdentityToken(id) {
1174
+ return typeof id === "string" && id !== "" ? id : void 0;
1175
+ }
1116
1176
  var IAMInstanceProfileProvider = class {
1117
1177
  iamClient;
1118
1178
  createClient = new IamCreateClientCache(() => this.iamClient);
@@ -1139,12 +1199,14 @@ var IAMInstanceProfileProvider = class {
1139
1199
  if ("malformed" in principals) throw new ProvisioningError(`Roles of IAM instance profile ${logicalId} is not a list of IAM role names — no instance profile was created`, resourceType, logicalId);
1140
1200
  const roles = principals.lists.Roles;
1141
1201
  let leftBehind = false;
1202
+ let createdProfileIdentity;
1142
1203
  try {
1143
1204
  const response = await (await this.createClient.get()).send(new CreateInstanceProfileCommand({
1144
1205
  InstanceProfileName: instanceProfileName,
1145
1206
  Path: path
1146
1207
  }));
1147
1208
  leftBehind = true;
1209
+ createdProfileIdentity = instanceProfileIdentityToken(response.InstanceProfile?.InstanceProfileId);
1148
1210
  log.debug(`Created IAM instance profile: ${v(instanceProfileName)}`);
1149
1211
  const attachedRoles = [];
1150
1212
  try {
@@ -1183,7 +1245,7 @@ var IAMInstanceProfileProvider = class {
1183
1245
  } catch (error) {
1184
1246
  const cause = error instanceof Error ? error : void 0;
1185
1247
  const thrown = this.wrapMaskedError(log.mask, error, (text) => new ProvisioningError(`Failed to create IAM instance profile ${logicalId}: ${text}`, resourceType, logicalId, instanceProfileName, cause));
1186
- if (leftBehind) markCreatedBeforeFailure(thrown, logicalId, resourceType, instanceProfileName);
1248
+ if (leftBehind) markCreatedBeforeFailure(thrown, logicalId, resourceType, instanceProfileName, createdProfileIdentity);
1187
1249
  throw thrown;
1188
1250
  }
1189
1251
  }
@@ -1258,7 +1320,7 @@ var IAMInstanceProfileProvider = class {
1258
1320
  if (error instanceof NoSuchEntityException) {
1259
1321
  const clientRegion = await this.iamClient.config.region();
1260
1322
  assertRegionMatch(clientRegion, context?.expectedRegion, resourceType, logicalId, physicalId);
1261
- this.logger.debug(`Instance profile ${physicalId} does not exist, skipping deletion`);
1323
+ this.logGoneOnDelete(logicalId, physicalId, context);
1262
1324
  return;
1263
1325
  }
1264
1326
  throw error;
@@ -1278,13 +1340,51 @@ var IAMInstanceProfileProvider = class {
1278
1340
  if (error instanceof NoSuchEntityException) {
1279
1341
  const clientRegion = await this.iamClient.config.region();
1280
1342
  assertRegionMatch(clientRegion, context?.expectedRegion, resourceType, logicalId, physicalId);
1281
- this.logger.debug(`Instance profile ${physicalId} does not exist, skipping deletion`);
1343
+ this.logGoneOnDelete(logicalId, physicalId, context);
1282
1344
  return;
1283
1345
  }
1284
1346
  const cause = error instanceof Error ? error : void 0;
1285
1347
  throw new ProvisioningError(`Failed to delete IAM instance profile ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
1286
1348
  }
1287
1349
  }
1350
+ logGoneOnDelete(logicalId, physicalId, context) {
1351
+ if (context?.failedCreateOrphan === true) this.logger.info(safeMsg` IAM instance profile ${physicalId} (${logicalId}), which a failed deploy created, is already gone; nothing to delete`);
1352
+ else this.logger.debug(`Instance profile ${physicalId} does not exist, skipping deletion`);
1353
+ }
1354
+ async isSameResource(journaledPhysicalId, record, resourceType, context) {
1355
+ if (resourceType !== INSTANCE_PROFILE_TYPE) return "unknown";
1356
+ if (!isInstanceProfileName(journaledPhysicalId) || !isInstanceProfileName(record.physicalId)) return "unknown";
1357
+ if (journaledPhysicalId === record.physicalId) return "same";
1358
+ if (journaledPhysicalId.toLowerCase() === record.physicalId.toLowerCase()) return "unknown";
1359
+ if (await this.iamClient.config.region() !== context.expectedRegion) return "unknown";
1360
+ const recordId = await this.readIdIfExists(record.physicalId);
1361
+ if (recordId === void 0) return "unknown";
1362
+ const journaledId = await this.readIdIfExists(journaledPhysicalId);
1363
+ if (journaledId === void 0) return "different";
1364
+ return journaledId === recordId ? "same" : "different";
1365
+ }
1366
+ async resourceIdentity(physicalId, resourceType, context) {
1367
+ if (resourceType !== INSTANCE_PROFILE_TYPE || !isInstanceProfileName(physicalId)) return;
1368
+ if (await this.iamClient.config.region() !== context.expectedRegion) return void 0;
1369
+ const id = await this.readIdIfExists(physicalId);
1370
+ return id === void 0 ? RESOURCE_NOT_FOUND : id;
1371
+ }
1372
+ async readIdIfExists(name) {
1373
+ let answeredName;
1374
+ let id;
1375
+ try {
1376
+ const response = await this.iamClient.send(new GetInstanceProfileCommand({ InstanceProfileName: name }));
1377
+ answeredName = response.InstanceProfile?.InstanceProfileName;
1378
+ id = response.InstanceProfile?.InstanceProfileId;
1379
+ } catch (error) {
1380
+ if (error instanceof NoSuchEntityException) return void 0;
1381
+ throw error;
1382
+ }
1383
+ if (answeredName !== name) throw new Error("IAM answered for another instance profile than the one asked for");
1384
+ const token = instanceProfileIdentityToken(id);
1385
+ if (token === void 0) throw new Error("IAM returned no InstanceProfileId");
1386
+ return token;
1387
+ }
1288
1388
  async readCurrentState(physicalId, _logicalId, _resourceType) {
1289
1389
  let profile;
1290
1390
  try {
@@ -44544,6 +44644,7 @@ var NestedStackProvider = class {
44544
44644
  ...deleteContext?.removeProtection === true && { removeProtection: true },
44545
44645
  ...deleteContext?.resolveSecretDerivedPrincipals !== void 0 && { resolveSecretDerivedPrincipals: { inheritedProducerRegions: deleteContext.resolveSecretDerivedPrincipals.importedProducerRegions } },
44546
44646
  ...deleteContext?.stackDestroy === true && { stackDestroy: true },
44647
+ ...ctx.destroyOptions?.purgeStateHistory === true && { purgeStateHistory: true },
44547
44648
  ...childNoEchoReresolver !== void 0 && { noEchoReresolver: childNoEchoReresolver },
44548
44649
  ...(ctx.destroyOptions?.skipFinalSnapshot === true || ctx.options?.skipFinalSnapshot === true) && { skipFinalSnapshot: true },
44549
44650
  ...ctx.destroyOptions?.resourceWarnAfterMs !== void 0 && { resourceWarnAfterMs: ctx.destroyOptions.resourceWarnAfterMs },
@@ -45123,4 +45224,4 @@ var ACMCertificateProvider = class {
45123
45224
 
45124
45225
  //#endregion
45125
45226
  export { ACMCertificateProvider, ASGProvider, AgentCoreBrowserProvider, AgentCoreCodeInterpreterProvider, AgentCoreEvaluatorProvider, AgentCoreRuntimeProvider, ApiGatewayProvider, ApiGatewayV2Provider, AppSyncProvider, BudgetsBudgetProvider, CloudFrontDistributionProvider, CloudFrontOACProvider, CloudFrontOAIProvider, CloudTrailProvider, CloudWatchAlarmProvider, CloudWatchAnomalyDetectorProvider, CodeBuildProvider, CodeCommitRepositoryProvider, CognitoUserPoolProvider, DLMLifecyclePolicyProvider, DocDBProvider, DocDBSubnetGroupProvider, DynamoDBGlobalTableProvider, DynamoDBTableProvider, EC2Provider, ECRProvider, ECSProvider, EFSProvider, ELBv2Provider, EMRClusterProvider, EMRInstanceFleetConfigProvider, EMRInstanceGroupConfigProvider, ElastiCacheProvider, EventBridgeBusProvider, EventBridgeRuleProvider, FSxFileSystemProvider, FirehoseProvider, GlueConnectionProvider, GlueCrawlerProvider, GlueJobProvider, GlueProvider, GlueSecurityConfigurationProvider, GlueTriggerProvider, GlueWorkflowProvider, IAMAccessKeyProvider, IAMInstanceProfileProvider, IAMManagedPolicyProvider, IAMPolicyProvider, IAMRoleProvider, IAMUserGroupProvider, KMSProvider, KinesisStreamConsumerProvider, KinesisStreamProvider, LambdaEventInvokeConfigProvider, LambdaEventSourceMappingProvider, LambdaFunctionProvider, LambdaLayerVersionProvider, LambdaMicrovmImageProvider, LambdaPermissionProvider, LambdaUrlProvider, LogsLogGroupProvider, NeptuneProvider, NestedStackProvider, PipesPipeProvider, RDSDBProxyEndpointProvider, RDSDBProxyProvider, RDSDBProxyTargetGroupProvider, RDSProvider, Route53Provider, S3BucketPolicyProvider, S3BucketProvider, S3DirectoryBucketProvider, S3TablesProvider, S3VectorsProvider, SNSSubscriptionProvider, SNSTopicPolicyProvider, SNSTopicProvider, SQSQueuePolicyProvider, SQSQueueProvider, SSMParameterProvider, SchedulerScheduleProvider, SecretsManagerSecretProvider, ServiceDiscoveryProvider, StepFunctionsProvider, WAFv2WebACLProvider, WaitConditionHandleProvider };
45126
- //# sourceMappingURL=provider-classes-WJRB6zvO.js.map
45227
+ //# sourceMappingURL=provider-classes-SNKb1al7.js.map