@go-to-k/cdkd 0.299.1 → 0.299.3

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-BxW2FkQz.js → asg-provider-CsBxbRlH.js} +2 -2
  2. package/dist/{asg-provider-BxW2FkQz.js.map → asg-provider-CsBxbRlH.js.map} +1 -1
  3. package/dist/cli.js +2 -2
  4. package/dist/{deploy-engine-CZUhJ1IZ.js → deploy-engine-DEBgHf6Z.js} +4 -4
  5. package/dist/{deploy-engine-CZUhJ1IZ.js.map → deploy-engine-DEBgHf6Z.js.map} +1 -1
  6. package/dist/iam-policy-targets-Pn2m0R67.js.map +1 -1
  7. package/dist/{iam-role-provider-C24I_FvR.js → iam-role-provider-CXfEJz94.js} +2 -2
  8. package/dist/{iam-role-provider-C24I_FvR.js.map → iam-role-provider-CXfEJz94.js.map} +1 -1
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +2 -2
  12. package/dist/{neptune-provider-D7sAjt4U.js → neptune-provider-C81KkPPG.js} +2 -2
  13. package/dist/{neptune-provider-D7sAjt4U.js.map → neptune-provider-C81KkPPG.js.map} +1 -1
  14. package/dist/{program-w-kAH85e.js → program-B4pWdUfl.js} +46 -8
  15. package/dist/program-B4pWdUfl.js.map +1 -0
  16. package/dist/{provider-classes-Xrt4DIC7.js → provider-classes-BFHOZwKd.js} +129 -22
  17. package/dist/provider-classes-BFHOZwKd.js.map +1 -0
  18. package/dist/{rds-provider-Bz8JUYBp.js → rds-provider-d15q7Rp5.js} +2 -2
  19. package/dist/{rds-provider-Bz8JUYBp.js.map → rds-provider-d15q7Rp5.js.map} +1 -1
  20. package/dist/{version-DMqEiJIt.js → version-B7Gzz6TR.js} +2 -2
  21. package/dist/{version-DMqEiJIt.js.map → version-B7Gzz6TR.js.map} +1 -1
  22. package/package.json +1 -1
  23. package/dist/program-w-kAH85e.js.map +0 -1
  24. package/dist/provider-classes-Xrt4DIC7.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-CZUhJ1IZ.js";
6
- import { n as collectInlinePolicyNamesManagedBySiblings, r as IamCreateClientCache, t as IAMRoleProvider } from "./iam-role-provider-C24I_FvR.js";
7
- import { a as canonicalizeIpProtocolValue, i as resolveSecretDerivedPrincipals, n as runDestroyForStack, o as resolvedResourceTimeoutMs, r as isResolvableSecretPrincipalList, t as canonicalizeIpv4Cidr } from "./program-w-kAH85e.js";
8
- import { RDSProvider } from "./rds-provider-Bz8JUYBp.js";
9
- import { NeptuneProvider } from "./neptune-provider-D7sAjt4U.js";
10
- import { ASGProvider } from "./asg-provider-BxW2FkQz.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-DEBgHf6Z.js";
6
+ import { n as collectInlinePolicyNamesManagedBySiblings, r as IamCreateClientCache, t as IAMRoleProvider } from "./iam-role-provider-CXfEJz94.js";
7
+ import { a as canonicalizeIpProtocolValue, i as resolveSecretDerivedPrincipals, n as runDestroyForStack, o as resolvedResourceTimeoutMs, r as isResolvableSecretPrincipalList, t as canonicalizeIpv4Cidr } from "./program-B4pWdUfl.js";
8
+ import { RDSProvider } from "./rds-provider-d15q7Rp5.js";
9
+ import { NeptuneProvider } from "./neptune-provider-C81KkPPG.js";
10
+ import { ASGProvider } from "./asg-provider-CsBxbRlH.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";
@@ -379,7 +379,7 @@ var IAMPolicyProvider = class {
379
379
  const values = Object.fromEntries(malformedKinds.map((k) => [k, recordedLists[k]]));
380
380
  const memo = optIn.retryMemo;
381
381
  const reused = memo?.resolved;
382
- const resolved = reused ?? await resolveSecretDerivedPrincipals(values, context?.expectedRegion, optIn.importedProducerRegions);
382
+ const resolved = reused ?? await resolveSecretDerivedPrincipals(values, context?.expectedRegion, optIn.importedProducerRegions, optIn.recordedRegions);
383
383
  if (resolved && memo) memo.resolved = resolved;
384
384
  if (resolved) {
385
385
  roles = resolved.lists["Roles"] ?? targets.wellFormed.roles;
@@ -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 {
@@ -2403,7 +2503,7 @@ var IAMUserGroupProvider = class {
2403
2503
  const resolutionAttempted = "malformed" in read && optIn !== void 0 && isResolvableSecretPrincipalList(properties["Users"]);
2404
2504
  if (resolutionAttempted) {
2405
2505
  const reused = memo?.resolved;
2406
- const resolved = reused ?? await resolveSecretDerivedPrincipals({ Users: properties["Users"] }, context?.expectedRegion, optIn.importedProducerRegions);
2506
+ const resolved = reused ?? await resolveSecretDerivedPrincipals({ Users: properties["Users"] }, context?.expectedRegion, optIn.importedProducerRegions, optIn.recordedRegions);
2407
2507
  if (resolved && memo) memo.resolved = resolved;
2408
2508
  if (resolved?.lists["Users"] !== void 0) {
2409
2509
  users = resolved.lists["Users"];
@@ -5335,8 +5435,9 @@ var S3BucketPolicyProvider = class {
5335
5435
  throw new ProvisioningError(`Failed to create S3 bucket policy ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, bucketName, cause);
5336
5436
  }
5337
5437
  }
5338
- async update(logicalId, physicalId, resourceType, properties, _previousProperties) {
5438
+ async update(logicalId, physicalId, resourceType, properties, _previousProperties, context) {
5339
5439
  this.logger.debug(`Updating S3 bucket policy ${logicalId}: ${physicalId}`);
5440
+ assertRegionMatch(context?.expectedRegion ? await this.s3Client.config.region() : void 0, context?.expectedRegion, resourceType, logicalId, physicalId, "pre-update");
5340
5441
  const bucketName = properties["Bucket"];
5341
5442
  const policyDocument = properties["PolicyDocument"];
5342
5443
  if (!bucketName) throw new ProvisioningError(`Bucket is required for S3 bucket policy ${logicalId}`, resourceType, logicalId, physicalId);
@@ -5591,8 +5692,9 @@ var SQSQueueProvider = class {
5591
5692
  throw new ProvisioningError(`Failed to create SQS queue ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, queueName, cause);
5592
5693
  }
5593
5694
  }
5594
- async update(logicalId, physicalId, resourceType, properties, previousProperties) {
5695
+ async update(logicalId, physicalId, resourceType, properties, previousProperties, context) {
5595
5696
  this.logger.debug(`Updating SQS queue ${logicalId}: ${physicalId}`);
5697
+ assertRegionMatch(context?.expectedRegion ? await this.sqsClient.config.region() : void 0, context?.expectedRegion, resourceType, logicalId, physicalId, "pre-update");
5596
5698
  refuseMalformedDesiredTags(properties["Tags"], resourceType, logicalId, physicalId);
5597
5699
  try {
5598
5700
  const attributes = {};
@@ -13547,6 +13649,7 @@ var SSMParameterProvider = class SSMParameterProvider {
13547
13649
  if (properties["Tier"] !== void 0) putParams.Tier = properties["Tier"];
13548
13650
  const policies = ssmPoliciesParameter(properties["Policies"]);
13549
13651
  if (policies !== void 0) putParams.Policies = policies;
13652
+ else if (context?.desiredFromAwsReadback === true && !["[]", void 0].includes(ssmPoliciesParameter(previousProperties["Policies"])) && context.declaredEmptyProperties?.has("Policies") === true) putParams.Policies = SSM_CLEAR_POLICIES;
13550
13653
  if (properties["DataType"] !== void 0) putParams.DataType = properties["DataType"];
13551
13654
  await this.ssmClient.send(new PutParameterCommand(putParams));
13552
13655
  const plan = planTagDiff(tagMapAsList(previousProperties["Tags"]), tagMapAsList(properties["Tags"]));
@@ -13692,6 +13795,7 @@ var SSMParameterProvider = class SSMParameterProvider {
13692
13795
  return null;
13693
13796
  }
13694
13797
  };
13798
+ const SSM_CLEAR_POLICIES = "[{}]";
13695
13799
  function ssmPoliciesParameter(policies) {
13696
13800
  if (policies === void 0 || policies === null || policies === "") return void 0;
13697
13801
  if (typeof policies === "string") return policies;
@@ -13875,8 +13979,9 @@ var EventBridgeRuleProvider = class {
13875
13979
  throw thrown;
13876
13980
  }
13877
13981
  }
13878
- async update(logicalId, physicalId, resourceType, properties, previousProperties) {
13982
+ async update(logicalId, physicalId, resourceType, properties, previousProperties, context) {
13879
13983
  this.logger.debug(`Updating EventBridge rule ${logicalId}: ${physicalId}`);
13984
+ assertRegionMatch(context?.expectedRegion ? await this.eventBridgeClient.config.region() : void 0, context?.expectedRegion, resourceType, logicalId, physicalId, "pre-update");
13880
13985
  refuseMalformedDesiredTags(properties["Tags"], resourceType, logicalId, physicalId);
13881
13986
  const ruleName = properties["Name"] || generateResourceName(logicalId, { maxLength: 64 });
13882
13987
  const newTargets = properties["Targets"];
@@ -14190,7 +14295,8 @@ var EventBridgeBusProvider = class {
14190
14295
  throw new ProvisioningError(`Failed to create EventBus ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, void 0, cause);
14191
14296
  }
14192
14297
  }
14193
- async update(logicalId, physicalId, resourceType, properties, previousProperties) {
14298
+ async update(logicalId, physicalId, resourceType, properties, previousProperties, context) {
14299
+ assertRegionMatch(context?.expectedRegion ? await this.eventBridgeClient.config.region() : void 0, context?.expectedRegion, resourceType, logicalId, physicalId, "pre-update");
14194
14300
  refuseMalformedDesiredTags(properties["Tags"], resourceType, logicalId, physicalId);
14195
14301
  try {
14196
14302
  return await this.applyUpdate(logicalId, physicalId, resourceType, properties, previousProperties);
@@ -22143,8 +22249,9 @@ var StepFunctionsProvider = class {
22143
22249
  throw new ProvisioningError(`Failed to create Step Functions state machine ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, stateMachineName, cause);
22144
22250
  }
22145
22251
  }
22146
- async update(logicalId, physicalId, resourceType, properties, previousProperties) {
22252
+ async update(logicalId, physicalId, resourceType, properties, previousProperties, context) {
22147
22253
  this.logger.debug(`Updating Step Functions state machine ${logicalId}: ${physicalId}`);
22254
+ assertRegionMatch(context?.expectedRegion ? await this.getClient().config.region() : void 0, context?.expectedRegion, resourceType, logicalId, physicalId, "pre-update");
22148
22255
  refuseMalformedDesiredTags(properties["Tags"], resourceType, logicalId, physicalId);
22149
22256
  try {
22150
22257
  const definitionString = await this.buildDefinitionString(properties);
@@ -45116,4 +45223,4 @@ var ACMCertificateProvider = class {
45116
45223
 
45117
45224
  //#endregion
45118
45225
  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 };
45119
- //# sourceMappingURL=provider-classes-Xrt4DIC7.js.map
45226
+ //# sourceMappingURL=provider-classes-BFHOZwKd.js.map