@cdkd/cli 0.346.0 → 0.348.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ambient-client-defaults-w6GrD1cQ.js → ambient-client-defaults-7acjxfyN.js} +13 -6
- package/dist/ambient-client-defaults-7acjxfyN.js.map +1 -0
- package/dist/{asg-provider-Bu7rz365.js → asg-provider-r1ojkIvF.js} +6 -6
- package/dist/{asg-provider-Bu7rz365.js.map → asg-provider-r1ojkIvF.js.map} +1 -1
- package/dist/{aws-client-defaults-DP5k4Mfi.js → aws-client-defaults-DAebi99J.js} +13 -5
- package/dist/{aws-client-defaults-DP5k4Mfi.js.map → aws-client-defaults-DAebi99J.js.map} +1 -1
- package/dist/{aws-clients-CUCH-WCd.js → aws-clients-DOkPjjAW.js} +2 -2
- package/dist/{aws-clients-CUCH-WCd.js.map → aws-clients-DOkPjjAW.js.map} +1 -1
- package/dist/cli.js +2 -2
- package/dist/{db-instance-modify-retry-CY94H9jp.js → db-instance-modify-retry-BaSXzEMy.js} +4 -4
- package/dist/{db-instance-modify-retry-CY94H9jp.js.map → db-instance-modify-retry-BaSXzEMy.js.map} +1 -1
- package/dist/{deploy-engine-BocT17az.js → deploy-engine-2XoVAu4C.js} +354 -77
- package/dist/deploy-engine-2XoVAu4C.js.map +1 -0
- package/dist/{ecr-uri-Cg53WsUz.js → ecr-uri-C1_heDAt.js} +3 -3
- package/dist/{ecr-uri-Cg53WsUz.js.map → ecr-uri-C1_heDAt.js.map} +1 -1
- package/dist/{iam-role-provider-_bvctXgr.js → iam-role-provider-BnLtoKcW.js} +6 -6
- package/dist/{iam-role-provider-_bvctXgr.js.map → iam-role-provider-BnLtoKcW.js.map} +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/{aws-failure-text-jomzO3aT.js → logger-DmQRya0S.js} +148 -59
- package/dist/logger-DmQRya0S.js.map +1 -0
- package/dist/{neptune-provider-CceDOA6q.js → neptune-provider-lzti8HIF.js} +7 -7
- package/dist/{neptune-provider-CceDOA6q.js.map → neptune-provider-lzti8HIF.js.map} +1 -1
- package/dist/{program-DM3nrEl9.js → program-DSlYCm_d.js} +1152 -499
- package/dist/program-DSlYCm_d.js.map +1 -0
- package/dist/{provider-classes-BJRQVOZ0.js → provider-classes-RMTfwJPz.js} +21 -21
- package/dist/provider-classes-RMTfwJPz.js.map +1 -0
- package/dist/{rds-provider-B-TkBvu0.js → rds-provider-COq1pW0G.js} +53 -35
- package/dist/{rds-provider-B-TkBvu0.js.map → rds-provider-COq1pW0G.js.map} +1 -1
- package/dist/{read-replica-IoZoKlpg.js → read-replica-sjvqi8Of.js} +78 -24
- package/dist/read-replica-sjvqi8Of.js.map +1 -0
- package/dist/{update-removal-BjJh8h9m.js → update-removal-D-FspP88.js} +4 -4
- package/dist/{update-removal-BjJh8h9m.js.map → update-removal-D-FspP88.js.map} +1 -1
- package/dist/{version-BdxBmlDu.js → version-DXmr3_M4.js} +2 -2
- package/dist/{version-BdxBmlDu.js.map → version-DXmr3_M4.js.map} +1 -1
- package/package.json +3 -2
- package/dist/ambient-client-defaults-w6GrD1cQ.js.map +0 -1
- package/dist/aws-failure-text-jomzO3aT.js.map +0 -1
- package/dist/deploy-engine-BocT17az.js.map +0 -1
- package/dist/program-DM3nrEl9.js.map +0 -1
- package/dist/provider-classes-BJRQVOZ0.js.map +0 -1
- package/dist/read-replica-IoZoKlpg.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as getCdkdVersion } from "./version-
|
|
2
|
-
import { $ as
|
|
3
|
-
import { $c as recordedNoEchoValuesOf, $i as isFinalSnapshotError, $l as hasReadableExportSet, $n as updatePartialMessage, $o as isStatefulRecreateTargetSync, $r as DEFAULT_RESOURCE_TIMEOUT_MS, $s as malformedExportNamesWarning, $t as NESTED_PENDING_PARENT_REASON, $u as isMalformedEnvKey, A as PROTECTION_PROPERTY_BY_TYPE, Ad as canonicalizeRegion, Ai as withAttemptedItemsMasked, An as rollbackOrphanIds, Ar as retiredNameGenerationsLeaving, As as refuseMalformedResourceAttributesForOrphan, Au as ensureAssetStorage, Bc as DagBuilder, Bd as hasOwnKey, Bi as secretNamedRecordNeedles, Bl as recordNoEchoAttributeValues, Bn as propertiesChangedReason, Bo as keepsSecretReferenceToken, Br as exportAliasCollisionScrubWarning, Bs as malformedResourcePropertiesWarning, Bt as refactorMarkerRefusalMessage, Bu as buildDockerImage, C as refusePendingMovesOut, Ca as TemplateNoEchoReresolver, Cc as displayLogicalId, Cd as MIGRATE_TMP_PREFIX, Ci as green, Cl as DYNAMIC_REFERENCE_TOKEN_SCAN, Cn as DeploymentEventsStore, Co as isUnboundTemplateParameter, Cr as removeProtectionTypeList, Cs as unpreviewableOrphanRecords, Cu as stringifyValue, D as diffSecurity, Da as withPrintingSecrets, Dc as findHandledUnwrittenCreateOnly, Dd as decodeListingKey, Di as noEchoComparisonForTemplate, Dl as pathCrossesDottedKey, Dn as findRefactorHints, Do as isStalePlaceholderArnAttribute, Dr as nameScopeOf, Ds as malformedLocalResourcesWarning, Du as loadPublishableAssetManifest, E as serviceTokenBlockingReason, Ec as findActionableSdkUnwired, Ed as CUSTOM_RESOURCE_RESPONSE_OBJECT_DESCRIPTION, Ei as noEchoAttributeNamesOf, El as spelledKeysOf, En as formatDestructiveChange, Eo as cfnRefValueFromPhysicalId, Er as nameGenerationHighWaterOf, Es as malformedLocalResourceEntriesWarning, Eu as createAssetRedirectResolver, Fa as UNSPECIFIED_SKIP_REASON, Fd as processStackMessages, Fi as namingSecretsWithRecordedNoEcho, Fl as splitGetAttStringForm, Fn as differingRemedy, Fo as getAccountInfo, Fr as namesAnyDeclaredParameter, Fs as refuseMalformedResourceEntriesForImportSave, Ft as keptForRetainedRecord, Fu as parseBootstrapMarker, Gc as maskReadbackAtCoordinates, Gd as describeFileReadFailure, Gl as isSingleDynamicReferenceToken, Gn as DELETED_RESOURCE_REMEDY, Go as unsettledItemsOf, Gr as exportNameNoEchoParameters, Gs as repairMalformedResourcePropertiesForReadOnly, Gu as redactedCause, Hc as canonicalCoordinates, Hd as nullPrototypeRecord, Hi as storedSecretNameNeedles, Hl as recordProvenPublicExpression, Hn as referencedLogicalIds, Ho as INTRINSIC_KEYS, Hr as secretBearingStateKeyWarning, Hs as refuseMalformedResourcePropertiesForDrift, Ht as sameMove, Hu as describeDockerCapturedOutput, Ia as deleteIndeterminateGuards, Id as describeJsonParseFailure, Ii as orphanRecordsPrintingBag, Il as carriesSecretMask, In as isPairableType, Io as isImpossibleEmptyStoredAttribute, Ir as reachableDivergentParameters, Is as refuseMalformedResourceEntriesForOrphan, It as recordRetainedForReadoption, Iu as readBootstrapMarkerBody, Ja as isWaitAbandonedError, Jc as noEchoCoordinatesOf, Jd as resolveAssemblyPath, Ji as ATOMIC_FINAL_SNAPSHOT_TYPES, Jl as S3StateBackend, Jn as withUnprovenUnsettled, Jo as withoutUnsettledProperties, Jr as noEchoParameterValueSeed, Js as malformedOrphansRefusalMessage, Ju as dockerSpawnEnvWithSensitive, Kc as maskWholeValue, Kd as displayAssemblyPath, Ki as secretSegmentsOfState, Kl as LockManager, Kn as recordAfterRollbackUpdate, Ko as unsettledPropertiesOf, Kr as exportNameSecretExposure, Ks as UNREADABLE_ORPHANS_CONTAINER_ROW, Kt as formatResourceLine, Ku as redactedDockerCause, La as deleteLeftInPlace, Ld as parseFailureDebugDetail, Li as secretNamePrintingBag, Ll as provenPublicValue, Ln as looselyEqual, Lo as carriesFetchableDynamicReference, Lr as resourcesNamingDeclaredParameter, Ls as repairMalformedResourceEntriesForReadOnly, Lt as readRefactorMarker, Lu as validateAssetBucketName, M as perType, Ma as setResolvedResourceTimeouts, Mc as hasNoCloudControlHandlers, Md as refuseFailedLookups, Mi as completedReplayEntries, Mn as changedReferenceInDiff, Ms as refuseMalformedResourceEntriesForDeploy, Mt as withResourceDeadline, Mu as assertAssetBucketRegion, N as readProtection, Na as slowCcOperationTimeoutMs, Nd as AssemblyReader, Ni as journaledOrphanPrintingBag, Nl as recordPhysicalNameCopy, Nn as changedReferencePath, No as recordedOutputReferenceRegions, Nr as inheritProducerRegions, Ns as refuseMalformedResourceEntriesForDestroy, Nt as IMPLICIT_DELETE_DEPENDENCIES, Nu as isCrossRegionRedirect, O as recordedProtectionEvidence, Od as expectedOwnerParam, Oi as noEchoExactEchoLeavesOf, Ol as identityKeyFor, On as hintSidesOf, Oo as lacksRecordedTableArn, Or as retiredAfterRollback, Os as malformedResourceEntriesWarning, Ou as rewriteTemplateAssetReferences, Pa as RollbackInlinePolicyWriters, Pd as StageLoadError, Pi as maskEventTextWithBoundBags, Pl as recordNestedStackParameterExpressions, Pn as changedReferenceReason, Po as recordedReferenceRegions, Pr as computeParameterTaint, Ps as refuseMalformedResourceEntriesForImport, Pt as computeImplicitDeleteEdges, Pu as getBootstrapMarkerKey, Qa as poisonRenderedSpellingsCollidingIn, Qc as readsNoEchoSource, Qd as resolveBucketRegion, Qi as effectiveDeletionPolicy, Ql as exportNamesCarriedFrom, Qn as undeclaredEmptyObservedKeys, Qo as isStatefulRecreateTargetForReplace, Qr as bindingSkippedOutputs, Qs as repairMalformedOrphansForReadOnly, Qt as resolvePendingCloudControlRequests, Qu as isDockerClientEnvKey, Ra as deleteSkipReason, Rd as utf8ByteLength, Ri as secretNamePrintingBags, Rl as recordMaskOnlyValue, Rn as mappingPairs, Ro as isNamelessDynamicReferenceError, Rr as WITHHELD_NAME_DISPLAY, Rs as unreadableResourceEntries, Rt as readRefactorMarkerOnce, Ru as validateContainerRepoName, S as pendingMovesRefusalMessage, Sa as customResourceResponseExpirationWarning, Sc as UNREADABLE_RESOURCES_MAP_ROW, Sd as CFN_TEMPLATE_URL_LIMIT, Si as gray, Sn as DeploymentEventsReader, So as coerceParameterTypedValue, Sr as segmentCleanupOptions, Ss as repairMalformedOrphanRecordsForReadOnly, Su as isSensitiveAttributeName, T as findServiceTokenRefusals, Ta as isCustomResourceType$1, Tc as hasReadableResources, Td as uploadCfnTemplate, Ti as yellow, Tl as isUncertifiedBaselineMaskPosition, Tn as findDestructiveChanges, To as AWS_NO_VALUE, Tr as nameGenerationCarriedFrom, Ts as isReadableResourceEntry, Tu as buildAssetRedirectMap, Uc as isMarkedCoordinate, Ud as ownValue, Ui as extractDeploymentEventError, Ul as wholeStringLeavesOf, Un as replayFailedOperations, Ur as secretSafeKeyDisplay, Us as refuseMalformedResourcePropertiesForExport, Ut as updateRefactorMarker, Uu as describeDockerExecFailure, Vc as TemplateParser, Vd as hasPlainPrototype, Vi as stateSecretNameNeedles, Vl as recordNoEchoParameterFreshValue, Vn as proposeRenames, Vo as withSharedDrainBudget, Vr as secretBearing, Vs as refuseMalformedResourcePropertiesForDestroy, Vt as refuseRefactorMarker, Vu as resolveDockerContextDirectory, Wc as maskAtCoordinates, Wd as absoluteAssemblyPathEscape, Wl as WHOLE_DYNAMIC_REFERENCE_PATTERN, Wn as replayRollback, Wo as unsettledItemsField, Wr as carriedExportAliasExposure, Ws as refuseMalformedResourcePropertiesForOrphan, Wu as describeDockerFailure, Xa as IntrinsicFunctionResolver, Xc as noEchoOutputsComparison, Xd as injectedAwsRegionValue, Xi as ccRoutedFinalSnapshotError, Xl as acceptedCreateOnlyDropsOf, Xn as equalModuloMarkedMask, Xo as shownType, Xr as collectPublishedOutputNames, Xs as refuseMalformedOrphans, Xu as partitionSensitiveEnv, Ya as DiffCalculator, Yc as noEchoLeavesOf, Yd as injectAwsRegion, Yi as PRE_DELETE_SNAPSHOT_TYPES, Yl as splitImportedOps, Yn as calculateResourceDrift, Yo as findReplacedReadersOfRecreateTargets, Yr as collectDeclaredOutputNames, Ys as malformedOrphansWarning, Yu as finchSecretArgvRefusal, Za as isAlwaysLiveAttribute, Zi as ccRoutedInstanceTakesNoSnapshot, Zl as describeRegionValueKind, Zn as equalModuloMask, Zo as MULTI_REGION_RECREATE_BLOCKED_TYPES, Zr as isExportAliasCollision, Zs as refuseMalformedOrphansForDestroy, Zt as pendingRequestCount, Zu as warnFinchArgvExposure, _ as listNestedTemplateRows, _a as ccBrokenReason, _c as repairMalformedResourcesForReadOnly, _d as resolveUseCdkBootstrapAssets, _l as errorCauseChain, _n as loadJournaledOrphans, _r as findNestedStackTypeChanges, _s as malformedOrphanRowsKeptWarning, _u as isAccessDenied, a as scanActiveConsumers, ac as refuseMalformedOutputs, ad as getDockerImageBySourceHash, ai as withStackRecords, an as recordDisplacedSkips, ao as assertSendableRoleArn, au as shouldRetainResource, b as hasPendingMovesOut, ba as CUSTOM_RESOURCE_RESPONSE_LIFECYCLE_RULE_ID, bc as withheldAccountClause, bd as ssmResolvedValueType, bi as bold, bl as scrubResourceRecord, bn as makeSiblingClaimReader, bs as refuseMalformedOrphanRecordsForDestroy, bu as withStackInstanceIdWithheld, c as inheritedProvenanceForChildDiff, cc as STATE_REGION_DIVERGED, cd as getDefaultStateBucketName, ci as holdsSupersededResources, cl as hasMaskableValues, cn as withNestedRevertRun, co as sendableAssumeRoleCommand, cr as demoteSupersededOrphans, cs as describeTypeWithThrottleRetry, cu as hasUnverifiableParameterRefusal, d as conditionInputsFrom, dc as malformedResourcesWarning, dd as resolveApp, di as supersededHeldByOtherTypeWarning, dl as printingCorpusOf, dn as withNestedStackContext, do as callerEnvCredentials, dr as planFailedOps, du as timePhase, ea as refusesFinalSnapshot, ec as malformedExportSourceWarning, ed as formatDockerLoginError, ei as DEFAULT_RESOURCE_WARN_AFTER_MS, el as valueAtCoordinate, en as displacedOpClause, eo as resolveDynamicReferences, er as updatePartialReason, es as renderStatefulReason, eu as importableOutputKeys, f as parentSuppliedValues, fc as malformedStateRefusalMessage, fd as resolveAutoAssetStorage, fi as supersededHolderOf, fl as recordLogOnlyParameterValue, fn as deleteJournaledOrphans, fo as envCredentialsAreAssumedRole, fr as recheckFailedPlan, fs as declaresNoEcho, fu as rebuildClientForBucketRegion, g as isAbsoluteAssetPath, ga as ProviderRegistry, gc as refuseMalformedState, gd as resolveStateBucketWithDefaultAndSource, gl as createSecretMasker, gn as journaledOrphanLines, go as regionLessSecretName, gr as withPreviousPolicies, gs as malformedOrphanRecordsWarning, gu as crossPrefixDeniedWarning, h as findNestedTemplateTreeDefect, ha as CC_BROKEN_REASON, hc as refuseMalformedResourcesForExport, hd as resolveStateBucketWithDefault, hl as unionOfSecretBags, hn as isHandledOrphan, ho as producerRegionsFromState, hr as resolveReplacementOldType, hs as malformedOrphanRecordsRefusalMessage, hu as applyCrossPrefixScan, i as mergeNoChangeOutputs, id as AssetManifestLoader, in as nestedChildStackName$1, io as assertFlagRoleArn, ir as withCreateTokenLedger, iu as orphansCarriedFrom, j as isProtectionValueActive, jc as NO_CC_HANDLERS_REASON, jd as derivePartitionAndUrlSuffix, ji as createReadOnlyAttributeHealerFactory, jl as physicalNameCopiesOf, jn as withMovedTo, jo as keepHeldTokenProvenance, jr as withNameGenerationReached, js as refuseMalformedResourceEntries, ju as buildDenyExternalAccessPolicy, k as recordedProtectionNote, ka as CloudControlProvider, kc as unwrittenCreateOnlyReplacement, kd as PARTITION_TABLE, ki as noEchoParameterNamesOf, kl as inheritNestedStackParameterAssociations, kn as movedToHint, ko as refStateLookupFromResource, kr as retiredNameGenerationsAfter, ks as malformedScrubResourceEntriesRefusalMessage, ku as AssetModeResolver, l as makeCanonicalizePropertiesFn, lc as refuseDivergentRecordRegionForDestroy, ld as getLegacyStateBucketName, li as isSupersededResourceRecord, ll as literalSplitDelimitersOf, ln as collectNestedChildUnaddressed, lo as AWS_CREDENTIAL_ENV_KEYS, lr as isJournaledOrphan, ls as withRetry, lu as PhaseClock, m as childTemplateLoader, mc as refuseMalformedResourcesForDestroy, md as resolveSkipPrefix, mi as withoutSuperseded, ml as shareLogOnlyValues, mn as dropFailedHint, mo as classifyReplaySecretRegion, mr as replacementNeverSwapped, ms as isReadableOrphanRecord, mu as CrossPrefixScanCache, n as isSecretBearingReferenceString, na as createPreDeleteFinalSnapshot, nc as malformedOutputsRefusalMessage, nd as runDockerForeground, nn as dropSettledNestedJournals, no as refuseUnreadableCdkCrossAccountRefs, nr as ledgerForStack, nu as isReadableBag, o as inRunStackKey, oc as refuseMalformedOutputsForDestroy, od as Synthesizer, ol as carryLogOnlyValues, oo as explicitRoleArnOrThrow, or as planRollback, os as prefetchCreateOnlyPropertyPaths, ou as stackInstanceIdCarriedFrom, p as readRecordedConditionVerdicts, pc as refuseMalformedResourcesForDeploy, pd as resolveCaptureObservedState, pi as supersededResourcesOf, pl as recordLogOnlyValue, pn as dropFailedCommands, po as classifyRecordedSecretRegion, pr as recordUnderIdIsNotOwn, ps as deployRefusesOrphanRowsReason, pu as CrossPrefixReadError, qc as maskedLeafCoordinatesOf, qd as renderAssemblyPathEscape, qi as withSecretPhysicalIdsMaskedInState, ql as isLockInfoExpired, qn as settleUnsettledPrevious, qo as withUnsettledProperties, qr as isWholeDynamicReferenceValue, qs as hasReadableOrphans, qu as redactDockerArgvValues, r as keptWholeReasonText, ra as buildFinalSnapshotIdentifier, rc as malformedOutputsWarning, rd as runDockerStreaming, ri as destroyStackRecordsView, rl as redactForState, ro as applyRoleArnIfSet, ru as orphansAfterRollback, s as crossStackOutputProvenanceSource, sc as repairMalformedOutputsForReadOnly, sd as synthesisStatusMessage, si as deleteSupersededEntry, sl as createUnionSecretMasker, sn as revertedNestedRowIds, so as isIamRoleArn, sr as seedsDeleteFirstGuard, ss as templateResourceTypes, su as hasReasonlessBaselineRefusal, t as DeployEngine, ta as unsupportedFinalSnapshotError, tc as malformedLocalOutputsWarning, td as getDockerCmd, ti as maskingRetryLogger, tl as liveMatchesUnresolvedTokenFrame, tn as displacedPhysicalIdShown, to as producerLookupOver, tu as importableOutputs, u as conditionFingerprint, uc as malformedRenderedContainersWarning, ud as loadCdkJson, ui as supersededAfterRollback, ul as logOnlyValueCount, un as getCurrentNestedStackContext, uo as applyCallerIdentityCredentials, ur as isReplacementOrphan, us as parameterInputsFor, uu as renderPhaseTimings, v as renderNestedTemplateTreeDefect, va as isCustomResource, vc as JSON_LISTING_HOLE_VALUE, vd as stateBucketExistenceConfirmed, vl as maskSecretsInError, vn as sameJournaledOrphans, vs as previewableOrphanRecords, vu as isNotImplemented, w as deferredServiceTokenWarning, wa as readsNoEchoDeleteValues, wc as hasReadableOutputs, wd as findLargeInlineResources, wi as red, wl as dynamicReferenceTokens, wn as constructPathOf$1, wo as parameterTypeMayLoseSecretIdentity, wr as orphanNeedsIdentity, ws as unreadableOrphanRecords, wu as WorkGraph, x as pendingMovesOutOf, xa as applyCustomResourceResponseExpiration, xc as STATE_RESOURCES_MALFORMED, xd as CFN_TEMPLATE_BODY_LIMIT, xi as cyan, xl as withPhysicalNameCopies, xn as planOrphanAdoption, xs as refuseMalformedOrphansForOrphan, xu as AssetPublisher, y as templateIdentity, ya as wouldReturnToSdkProvider, yc as accountArgs, yd as warnDeprecatedNoPrefixCliFlag, yl as maskSecretsInText, yn as makeForeignHolderScan, ys as refuseMalformedOrphanRecords, yu as stackInstanceIdOf, zd as defineOwnKey, zl as recordMaskOnlyValuesIn, zn as parseMappingFile, zo as carriesDynamicReference, zr as displayTextOrWithheld, zs as malformedDriftResourcePropertiesWarning, zt as refactorMarkerMovesOf, zu as BOOTSTRAP_MARKER_PREFIX } from "./deploy-engine-BocT17az.js";
|
|
4
|
-
import {
|
|
5
|
-
import { $t as forceQuitRecoveryClause, Dt as logicalIdShown, H as assertRegionMatch, M as VALUE_NOT_SHOWN, Qt as buildLockContentionMessage, U as isMarkedNotGone, V as RESOURCE_NOT_FOUND, Xt as UNREPRODUCIBLE_LOCK_CLAUSE, Zt as buildForceUnlockCommand, an as CUSTOM_RESOURCE_RESPONSE_PREFIX, bt as interruptWatchListenerCount, dn as setPasteableAwsCaBundle, en as formatLockExpiry, fn as setPasteableAwsProfile, kt as resourceTypeShown, ln as producerCoordinateKey, m as RESOLVED_PREVIOUS_PRINCIPAL_KEYS, mt as isAwsCliLiteral, nn as formatLockOwner, on as DEFAULT_STATE_PREFIX, p as IAM_PRINCIPAL_NAME, pn as withPasteableAwsProfile, sn as injectiveKey, st as runDeleteAttempt, tn as formatLockOperation, un as producerRecordKey, vt as beginCommandInterruptScope, xt as isInterruptedWaitError, y as readRecordedPrincipals, yt as endCommandInterruptScope, z as remedyLogicalId } from "./update-removal-
|
|
6
|
-
import { a as runWithStackAwsClients, i as resetAwsClients, l as s3ClientDefaults, o as setAwsClients, s as resolveS3ClientDefaults, t as AwsClients, u as setS3ClientDefaultsDebugLog } from "./aws-clients-
|
|
7
|
-
import { a as getAssumedRoleCredentials, c as setAwsEndpointOverrideSource, m as
|
|
8
|
-
import { a as parseEcrRegistryHost, i as looksLikeEcrHostWithForeignSuffix, n as hasEcrRegistryHostLabels, t as ecrRegistryHostPattern } from "./ecr-uri-
|
|
1
|
+
import { t as getCdkdVersion } from "./version-DXmr3_M4.js";
|
|
2
|
+
import { $ as withStackScope, B as generateResourceName, E as coerceCfnBoolean, I as PATTERN_B_NAME_OPTIONS, L as PATTERN_B_NAME_PROPERTIES, Q as withSkipPrefix, R as PATTERN_B_RESOURCE_TYPES, S as explicitNamePropertyFor, X as isNameGeneration, _t as truncateCodePoints, a as reserveStdoutForPayload, at as asIsMessage, ct as displayIdent, dt as isPasteableIdent, gt as terminalSafe, ht as stringifyJsonPayload, i as releaseStdoutForPayload, it as UNRENDERABLE, lt as displaySafe, m as verboseAwareText, mt as safeMsg, n as getLogger, nt as SECRET_REF_MAX_CODE_POINTS, ot as cutMarker, p as safeStringify, pt as plainIdentOr, r as isStdoutReservedForPayload, rt as STACK_REF_MAX_CODE_POINTS, s as runStackBuffered, st as displayAwsMessage, tt as SAFE_MSG_ALTERED_CHAR, u as describeAwsFailure, ut as displayStackName, y as getLiveRenderer, z as derivesPatternBName } from "./logger-DmQRya0S.js";
|
|
3
|
+
import { $a as poisonRenderedSpellingsCollidingIn, $d as setChildProcessAwsEnv, $i as isFinalSnapshotError, $l as describeRegionValueKind, $n as updatePartialMessage, $o as MULTI_REGION_RECREATE_BLOCKED_TYPES, $r as DEFAULT_RESOURCE_TIMEOUT_MS, $s as refuseMalformedOrphansForDestroy, $t as NESTED_PENDING_PARENT_REASON, $u as warnFinchArgvExposure, A as PROTECTION_PROPERTY_BY_TYPE, Ad as CUSTOM_RESOURCE_RESPONSE_OBJECT_DESCRIPTION, Ai as withAttemptedItemsMasked, Al as identityKeyFor, An as rollbackOrphanIds, Ao as lacksRecordedTableArn, Ar as retiredNameGenerationsLeaving, As as malformedResourceEntriesWarning, Au as rewriteTemplateAssetReferences, Bd as describeJsonParseFailure, Bi as secretNamedRecordNeedles, Bl as recordMaskOnlyValue, Bn as propertiesChangedReason, Bo as isNamelessDynamicReferenceError, Br as exportAliasCollisionScrubWarning, Bs as unreadableResourceEntries, Bt as refactorMarkerRefusalMessage, Bu as validateContainerRepoName, C as refusePendingMovesOut, Ca as TemplateNoEchoReresolver, Cc as STATE_RESOURCES_MALFORMED, Cd as warnDeprecatedNoPrefixCliFlag, Ci as green, Cl as withPhysicalNameCopies, Cn as DeploymentEventsStore, Cr as removeProtectionTypeList, Cs as refuseMalformedOrphansForOrphan, Cu as AssetPublisher, D as diffSecurity, Da as withPrintingSecrets, Dc as hasReadableResources, Dd as MIGRATE_TMP_PREFIX, Di as noEchoComparisonForTemplate, Dl as isUncertifiedBaselineMaskPosition, Dn as findRefactorHints, Do as AWS_NO_VALUE, Dr as nameScopeOf, Ds as isReadableResourceEntry, Du as buildAssetRedirectMap, E as serviceTokenBlockingReason, Ec as hasReadableOutputs, Ed as CFN_TEMPLATE_URL_LIMIT, Ei as noEchoAttributeNamesOf, El as dynamicReferenceTokens, En as formatDestructiveChange, Eo as parameterTypeMayLoseSecretIdentity, Er as nameGenerationHighWaterOf, Es as unreadableOrphanRecords, Eu as WorkGraph, Fa as UNSPECIFIED_SKIP_REASON, Fd as derivePartitionAndUrlSuffix, Fi as namingSecretsWithRecordedNoEcho, Fl as recordPhysicalNameCopy, Fn as differingRemedy, Fo as recordedOutputReferenceRegions, Fr as namesAnyDeclaredParameter, Fs as refuseMalformedResourceEntriesForDestroy, Ft as keptForRetainedRecord, Fu as isCrossRegionRedirect, Gc as isMarkedCoordinate, Gd as hasPlainPrototype, Gl as wholeStringLeavesOf, Gn as DELETED_RESOURCE_REMEDY, Gr as exportNameNoEchoParameters, Gs as refuseMalformedResourcePropertiesForExport, Gu as describeDockerExecFailure, Hc as DagBuilder, Hd as utf8ByteLength, Hi as storedSecretNameNeedles, Hl as recordNoEchoAttributeValues, Hn as referencedLogicalIds, Ho as keepsSecretReferenceToken, Hr as secretBearingStateKeyWarning, Hs as malformedResourcePropertiesWarning, Ht as sameMove, Hu as buildDockerImage, Ia as deleteIndeterminateGuards, Id as refuseFailedLookups, Ii as orphanRecordsPrintingBag, Il as recordNestedStackParameterExpressions, In as isPairableType, Io as recordedReferenceRegions, Ir as reachableDivergentParameters, Is as refuseMalformedResourceEntriesForImport, It as recordRetainedForReadoption, Iu as getBootstrapMarkerKey, Ja as isWaitAbandonedError, Jc as maskWholeValue, Jd as absoluteAssemblyPathEscape, Ji as ATOMIC_FINAL_SNAPSHOT_TYPES, Jl as LockManager, Jn as withUnprovenUnsettled, Jo as unsettledPropertiesOf, Jr as noEchoParameterValueSeed, Js as UNREADABLE_ORPHANS_CONTAINER_ROW, Ju as redactedDockerCause, Kc as maskAtCoordinates, Kd as nullPrototypeRecord, Ki as secretSegmentsOfState, Kl as WHOLE_DYNAMIC_REFERENCE_PATTERN, Kn as recordAfterRollbackUpdate, Ko as unsettledItemsField, Kr as exportNameSecretExposure, Ks as refuseMalformedResourcePropertiesForOrphan, Kt as formatResourceLine, Ku as describeDockerFailure, La as deleteLeftInPlace, Ld as AssemblyReader, Li as secretNamePrintingBag, Ll as splitGetAttStringForm, Ln as looselyEqual, Lo as getAccountInfo, Lr as resourcesNamingDeclaredParameter, Ls as refuseMalformedResourceEntriesForImportSave, Lt as readRefactorMarker, Lu as parseBootstrapMarker, M as perType, Ma as setResolvedResourceTimeouts, Md as expectedOwnerParam, Mi as completedReplayEntries, Mn as changedReferenceInDiff, Ms as refuseMalformedResourceAttributesForOrphan, Mt as withResourceDeadline, Mu as ensureAssetStorage, N as readProtection, Na as slowCcOperationTimeoutMs, Nc as NO_CC_HANDLERS_REASON, Nd as PARTITION_TABLE, Ni as journaledOrphanPrintingBag, Nl as physicalNameCopiesOf, Nn as changedReferencePath, No as keepHeldTokenProvenance, Nr as inheritProducerRegions, Ns as refuseMalformedResourceEntries, Nt as IMPLICIT_DELETE_DEPENDENCIES, Nu as buildDenyExternalAccessPolicy, O as recordedProtectionEvidence, Oc as findActionableSdkUnwired, Od as findLargeInlineResources, Oi as noEchoExactEchoLeavesOf, Ol as spelledKeysOf, On as hintSidesOf, Oo as cfnRefValueFromPhysicalId, Or as retiredAfterRollback, Os as malformedLocalResourceEntriesWarning, Ou as createAssetRedirectResolver, Pa as RollbackInlinePolicyWriters, Pc as hasNoCloudControlHandlers, Pd as canonicalizeRegion, Pi as maskEventTextWithBoundBags, Pn as changedReferenceReason, Pr as computeParameterTaint, Ps as refuseMalformedResourceEntriesForDeploy, Pt as computeImplicitDeleteEdges, Pu as assertAssetBucketRegion, Qa as isAlwaysLiveAttribute, Qc as noEchoOutputsComparison, Qd as resolveAssemblyPath, Qi as effectiveDeletionPolicy, Ql as acceptedCreateOnlyDropsOf, Qn as undeclaredEmptyObservedKeys, Qo as shownType, Qr as bindingSkippedOutputs, Qs as refuseMalformedOrphans, Qt as resolvePendingCloudControlRequests, Qu as partitionSensitiveEnv, Ra as deleteSkipReason, Rd as StageLoadError, Ri as secretNamePrintingBags, Rl as carriesSecretMask, Rn as mappingPairs, Ro as isImpossibleEmptyStoredAttribute, Rr as WITHHELD_NAME_DISPLAY, Rs as refuseMalformedResourceEntriesForOrphan, Rt as readRefactorMarkerOnce, Ru as readBootstrapMarkerBody, S as pendingMovesRefusalMessage, Sa as customResourceResponseExpirationWarning, Sc as withheldAccountClause, Sd as stateBucketExistenceConfirmed, Si as gray, Sl as scrubResourceRecord, Sn as DeploymentEventsReader, Sr as segmentCleanupOptions, Ss as refuseMalformedOrphanRecordsForDestroy, Su as withStackInstanceIdWithheld, T as findServiceTokenRefusals, Ta as isCustomResourceType$1, Tc as displayLogicalId, Td as CFN_TEMPLATE_BODY_LIMIT, Ti as yellow, Tl as DYNAMIC_REFERENCE_TOKEN_SCAN, Tn as findDestructiveChanges, To as isUnboundTemplateParameter, Tr as nameGenerationCarriedFrom, Ts as unpreviewableOrphanRecords, Tu as stringifyValue, Uc as TemplateParser, Ud as defineOwnKey, Ui as extractDeploymentEventError, Ul as recordNoEchoParameterFreshValue, Un as replayFailedOperations, Uo as withSharedDrainBudget, Ur as secretSafeKeyDisplay, Us as refuseMalformedResourcePropertiesForDestroy, Ut as updateRefactorMarker, Uu as resolveDockerContextDirectory, Vd as parseFailureDebugDetail, Vi as stateSecretNameNeedles, Vl as recordMaskOnlyValuesIn, Vn as proposeRenames, Vo as carriesDynamicReference, Vr as secretBearing, Vs as malformedDriftResourcePropertiesWarning, Vt as refuseRefactorMarker, Vu as BOOTSTRAP_MARKER_PREFIX, Wc as canonicalCoordinates, Wd as hasOwnKey, Wl as recordProvenPublicExpression, Wn as replayRollback, Wo as INTRINSIC_KEYS, Wr as carriedExportAliasExposure, Ws as refuseMalformedResourcePropertiesForDrift, Wu as describeDockerCapturedOutput, Xa as IntrinsicFunctionResolver, Xc as noEchoCoordinatesOf, Xd as displayAssemblyPath, Xi as ccRoutedFinalSnapshotError, Xl as S3StateBackend, Xn as equalModuloMarkedMask, Xo as withoutUnsettledProperties, Xr as collectPublishedOutputNames, Xs as malformedOrphansRefusalMessage, Xu as dockerSpawnEnvWithSensitive, Ya as DiffCalculator, Yc as maskedLeafCoordinatesOf, Yd as describeFileReadFailure, Yi as PRE_DELETE_SNAPSHOT_TYPES, Yl as isLockInfoExpired, Yn as calculateResourceDrift, Yo as withUnsettledProperties, Yr as collectDeclaredOutputNames, Ys as hasReadableOrphans, Yu as redactDockerArgvValues, Za as isSelectOutOfBounds, Zc as noEchoLeavesOf, Zd as renderAssemblyPathEscape, Zi as ccRoutedInstanceTakesNoSnapshot, Zl as splitImportedOps, Zn as equalModuloMask, Zo as findReplacedReadersOfRecreateTargets, Zr as isExportAliasCollision, Zs as malformedOrphansWarning, Zt as pendingRequestCount, Zu as finchSecretArgvRefusal, _ as listNestedTemplateRows, _a as ccBrokenReason, _c as refuseMalformedResourcesForExport, _d as resolveSkipPrefix, _l as unionOfSecretBags, _n as loadJournaledOrphans, _o as producerRegionsFromState, _r as findNestedStackTypeChanges, _s as malformedOrphanRecordsRefusalMessage, _u as applyCrossPrefixScan, a as scanActiveConsumers, ac as malformedOutputsWarning, ad as runDockerStreaming, ai as withStackRecords, al as redactForState, an as recordDisplacedSkips, ao as applyRoleArnIfSet, au as orphansAfterRollback, b as hasPendingMovesOut, ba as CUSTOM_RESOURCE_RESPONSE_LIFECYCLE_RULE_ID, bc as JSON_LISTING_HOLE_VALUE, bd as resolveStateBucketWithSource, bi as bold, bl as maskSecretsInError, bn as makeSiblingClaimReader, bs as previewableOrphanRecords, bu as isNotImplemented, c as inheritedProvenanceForChildDiff, cc as refuseMalformedOutputsForDestroy, cd as getDockerImageBySourceHash, ci as holdsSupersededResources, cl as carryLogOnlyValues, cn as withNestedRevertRun, co as explicitRoleArnOrThrow, cr as demoteSupersededOrphans, cs as prefetchCreateOnlyPropertyPaths, cu as stackInstanceIdCarriedFrom, d as conditionInputsFrom, dc as refuseDivergentRecordRegionForDestroy, dd as getDefaultStateBucketName, di as supersededHeldByOtherTypeWarning, dl as literalSplitDelimitersOf, dn as withNestedStackContext, do as AWS_CREDENTIAL_ENV_KEYS, dr as planFailedOps, ds as withRetry, du as PhaseClock, ea as refusesFinalSnapshot, ec as repairMalformedOrphansForReadOnly, ed as isDockerClientEnvKey, ef as injectAwsRegion, ei as DEFAULT_RESOURCE_WARN_AFTER_MS, el as readsNoEchoSource, en as displacedOpClause, eo as stackIdTailOf, er as updatePartialReason, es as isStatefulRecreateTargetForReplace, eu as exportNamesCarriedFrom, f as parentSuppliedValues, fc as malformedRenderedContainersWarning, fd as getLegacyStateBucketName, fi as supersededHolderOf, fl as logOnlyValueCount, fn as deleteJournaledOrphans, fo as applyCallerIdentityCredentials, fr as recheckFailedPlan, fs as parameterInputsFor, fu as renderPhaseTimings, g as isAbsoluteAssetPath, ga as ProviderRegistry, gc as refuseMalformedResourcesForDestroy, gd as resolveCaptureObservedState, gl as shareLogOnlyValues, gn as journaledOrphanLines, go as classifyReplaySecretRegion, gr as withPreviousPolicies, gs as isReadableOrphanRecord, gu as CrossPrefixScanCache, h as findNestedTemplateTreeDefect, ha as CC_BROKEN_REASON, hc as refuseMalformedResourcesForDeploy, hd as resolveAutoAssetStorage, hl as recordLogOnlyValue, hn as isHandledOrphan, ho as classifyRecordedSecretRegion, hr as resolveReplacementOldType, hs as deployRefusesOrphanRowsReason, hu as CrossPrefixReadError, i as mergeNoChangeOutputs, ic as malformedOutputsRefusalMessage, id as runDockerForeground, in as nestedChildStackName$1, io as refuseUnreadableCdkCrossAccountRefs, ir as withCreateTokenLedger, iu as isReadableBag, j as isProtectionValueActive, jc as unwrittenCreateOnlyReplacement, jd as decodeListingKey, ji as createReadOnlyAttributeHealerFactory, jl as inheritNestedStackParameterAssociations, jn as withMovedTo, jo as refStateLookupFromResource, jr as withNameGenerationReached, js as malformedScrubResourceEntriesRefusalMessage, ju as AssetModeResolver, k as recordedProtectionNote, ka as CloudControlProvider, kc as findHandledUnwrittenCreateOnly, kd as uploadCfnTemplate, ki as noEchoParameterNamesOf, kl as pathCrossesDottedKey, kn as movedToHint, ko as isStalePlaceholderArnAttribute, kr as retiredNameGenerationsAfter, ks as malformedLocalResourcesWarning, ku as loadPublishableAssetManifest, l as makeCanonicalizePropertiesFn, lc as repairMalformedOutputsForReadOnly, ld as Synthesizer, li as isSupersededResourceRecord, ll as createUnionSecretMasker, ln as collectNestedChildUnaddressed, lo as isIamRoleArn, lr as isJournaledOrphan, ls as templateResourceTypes, lu as hasReasonlessBaselineRefusal, m as childTemplateLoader, mc as malformedStateRefusalMessage, md as resolveApp, mi as withoutSuperseded, ml as recordLogOnlyParameterValue, mn as dropFailedHint, mo as envCredentialsAreAssumedRole, mr as replacementNeverSwapped, ms as declaresNoEcho, mu as rebuildClientForBucketRegion, n as isSecretBearingReferenceString, na as createPreDeleteFinalSnapshot, nc as malformedExportSourceWarning, nd as formatDockerLoginError, nl as valueAtCoordinate, nn as dropSettledNestedJournals, no as resolveDynamicReferences, nr as ledgerForStack, ns as renderStatefulReason, nu as importableOutputKeys, o as inRunStackKey, od as abortInFlightMultipartUploads, oo as assertFlagRoleArn, or as planRollback, ou as orphansCarriedFrom, p as readRecordedConditionVerdicts, pc as malformedResourcesWarning, pd as loadCdkJson, pi as supersededResourcesOf, pl as printingCorpusOf, pn as dropFailedCommands, po as callerEnvCredentials, pr as recordUnderIdIsNotOwn, pu as timePhase, qc as maskReadbackAtCoordinates, qd as ownValue, qi as withSecretPhysicalIdsMaskedInState, ql as isSingleDynamicReferenceToken, qn as settleUnsettledPrevious, qo as unsettledItemsOf, qr as isWholeDynamicReferenceValue, qs as repairMalformedResourcePropertiesForReadOnly, qu as redactedCause, r as keptWholeReasonText, ra as buildFinalSnapshotIdentifier, rc as malformedLocalOutputsWarning, rd as getDockerCmd, rf as resolveBucketRegion, ri as destroyStackRecordsView, rl as liveMatchesUnresolvedTokenFrame, ro as producerLookupOver, ru as importableOutputs, s as crossStackOutputProvenanceSource, sc as refuseMalformedOutputs, sd as AssetManifestLoader, si as deleteSupersededEntry, sn as revertedNestedRowIds, so as assertSendableRoleArn, sr as seedsDeleteFirstGuard, su as shouldRetainResource, t as DeployEngine, ta as unsupportedFinalSnapshotError, tc as malformedExportNamesWarning, td as isMalformedEnvKey, tf as injectedAwsRegionValue, ti as maskingRetryLogger, tl as recordedNoEchoValuesOf, tn as displacedPhysicalIdShown, ts as isStatefulRecreateTargetSync, tu as hasReadableExportSet, u as conditionFingerprint, uc as STATE_REGION_DIVERGED, ud as synthesisStatusMessage, ui as supersededAfterRollback, ul as hasMaskableValues, un as getCurrentNestedStackContext, uo as sendableAssumeRoleCommand, ur as isReplacementOrphan, us as describeTypeWithThrottleRetry, uu as hasUnverifiableParameterRefusal, v as renderNestedTemplateTreeDefect, va as isCustomResource, vc as refuseMalformedState, vd as resolveStateBucketWithDefault, vl as createSecretMasker, vn as sameJournaledOrphans, vo as regionLessSecretName, vs as malformedOrphanRecordsWarning, vu as crossPrefixDeniedWarning, w as deferredServiceTokenWarning, wa as readsNoEchoDeleteValues, wc as UNREADABLE_RESOURCES_MAP_ROW, wd as ssmResolvedValueType, wi as red, wn as constructPathOf$1, wo as coerceParameterTypedValue, wr as orphanNeedsIdentity, ws as repairMalformedOrphanRecordsForReadOnly, wu as isSensitiveAttributeName, x as pendingMovesOutOf, xa as applyCustomResourceResponseExpiration, xc as accountArgs, xd as resolveUseCdkBootstrapAssets, xi as cyan, xl as maskSecretsInText, xn as planOrphanAdoption, xs as refuseMalformedOrphanRecords, xu as stackInstanceIdOf, y as templateIdentity, ya as wouldReturnToSdkProvider, yc as repairMalformedResourcesForReadOnly, yd as resolveStateBucketWithDefaultAndSource, yl as errorCauseChain, yn as makeForeignHolderScan, ys as malformedOrphanRowsKeptWarning, yu as isAccessDenied, zd as processStackMessages, zl as provenPublicValue, zn as parseMappingFile, zo as carriesFetchableDynamicReference, zr as displayTextOrWithheld, zs as repairMalformedResourceEntriesForReadOnly, zt as refactorMarkerMovesOf, zu as validateAssetBucketName } from "./deploy-engine-2XoVAu4C.js";
|
|
4
|
+
import { A as stripControlChars, B as retryClassificationText, Ct as withheldTargetClause, F as isAmbiguousOutcomeError, H as isMarkedNonRetryable, J as DynamicReferenceRegionAmbiguousError, Q as AccountIdUnavailableError, R as isRetryableTransientError, St as shellQuote, Tt as setPasteableVerbFlags, U as isThrottlingError, W as markNonRetryable, X as MalformedProducerRecordRefusalError, Y as IntrinsicResolutionRefusalError, _ as ResourceUpdateNotSupportedError, _t as pasteableCommand, a as normalizeAwsError, at as ProvisioningError, bt as quotedOrDescribed, ct as SynthesisError, et as CdkdError, ft as SHELL_ACTIVE_WHY, g as PartialFailureError, gt as isInertUnquoted, h as NestedStackChildDirectDestroyError, i as credentialFingerprint, j as stripForDisplay, k as escapeRegExp, l as withErrorHandling, mt as commandHole, n as ambientCredentialConfig, o as formatError, ot as ResourceTimeoutError, q as CrossAccountSecretRefusalError, r as clientDefaultsFor, rt as LocalInvokeBuildError$1, s as handleError, st as StateError, t as ambientClientDefaults, tt as DeployCancelledError, u as LocalStartServiceError, ut as TIMEOUT_FLAG_RESOURCE_TYPE, v as StackHasActiveImportsError, wt as setPasteableRunFlags, xt as shellBoundedDisplay, y as StackTerminationProtectionError, yt as plainOrDescribed, z as isTransientServerError } from "./ambient-client-defaults-7acjxfyN.js";
|
|
5
|
+
import { $t as forceQuitRecoveryClause, Dt as logicalIdShown, H as assertRegionMatch, M as VALUE_NOT_SHOWN, Qt as buildLockContentionMessage, U as isMarkedNotGone, V as RESOURCE_NOT_FOUND, Xt as UNREPRODUCIBLE_LOCK_CLAUSE, Zt as buildForceUnlockCommand, an as CUSTOM_RESOURCE_RESPONSE_PREFIX, bt as interruptWatchListenerCount, dn as setPasteableAwsCaBundle, en as formatLockExpiry, fn as setPasteableAwsProfile, kt as resourceTypeShown, ln as producerCoordinateKey, m as RESOLVED_PREVIOUS_PRINCIPAL_KEYS, mt as isAwsCliLiteral, nn as formatLockOwner, on as DEFAULT_STATE_PREFIX, p as IAM_PRINCIPAL_NAME, pn as withPasteableAwsProfile, sn as injectiveKey, st as runDeleteAttempt, tn as formatLockOperation, un as producerRecordKey, vt as beginCommandInterruptScope, xt as isInterruptedWaitError, y as readRecordedPrincipals, yt as endCommandInterruptScope, z as remedyLogicalId } from "./update-removal-D-FspP88.js";
|
|
6
|
+
import { a as runWithStackAwsClients, i as resetAwsClients, l as s3ClientDefaults, o as setAwsClients, s as resolveS3ClientDefaults, t as AwsClients, u as setS3ClientDefaultsDebugLog } from "./aws-clients-DOkPjjAW.js";
|
|
7
|
+
import { a as getAssumedRoleCredentials, c as setAssumedRoleCredentials, h as formatAuthority, l as setAwsEndpointOverrideSource, m as runInStackAwsScope, n as awsClientDefaults, o as getPreAssumeEnvCredentials, r as awsEndpointOverrideActive, s as runWithRealAws } from "./aws-client-defaults-DAebi99J.js";
|
|
8
|
+
import { a as parseEcrRegistryHost, i as looksLikeEcrHostWithForeignSuffix, n as hasEcrRegistryHostLabels, t as ecrRegistryHostPattern } from "./ecr-uri-C1_heDAt.js";
|
|
9
9
|
import { t as cdkdCacheHome } from "./cli.js";
|
|
10
10
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
11
11
|
import { CopyObjectCommand, CreateBucketCommand, DeleteBucketCommand, DeleteObjectsCommand, GetBucketLocationCommand, GetObjectCommand, HeadBucketCommand, ListObjectVersionsCommand, ListObjectsV2Command, NoSuchBucket, NotFound, PutBucketEncryptionCommand, PutBucketPolicyCommand, PutBucketVersioningCommand, PutObjectCommand, S3Client, S3ServiceException } from "@aws-sdk/client-s3";
|
|
@@ -23,10 +23,10 @@ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
|
23
23
|
import { execFile, spawn } from "node:child_process";
|
|
24
24
|
import { devNull, tmpdir } from "node:os";
|
|
25
25
|
import { BatchDeleteImageCommand, DeleteRepositoryCommand, DescribeImagesCommand as DescribeImagesCommand$1, ECRClient, GetAuthorizationTokenCommand } from "@aws-sdk/client-ecr";
|
|
26
|
+
import { A2A_CONTAINER_PORT, A2A_PATH, AGENTCORE_A2A_PROTOCOL, AGENTCORE_AGUI_PROTOCOL, AGENTCORE_MCP_PROTOCOL, ConnectionRegistry, DEFAULT_AWS_EMULATOR_URL, DynamicReferenceResolver, EMULATOR_SCRUBBED_ENV_KEYS, EcsTaskResolutionError, HOST_GATEWAY_MIN_VERSION, LocalInvokeBuildError, MCP_CONTAINER_PORT, MCP_PATH, UNNAMED_WORKLOAD, a2aInvokeOnce, activateWorkloadAwsWiring, addAlbSpecificOptions, addAwsEndpointOptions, addCommonEcsServiceOptions, addImageOverrideOptions, addStartServiceSpecificOptions, albStrategy, applyWorkloadAwsWiringToEnv, architectureToPlatform, attachAuthorizers, attachLoopbackForwarder, attachStageContext, availableApiIdentifiers, awaitLoopbackForwarderStatus, awsEmulatorEnvName, awsEmulatorRealServices, bufferToBody, buildAgentCoreCodeImage, buildCognitoJwksUrl, buildConnectEvent, buildContainerImage, buildCorsConfigByApiId, buildCorsConfigFromCloudFrontChain, buildDisconnectEvent, buildJwksUrlFromIssuer, buildMessageEvent, buildMgmtEndpointEnvUrl, buildNamespaceOwnerForwarderDockerArgs, buildStageMap, canonicalizeImageOverrideKeys, classifySourceChange, containsDynamicReference, createAuthorizerCache, createFileWatcher, createFileWatcher as createFileWatcher$1, createJwksCache, createMixedModeStateProvider, createWatchPredicates, defaultCredentialsLoader, derivePseudoParametersFromRegion, describeAwsFailureForWarn, describeForwarderFailure, discoverRoutes, discoverWebSocketApis, dockerRegistryEnv, downloadAndExtractS3Bundle, effectiveLoopbackPorts, enforceImageOverrideOrphans, ensureForwarderImage, filterRoutesByApiIdentifier, firstUsableRegion, getActiveWorkloadAwsWiring, getActiveWorkloadAwsWiring as getActiveWorkloadAwsWiring$1, getAwsEndpointOverride, groupRoutesByServer, groupWorkloadsRoutedApart, handleConnectionsRequest, invokeAgentCore, invokeAgentCoreWs, isAwsServiceRoutedToEmulator, isRealAwsSentinel, keysNotFromTemplate, keysOverriddenBy, loopbackForwarderPlan, materializeLayerFromArn, mcpInvokeOnce, noImplicitEcrPullArgs, parseAwsEndpoint, parseConnectionsPath, parseImageOverrideFlags, parseSelectionExpressionPath, pickAgentCoreCandidateStack, pickAgentCoreCandidateStack as pickAgentCoreCandidateStack$1, probeHostGatewaySupport, readAwsEmulatorEnvVarsFile, readEmulatorRunFiles, readEnvVarsFileText, readMtlsMaterialsFromDisk, realAwsServicesOf, recordAssumedRole, resolveAgentCoreTarget, resolveAwsEmulatorOption, resolveDynamicReferencesInEnv, resolveEnvVars, resolveHostDefaultCredentials, resolveHostGatewayExtraHosts, resolveImageOverrides, resolveRuntimeCodeMountPath, resolveRuntimeFileExtension, resolveRuntimeImage, resolveSingleTarget, resolveWatchConfig, resolveWorkloadAwsWiring, runEcsServiceEmulator, runImageOverrideBuilds, setActiveWorkloadAwsWiring, setAwsEndpointOverride, signAgentCoreInvocation, startApiServer, substituteImagePlaceholders, takeAwsEmulatorStateSourceHint, tryResolveImageFnJoin, verifyJwtViaDiscovery, waitForAgentCorePing, withoutKeys } from "cdk-local/internal";
|
|
26
27
|
import { isDeepStrictEqual, promisify } from "node:util";
|
|
27
28
|
import graphlib from "graphlib";
|
|
28
29
|
import { Command, InvalidArgumentError, Option } from "commander";
|
|
29
|
-
import { A2A_CONTAINER_PORT, A2A_PATH, AGENTCORE_A2A_PROTOCOL, AGENTCORE_AGUI_PROTOCOL, AGENTCORE_MCP_PROTOCOL, ConnectionRegistry, DEFAULT_AWS_EMULATOR_URL, DynamicReferenceResolver, EMULATOR_SCRUBBED_ENV_KEYS, EcsTaskResolutionError, HOST_GATEWAY_MIN_VERSION, LocalInvokeBuildError, MCP_CONTAINER_PORT, MCP_PATH, a2aInvokeOnce, activateWorkloadAwsWiring, addAlbSpecificOptions, addAwsEndpointOptions, addCommonEcsServiceOptions, addImageOverrideOptions, addStartServiceSpecificOptions, albStrategy, applyWorkloadAwsWiringToEnv, architectureToPlatform, attachAuthorizers, attachLoopbackForwarder, attachStageContext, availableApiIdentifiers, awaitLoopbackForwarderStatus, awsEmulatorEnvName, bufferToBody, buildAgentCoreCodeImage, buildCognitoJwksUrl, buildConnectEvent, buildContainerImage, buildCorsConfigByApiId, buildCorsConfigFromCloudFrontChain, buildDisconnectEvent, buildJwksUrlFromIssuer, buildMessageEvent, buildMgmtEndpointEnvUrl, buildNamespaceOwnerForwarderDockerArgs, buildStageMap, canonicalizeImageOverrideKeys, classifySourceChange, containsDynamicReference, createAuthorizerCache, createFileWatcher, createFileWatcher as createFileWatcher$1, createJwksCache, createWatchPredicates, defaultCredentialsLoader, derivePseudoParametersFromRegion, describeAwsFailureForWarn, describeForwarderFailure, discoverRoutes, discoverWebSocketApis, downloadAndExtractS3Bundle, effectiveLoopbackPorts, enforceImageOverrideOrphans, ensureForwarderImage, filterRoutesByApiIdentifier, firstUsableRegion, getActiveWorkloadAwsWiring, getActiveWorkloadAwsWiring as getActiveWorkloadAwsWiring$1, getAwsEndpointOverride, groupRoutesByServer, handleConnectionsRequest, invokeAgentCore, invokeAgentCoreWs, keysNotFromTemplate, keysOverriddenBy, materializeLayerFromArn, mcpInvokeOnce, parseAwsEndpoint, parseConnectionsPath, parseImageOverrideFlags, parseSelectionExpressionPath, pickAgentCoreCandidateStack, pickAgentCoreCandidateStack as pickAgentCoreCandidateStack$1, probeHostGatewaySupport, readEmulatorRunFiles, readMtlsMaterialsFromDisk, recordAssumedRole, resolveAgentCoreTarget, resolveAwsEmulatorOption, resolveDynamicReferencesInEnv, resolveEnvVars, resolveHostDefaultCredentials, resolveHostGatewayExtraHosts, resolveImageOverrides, resolveRuntimeCodeMountPath, resolveRuntimeFileExtension, resolveRuntimeImage, resolveSingleTarget, resolveWatchConfig, resolveWorkloadAwsWiring, runEcsServiceEmulator, runImageOverrideBuilds, setActiveWorkloadAwsWiring, setAwsEndpointOverride, signAgentCoreInvocation, startApiServer, substituteImagePlaceholders, tryResolveImageFnJoin, verifyJwtViaDiscovery, waitForAgentCorePing, withoutKeys } from "cdk-local/internal";
|
|
30
30
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
31
31
|
import * as readline$1 from "node:readline/promises";
|
|
32
32
|
import readline from "node:readline/promises";
|
|
@@ -335,7 +335,8 @@ const skipFinalSnapshotOption = new Option("--skip-final-snapshot", "Delete reso
|
|
|
335
335
|
|
|
336
336
|
// src/local/local-role-arn.ts
|
|
337
337
|
async function applyRoleArnForLocal(opts) {
|
|
338
|
-
await applyRoleArnIfSet(opts);
|
|
338
|
+
if (getActiveWorkloadAwsWiring()?.mixed) await runWithRealAws(() => applyRoleArnIfSet(opts));
|
|
339
|
+
else await applyRoleArnIfSet(opts);
|
|
339
340
|
const role = getAssumedRoleCredentials();
|
|
340
341
|
if (role === void 0) return;
|
|
341
342
|
recordAssumedRole(getPreAssumeEnvCredentials(), {
|
|
@@ -399,10 +400,12 @@ async function activateLocalAwsWiring(options) {
|
|
|
399
400
|
awsEmulator: options.awsEmulator,
|
|
400
401
|
caBundle: options.caBundle,
|
|
401
402
|
profile: options.profile,
|
|
402
|
-
pull: options.pull
|
|
403
|
+
pull: options.pull,
|
|
404
|
+
envVars: options.envVars
|
|
403
405
|
});
|
|
404
406
|
} catch (err) {
|
|
405
|
-
|
|
407
|
+
const cause = err instanceof Error && err.cause instanceof Error ? err.cause : void 0;
|
|
408
|
+
throw new CdkdError(err instanceof Error ? err.message : String(err), "LOCAL_AWS_WIRING_FAILED", cause);
|
|
406
409
|
}
|
|
407
410
|
}
|
|
408
411
|
async function activateLocalAwsAndRoleArn(options) {
|
|
@@ -428,7 +431,8 @@ function assertAwsEmulatorValue(flag) {
|
|
|
428
431
|
async function applyLocalAwsWiring(wiring, env, extraMounts, takenContainerPaths) {
|
|
429
432
|
const defaults = wiring.mode === "forward" && !env["AWS_ACCESS_KEY_ID"] ? await resolveHostDefaultCredentials() : void 0;
|
|
430
433
|
const wiredEnv = applyWorkloadAwsWiringToEnv(env, wiring, defaults);
|
|
431
|
-
const
|
|
434
|
+
const emulatorOnly = workloadGetsEmulatorKeysOnly(env, wiring);
|
|
435
|
+
const mounts = extraMounts.filter((m) => !emulatorOnly || m.containerPath !== "/cdkd-aws/credentials");
|
|
432
436
|
const taken = /* @__PURE__ */ new Set([...takenContainerPaths, ...mounts.map((m) => m.containerPath)]);
|
|
433
437
|
for (const m of wiring.mounts) if (!taken.has(m.containerPath)) mounts.push({
|
|
434
438
|
...m,
|
|
@@ -440,13 +444,16 @@ async function applyLocalAwsWiring(wiring, env, extraMounts, takenContainerPaths
|
|
|
440
444
|
};
|
|
441
445
|
}
|
|
442
446
|
function loopbackPortsFor(wiring, env, network) {
|
|
443
|
-
|
|
447
|
+
if (network !== "host") return effectiveLoopbackPorts(env, wiring);
|
|
448
|
+
const mixed = wiring.mixed;
|
|
449
|
+
if (mixed && effectiveLoopbackPorts(env, wiring).includes(mixed.resignPort)) throw new CdkdError("A run with \"real-aws\" exceptions (AWS Emulator mixed mode) cannot use the host network: its re-signing sidecar listens on the workload's own loopback. Drop the \"real-aws\" exceptions or the host network.", "LOCAL_AWS_EMULATOR_FORWARDER_FAILED");
|
|
450
|
+
return [];
|
|
444
451
|
}
|
|
445
452
|
async function prepareLocalLoopbackForwarder(wiring) {
|
|
446
453
|
try {
|
|
447
454
|
await ensureForwarderImage(wiring.skipPull === true);
|
|
448
455
|
} catch (err) {
|
|
449
|
-
if (wiring.mode === "emulator") throw new CdkdError(`--aws-emulator: the loopback forwarder image could not be pulled: ${err.message}`, "LOCAL_AWS_EMULATOR_FORWARDER_PULL_FAILED");
|
|
456
|
+
if (wiring.mode === "emulator" || wiring.mixed) throw new CdkdError(`--aws-emulator: the loopback forwarder image could not be pulled: ${err.message}`, "LOCAL_AWS_EMULATOR_FORWARDER_PULL_FAILED");
|
|
450
457
|
}
|
|
451
458
|
}
|
|
452
459
|
async function attachLocalLoopbackForwarder(containerId, ports) {
|
|
@@ -475,6 +482,31 @@ function localAwsEmulatorCredentials() {
|
|
|
475
482
|
const wiring = getActiveWorkloadAwsWiring$1();
|
|
476
483
|
return wiring?.mode === "emulator" ? wiring.emulatorCredentials : void 0;
|
|
477
484
|
}
|
|
485
|
+
function workloadGetsEmulatorKeysOnly(env, wiring) {
|
|
486
|
+
if (!wiring) return false;
|
|
487
|
+
if (wiring.mode === "emulator") return true;
|
|
488
|
+
if (!wiring.mixed) return false;
|
|
489
|
+
return !Object.entries(env).some(([k, v]) => k !== "AWS_ENDPOINT_URL" && isRealAwsSentinel(k, v));
|
|
490
|
+
}
|
|
491
|
+
function taskRoleAssumedInRealAws(env, wiring) {
|
|
492
|
+
if (wiring?.mode === "emulator") return false;
|
|
493
|
+
if (!wiring?.mixed) return true;
|
|
494
|
+
return isRealAwsSentinel("AWS_ENDPOINT_URL_STS", env["AWS_ENDPOINT_URL_STS"]);
|
|
495
|
+
}
|
|
496
|
+
function mixedModeActive() {
|
|
497
|
+
return getActiveWorkloadAwsWiring$1()?.mixed !== void 0;
|
|
498
|
+
}
|
|
499
|
+
function realAwsException(service, workload) {
|
|
500
|
+
return mixedModeActive() && !isAwsServiceRoutedToEmulator(service, workload);
|
|
501
|
+
}
|
|
502
|
+
function mixedModeEmulatorOverride() {
|
|
503
|
+
return getAwsEndpointOverride() ?? getActiveWorkloadAwsWiring$1()?.mixed?.emulatorClientOverride;
|
|
504
|
+
}
|
|
505
|
+
function warnAwsEmulatorStateSourceHint(dropped, stateSourceGiven) {
|
|
506
|
+
if (dropped === 0 || stateSourceGiven) return;
|
|
507
|
+
const hint = takeAwsEmulatorStateSourceHint();
|
|
508
|
+
if (hint !== void 0) getLogger().warn(hint);
|
|
509
|
+
}
|
|
478
510
|
|
|
479
511
|
// src/cli/aws-emulator-activation.ts
|
|
480
512
|
async function activateAwsEmulatorForCommand(flag) {
|
|
@@ -542,6 +574,13 @@ function prepareAwsEmulatorForCommand(actionCommand) {
|
|
|
542
574
|
const value = resolveAwsEmulatorOption(flag);
|
|
543
575
|
if (value === void 0) return void 0;
|
|
544
576
|
const local = underLocalCommand(actionCommand);
|
|
577
|
+
const endpoint = parseAwsEndpoint(value === true ? DEFAULT_AWS_EMULATOR_URL : value, "--aws-emulator");
|
|
578
|
+
const url = endpoint.hostname === "localhost" ? endpoint.url.replace("//localhost", "//127.0.0.1") : endpoint.url;
|
|
579
|
+
if (local && localCommandIsMixedMode(actionCommand)) {
|
|
580
|
+
keepHostClientsOnRealAws();
|
|
581
|
+
pointChildProcessesAtEmulator(url, endpoint.port);
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
545
584
|
const ignored = [];
|
|
546
585
|
if (clearOption(actionCommand, "profile")) ignored.push("--profile");
|
|
547
586
|
if (!local && clearOption(actionCommand, "roleArn")) ignored.push("--role-arn");
|
|
@@ -562,14 +601,29 @@ function prepareAwsEmulatorForCommand(actionCommand) {
|
|
|
562
601
|
const names = ignored.join(", ");
|
|
563
602
|
onStderr(() => getLogger().info(safeMsg`--aws-emulator: ignoring ${names}; every AWS call uses the emulator's keys.`));
|
|
564
603
|
}
|
|
565
|
-
const endpoint = parseAwsEndpoint(value === true ? DEFAULT_AWS_EMULATOR_URL : value, "--aws-emulator");
|
|
566
|
-
const url = endpoint.hostname === "localhost" ? endpoint.url.replace("//localhost", "//127.0.0.1") : endpoint.url;
|
|
567
604
|
const caBundle = actionCommand.optsWithGlobals().caBundle;
|
|
568
605
|
pointEnvironmentAtEmulator(url, endpoint.port, caBundle);
|
|
569
606
|
if (local) return void 0;
|
|
570
607
|
setAwsEndpointOverrideSource(getAwsEndpointOverride);
|
|
571
608
|
return () => onStderr(() => activateAwsEmulatorForCommand(flag));
|
|
572
609
|
}
|
|
610
|
+
function keepHostClientsOnRealAws() {
|
|
611
|
+
const ignored = [];
|
|
612
|
+
for (const key of Object.keys(process.env)) if (key.startsWith("AWS_ENDPOINT_URL")) {
|
|
613
|
+
if (process.env[key] !== "") ignored.push(key);
|
|
614
|
+
delete process.env[key];
|
|
615
|
+
}
|
|
616
|
+
process.env["AWS_IGNORE_CONFIGURED_ENDPOINT_URLS"] = "true";
|
|
617
|
+
if (ignored.length > 0) {
|
|
618
|
+
const names = ignored.join(", ");
|
|
619
|
+
onStderr(() => getLogger().info(safeMsg`--aws-emulator (mixed mode): ignoring ${names}; the "real-aws" exceptions go to real AWS.`));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
function localCommandIsMixedMode(actionCommand) {
|
|
623
|
+
const envVars = actionCommand.optsWithGlobals().envVars;
|
|
624
|
+
if (typeof envVars !== "string" || envVars === "") return false;
|
|
625
|
+
return realAwsServicesOf(readAwsEmulatorEnvVarsFile(envVars).exceptions).length > 0;
|
|
626
|
+
}
|
|
573
627
|
function onStderr(fn) {
|
|
574
628
|
if (isStdoutReservedForPayload()) return fn();
|
|
575
629
|
reserveStdoutForPayload();
|
|
@@ -585,22 +639,42 @@ function onStderr(fn) {
|
|
|
585
639
|
return result;
|
|
586
640
|
}
|
|
587
641
|
function pointEnvironmentAtEmulator(url, port, caBundle) {
|
|
642
|
+
Object.assign(process.env, emulatorEnvironment(url, port, process.env));
|
|
643
|
+
const run = readEmulatorRunFiles(port);
|
|
644
|
+
const caPath = join(run.dir, "ca.pem");
|
|
645
|
+
const runCa = run.present && existsSync(caPath) ? caPath : devNull;
|
|
646
|
+
const ca = caBundle !== void 0 && caBundle !== "" ? caBundle : runCa;
|
|
647
|
+
setPasteableAwsCaBundle(url.startsWith("https:") && ca !== devNull ? ca : void 0);
|
|
648
|
+
}
|
|
649
|
+
function emulatorEnvironment(url, port, env) {
|
|
588
650
|
const run = readEmulatorRunFiles(port);
|
|
589
651
|
const runFile = (name) => {
|
|
590
652
|
const p = join(run.dir, name);
|
|
591
653
|
return run.present && existsSync(p) ? p : devNull;
|
|
592
654
|
};
|
|
593
|
-
process.env["AWS_ENDPOINT_URL"] = url;
|
|
594
655
|
const config = runFile("config");
|
|
595
|
-
|
|
596
|
-
|
|
656
|
+
const out = {
|
|
657
|
+
AWS_ENDPOINT_URL: url,
|
|
658
|
+
AWS_CONFIG_FILE: config,
|
|
659
|
+
AWS_SHARED_CREDENTIALS_FILE: runFile("emulator_credentials"),
|
|
660
|
+
AWS_EC2_METADATA_DISABLED: "true"
|
|
661
|
+
};
|
|
662
|
+
if (!env["AWS_REGION"] && !env["AWS_DEFAULT_REGION"] && config !== devNull) {
|
|
597
663
|
const region = defaultProfileRegion(readFileSync(config, "utf8"));
|
|
598
|
-
if (region !== void 0)
|
|
664
|
+
if (region !== void 0) out["AWS_REGION"] = region;
|
|
599
665
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
666
|
+
return out;
|
|
667
|
+
}
|
|
668
|
+
function pointChildProcessesAtEmulator(url, port) {
|
|
669
|
+
setChildProcessAwsEnv((env) => {
|
|
670
|
+
for (const key of [
|
|
671
|
+
"CDKD_ROLE_ARN",
|
|
672
|
+
...EMULATOR_SCRUBBED_ENV_KEYS,
|
|
673
|
+
...CREDENTIAL_ENV_KEYS
|
|
674
|
+
]) delete env[key];
|
|
675
|
+
for (const key of Object.keys(env)) if (key.startsWith("AWS_ENDPOINT_URL") || key === "AWS_IGNORE_CONFIGURED_ENDPOINT_URLS") delete env[key];
|
|
676
|
+
return Object.assign(env, emulatorEnvironment(url, port, env));
|
|
677
|
+
});
|
|
604
678
|
}
|
|
605
679
|
function defaultProfileRegion(ini) {
|
|
606
680
|
let inDefault = false;
|
|
@@ -1148,6 +1222,50 @@ async function bootstrapDestroyCommand(options) {
|
|
|
1148
1222
|
}
|
|
1149
1223
|
}
|
|
1150
1224
|
|
|
1225
|
+
// src/cli/commands/bootstrap-state-bucket.ts
|
|
1226
|
+
async function createStateBucket(args) {
|
|
1227
|
+
const { s3, bucketName, region, report } = args;
|
|
1228
|
+
report(`Creating S3 bucket: ${bucketName} in region ${region}`);
|
|
1229
|
+
const createBucketParams = { Bucket: bucketName };
|
|
1230
|
+
if (region !== "us-east-1") createBucketParams.CreateBucketConfiguration = { LocationConstraint: region };
|
|
1231
|
+
await s3.send(new CreateBucketCommand(createBucketParams));
|
|
1232
|
+
report(`✓ Created S3 bucket: ${bucketName}`);
|
|
1233
|
+
}
|
|
1234
|
+
async function configureStateBucket(args) {
|
|
1235
|
+
const { s3, bucketName, accountId, report } = args;
|
|
1236
|
+
const logger = getLogger();
|
|
1237
|
+
logger.debug("Enabling bucket versioning...");
|
|
1238
|
+
await s3.send(new PutBucketVersioningCommand({
|
|
1239
|
+
Bucket: bucketName,
|
|
1240
|
+
ExpectedBucketOwner: accountId,
|
|
1241
|
+
VersioningConfiguration: { Status: "Enabled" }
|
|
1242
|
+
}));
|
|
1243
|
+
report("✓ Enabled bucket versioning");
|
|
1244
|
+
logger.debug("Enabling bucket encryption...");
|
|
1245
|
+
await s3.send(new PutBucketEncryptionCommand({
|
|
1246
|
+
Bucket: bucketName,
|
|
1247
|
+
ExpectedBucketOwner: accountId,
|
|
1248
|
+
ServerSideEncryptionConfiguration: { Rules: [{
|
|
1249
|
+
ApplyServerSideEncryptionByDefault: { SSEAlgorithm: "AES256" },
|
|
1250
|
+
BucketKeyEnabled: true
|
|
1251
|
+
}] }
|
|
1252
|
+
}));
|
|
1253
|
+
report("✓ Enabled bucket encryption (AES-256)");
|
|
1254
|
+
logger.debug("Setting bucket policy...");
|
|
1255
|
+
const bucketPolicy = buildDenyExternalAccessPolicy(bucketName, accountId, await s3.config.region());
|
|
1256
|
+
await s3.send(new PutBucketPolicyCommand({
|
|
1257
|
+
Bucket: bucketName,
|
|
1258
|
+
ExpectedBucketOwner: accountId,
|
|
1259
|
+
Policy: JSON.stringify(bucketPolicy)
|
|
1260
|
+
}));
|
|
1261
|
+
report("✓ Set bucket policy (deny external access)");
|
|
1262
|
+
logger.debug("Setting custom-resource response lifecycle rule...");
|
|
1263
|
+
const lifecycle = await applyCustomResourceResponseExpiration(s3, bucketName, { expectedBucketOwner: accountId });
|
|
1264
|
+
if (lifecycle.status === "failed" || lifecycle.status === "refused") logger.warn(customResourceResponseExpirationWarning(bucketName, lifecycle));
|
|
1265
|
+
else if (lifecycle.status === "added") report(safeMsg`✓ Set lifecycle rule (expire ${CUSTOM_RESOURCE_RESPONSE_PREFIX}/ responses after ${1} day)`);
|
|
1266
|
+
else report(safeMsg`✓ Lifecycle rule ${CUSTOM_RESOURCE_RESPONSE_LIFECYCLE_RULE_ID} already present (left unchanged)`);
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1151
1269
|
// src/cli/commands/bootstrap.ts
|
|
1152
1270
|
async function bootstrapCommand(options) {
|
|
1153
1271
|
const logger = getLogger();
|
|
@@ -1215,6 +1333,12 @@ async function bootstrapCommand(options) {
|
|
|
1215
1333
|
}
|
|
1216
1334
|
const rebuiltStateBucketClient = await rebuildClientForBucketRegion(s3Client, bucketName, { ...options.profile && { profile: options.profile } });
|
|
1217
1335
|
const stateBucketS3 = rebuiltStateBucketClient ?? s3Client;
|
|
1336
|
+
const stateBucketSetup = {
|
|
1337
|
+
s3: stateBucketS3,
|
|
1338
|
+
bucketName,
|
|
1339
|
+
accountId,
|
|
1340
|
+
report: (message) => logger.info(message)
|
|
1341
|
+
};
|
|
1218
1342
|
try {
|
|
1219
1343
|
let bucketExists = false;
|
|
1220
1344
|
try {
|
|
@@ -1242,45 +1366,14 @@ async function bootstrapCommand(options) {
|
|
|
1242
1366
|
logger.info(`State bucket ${bucketName} already exists — skipping reconfiguration (use --force to reconfigure)`);
|
|
1243
1367
|
skipStateBucketConfig = true;
|
|
1244
1368
|
} else logger.info("--force specified, continuing with existing bucket");
|
|
1245
|
-
} else {
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
logger.debug("Enabling bucket versioning...");
|
|
1254
|
-
await stateBucketS3.send(new PutBucketVersioningCommand({
|
|
1255
|
-
Bucket: bucketName,
|
|
1256
|
-
ExpectedBucketOwner: accountId,
|
|
1257
|
-
VersioningConfiguration: { Status: "Enabled" }
|
|
1258
|
-
}));
|
|
1259
|
-
logger.info("✓ Enabled bucket versioning");
|
|
1260
|
-
logger.debug("Enabling bucket encryption...");
|
|
1261
|
-
await stateBucketS3.send(new PutBucketEncryptionCommand({
|
|
1262
|
-
Bucket: bucketName,
|
|
1263
|
-
ExpectedBucketOwner: accountId,
|
|
1264
|
-
ServerSideEncryptionConfiguration: { Rules: [{
|
|
1265
|
-
ApplyServerSideEncryptionByDefault: { SSEAlgorithm: "AES256" },
|
|
1266
|
-
BucketKeyEnabled: true
|
|
1267
|
-
}] }
|
|
1268
|
-
}));
|
|
1269
|
-
logger.info("✓ Enabled bucket encryption (AES-256)");
|
|
1270
|
-
logger.debug("Setting bucket policy...");
|
|
1271
|
-
const bucketPolicy = buildDenyExternalAccessPolicy(bucketName, accountId, await stateBucketS3.config.region());
|
|
1272
|
-
await stateBucketS3.send(new PutBucketPolicyCommand({
|
|
1273
|
-
Bucket: bucketName,
|
|
1274
|
-
ExpectedBucketOwner: accountId,
|
|
1275
|
-
Policy: JSON.stringify(bucketPolicy)
|
|
1276
|
-
}));
|
|
1277
|
-
logger.info("✓ Set bucket policy (deny external access)");
|
|
1278
|
-
logger.debug("Setting custom-resource response lifecycle rule...");
|
|
1279
|
-
const lifecycle = await applyCustomResourceResponseExpiration(stateBucketS3, bucketName, { expectedBucketOwner: accountId });
|
|
1280
|
-
if (lifecycle.status === "failed" || lifecycle.status === "refused") logger.warn(customResourceResponseExpirationWarning(bucketName, lifecycle));
|
|
1281
|
-
else if (lifecycle.status === "added") logger.info(safeMsg`✓ Set lifecycle rule (expire ${CUSTOM_RESOURCE_RESPONSE_PREFIX}/ responses after ${1} day)`);
|
|
1282
|
-
else logger.info(safeMsg`✓ Lifecycle rule ${CUSTOM_RESOURCE_RESPONSE_LIFECYCLE_RULE_ID} already present (left unchanged)`);
|
|
1283
|
-
}
|
|
1369
|
+
} else await createStateBucket({
|
|
1370
|
+
...stateBucketSetup,
|
|
1371
|
+
region
|
|
1372
|
+
});
|
|
1373
|
+
if (!skipStateBucketConfig) await configureStateBucket({
|
|
1374
|
+
...stateBucketSetup,
|
|
1375
|
+
region
|
|
1376
|
+
});
|
|
1284
1377
|
let assetStorage;
|
|
1285
1378
|
if (options.assets) {
|
|
1286
1379
|
logger.info("\nSetting up cdkd asset storage...");
|
|
@@ -2140,7 +2233,7 @@ function collectCrossStackRefs(node, onRef, unconditional) {
|
|
|
2140
2233
|
// src/provisioning/register-providers.ts
|
|
2141
2234
|
let providerClasses;
|
|
2142
2235
|
function loadProviderClasses() {
|
|
2143
|
-
providerClasses ??= import("./provider-classes-
|
|
2236
|
+
providerClasses ??= import("./provider-classes-RMTfwJPz.js");
|
|
2144
2237
|
return providerClasses;
|
|
2145
2238
|
}
|
|
2146
2239
|
function registerAllProviders(registry, classes) {
|
|
@@ -2917,9 +3010,51 @@ var ExportIndexStore = class {
|
|
|
2917
3010
|
}
|
|
2918
3011
|
};
|
|
2919
3012
|
|
|
3013
|
+
// src/cli/commands/emulator-auto-bootstrap.ts
|
|
3014
|
+
async function ensureAwsEmulatorStateBucket(args) {
|
|
3015
|
+
if (!awsEndpointOverrideActive()) return void 0;
|
|
3016
|
+
const logger = getLogger();
|
|
3017
|
+
const accountId = (await args.sts.send(new GetCallerIdentityCommand({}))).Account;
|
|
3018
|
+
const bucketName = resolveStateBucketWithSource(args.cliBucket)?.bucket ?? getDefaultStateBucketName(accountId);
|
|
3019
|
+
try {
|
|
3020
|
+
await args.s3.send(new HeadBucketCommand({ Bucket: bucketName }));
|
|
3021
|
+
return;
|
|
3022
|
+
} catch (error) {
|
|
3023
|
+
const name = error.name;
|
|
3024
|
+
if (name !== "NotFound" && name !== "NoSuchBucket") return void 0;
|
|
3025
|
+
}
|
|
3026
|
+
const setup = {
|
|
3027
|
+
s3: args.s3,
|
|
3028
|
+
bucketName,
|
|
3029
|
+
accountId,
|
|
3030
|
+
region: args.region,
|
|
3031
|
+
report: (message) => logger.debug(message)
|
|
3032
|
+
};
|
|
3033
|
+
try {
|
|
3034
|
+
try {
|
|
3035
|
+
await createStateBucket(setup);
|
|
3036
|
+
} catch (error) {
|
|
3037
|
+
const code = error.name;
|
|
3038
|
+
if (code !== "BucketAlreadyOwnedByYou" && code !== "BucketAlreadyExists") throw error;
|
|
3039
|
+
}
|
|
3040
|
+
await configureStateBucket(setup);
|
|
3041
|
+
} catch (error) {
|
|
3042
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
3043
|
+
throw new CdkdError(safeMsg`AWS Emulator auto-bootstrap of state bucket ${bucketName} failed: ${msg}. ` + "Run `cdkd bootstrap --aws-emulator --force` to retry.", "AWS_EMULATOR_BOOTSTRAP_FAILED", error instanceof Error ? error : void 0);
|
|
3044
|
+
}
|
|
3045
|
+
logger.info(safeMsg`AWS Emulator had no cdkd bootstrap; bootstrapped it (state bucket ${bucketName}).`);
|
|
3046
|
+
return bucketName;
|
|
3047
|
+
}
|
|
3048
|
+
|
|
2920
3049
|
// src/cli/commands/deploy/prep.ts
|
|
2921
3050
|
async function prepareStateInfra(args) {
|
|
2922
3051
|
const { options, region, effectiveRegion, awsClients, logger } = args;
|
|
3052
|
+
if (!options.dryRun) await ensureAwsEmulatorStateBucket({
|
|
3053
|
+
cliBucket: options.stateBucket,
|
|
3054
|
+
region,
|
|
3055
|
+
s3: awsClients.s3,
|
|
3056
|
+
sts: awsClients.sts
|
|
3057
|
+
});
|
|
2923
3058
|
const resolvedStateBucket = await resolveStateBucketWithDefaultAndSource(options.stateBucket, region, legacyStateBucketFallbackRegion(effectiveRegion));
|
|
2924
3059
|
const stateBucket = resolvedStateBucket.bucket;
|
|
2925
3060
|
const preflightStateBackend = new S3StateBackend(awsClients.s3, {
|
|
@@ -3594,6 +3729,67 @@ function splitUpdatePartial(result) {
|
|
|
3594
3729
|
nestedUpdatePartial
|
|
3595
3730
|
};
|
|
3596
3731
|
}
|
|
3732
|
+
async function confirmAutoAssetStorageCreate(args) {
|
|
3733
|
+
const { assetRegion, accountId } = args;
|
|
3734
|
+
const logger = getLogger();
|
|
3735
|
+
if (awsEndpointOverrideActive()) {
|
|
3736
|
+
logger.info(safeMsg`Creating cdkd asset storage for region '${assetRegion}' in AWS Emulator ` + `(no prompt under --aws-emulator; opt out with --no-auto-asset-storage).`);
|
|
3737
|
+
return true;
|
|
3738
|
+
}
|
|
3739
|
+
if (args.yes || !process.stdin.isTTY) {
|
|
3740
|
+
logger.info(safeMsg`Creating cdkd asset storage for region '${assetRegion}' (first deploy into this ` + `region; opt out with --no-auto-asset-storage).`);
|
|
3741
|
+
return true;
|
|
3742
|
+
}
|
|
3743
|
+
return promptYesNo(`Region '${assetRegion}' has no cdkd asset storage yet. Create it now (S3 bucket cdkd-assets-${accountId}-${assetRegion} + container-asset ECR repo, out of 'cdk gc' reach)?`);
|
|
3744
|
+
}
|
|
3745
|
+
const FORCE_QUIT_ABORT_BUDGET_MS = 5e3;
|
|
3746
|
+
function exitAfterAbortingUploads(exit, write, abort = abortInFlightMultipartUploads, budgetMs = FORCE_QUIT_ABORT_BUDGET_MS) {
|
|
3747
|
+
let started;
|
|
3748
|
+
try {
|
|
3749
|
+
started = abort();
|
|
3750
|
+
} catch {
|
|
3751
|
+
started = {
|
|
3752
|
+
destinations: [],
|
|
3753
|
+
done: Promise.resolve()
|
|
3754
|
+
};
|
|
3755
|
+
}
|
|
3756
|
+
const { destinations } = started;
|
|
3757
|
+
let exited = false;
|
|
3758
|
+
const finish = (confirmed) => {
|
|
3759
|
+
if (exited) return;
|
|
3760
|
+
exited = true;
|
|
3761
|
+
if (destinations.length > 0) {
|
|
3762
|
+
const list = destinations.map((d) => displaySafe(d)).join(", ");
|
|
3763
|
+
write(confirmed ? `Interrupted: aborted the in-flight asset upload(s) ${list}.\n` : `Interrupted: exiting before the abort of the in-flight asset upload(s) ${list} was confirmed; the asset bucket's lifecycle rule removes what is left.\n`);
|
|
3764
|
+
}
|
|
3765
|
+
exit(130);
|
|
3766
|
+
};
|
|
3767
|
+
const timer = setTimeout(() => finish(false), budgetMs);
|
|
3768
|
+
return started.done.catch(() => void 0).then(() => {
|
|
3769
|
+
clearTimeout(timer);
|
|
3770
|
+
finish(true);
|
|
3771
|
+
});
|
|
3772
|
+
}
|
|
3773
|
+
function createDeploySigintHandler(options) {
|
|
3774
|
+
const write = options.write ?? ((text) => void process.stderr.write(text));
|
|
3775
|
+
const exit = options.exit ?? ((code) => process.exit(code));
|
|
3776
|
+
let signals = 0;
|
|
3777
|
+
return () => {
|
|
3778
|
+
signals++;
|
|
3779
|
+
if (signals === 1) {
|
|
3780
|
+
write("\nInterrupted — waiting for in-progress operations to complete...\n");
|
|
3781
|
+
options.onFirst();
|
|
3782
|
+
return;
|
|
3783
|
+
}
|
|
3784
|
+
if (signals > 2) {
|
|
3785
|
+
exit(130);
|
|
3786
|
+
return;
|
|
3787
|
+
}
|
|
3788
|
+
write(`
|
|
3789
|
+
Force-quit: stack locks may not be released. If the next run reports a lock, run this for EACH stack it names, in the region-qualified form — see the message that run prints.\nRelease with: ${forceQuitReleaseCommand()}\n`);
|
|
3790
|
+
exitAfterAbortingUploads(exit, write, options.abort, options.budgetMs);
|
|
3791
|
+
};
|
|
3792
|
+
}
|
|
3597
3793
|
|
|
3598
3794
|
// src/cli/commands/deploy/stack-deploy.ts
|
|
3599
3795
|
async function deployStackInScope(ctx, stackInfo, stackRegion, stackAwsClients) {
|
|
@@ -3645,7 +3841,7 @@ async function deployStackInScope(ctx, stackInfo, stackRegion, stackAwsClients)
|
|
|
3645
3841
|
const syncValidation = validateRecreateTargets({
|
|
3646
3842
|
template: stackInfo.template,
|
|
3647
3843
|
state: stateForRecreateCheck?.state ?? {
|
|
3648
|
-
version:
|
|
3844
|
+
version: 16,
|
|
3649
3845
|
stackName: stackInfo.stackName,
|
|
3650
3846
|
region: stackRegion,
|
|
3651
3847
|
resources: {},
|
|
@@ -3680,7 +3876,7 @@ async function deployStackInScope(ctx, stackInfo, stackRegion, stackAwsClients)
|
|
|
3680
3876
|
const replacedReaders = await findReplacedReadersOfRecreateTargets({
|
|
3681
3877
|
template: stackInfo.template,
|
|
3682
3878
|
state: stateForRecreateCheck?.state ?? {
|
|
3683
|
-
version:
|
|
3879
|
+
version: 16,
|
|
3684
3880
|
stackName: stackInfo.stackName,
|
|
3685
3881
|
region: stackRegion,
|
|
3686
3882
|
resources: {},
|
|
@@ -3908,15 +4104,9 @@ async function deployCommand(stacks, options) {
|
|
|
3908
4104
|
const callerIdentityPromise = fetchCallerIdentity(region);
|
|
3909
4105
|
callerIdentityPromise.catch(() => void 0);
|
|
3910
4106
|
let deployInterrupted = false;
|
|
3911
|
-
const topLevelSigintHandler = () => {
|
|
3912
|
-
if (deployInterrupted) {
|
|
3913
|
-
process.stderr.write(`
|
|
3914
|
-
Force-quit: stack locks may not be released. If the next run reports a lock, run this for EACH stack it names, in the region-qualified form — see the message that run prints.\nRelease with: ${forceQuitReleaseCommand()}\n`);
|
|
3915
|
-
process.exit(130);
|
|
3916
|
-
}
|
|
3917
|
-
process.stderr.write("\nInterrupted — waiting for in-progress operations to complete...\n");
|
|
4107
|
+
const topLevelSigintHandler = createDeploySigintHandler({ onFirst: () => {
|
|
3918
4108
|
deployInterrupted = true;
|
|
3919
|
-
};
|
|
4109
|
+
} });
|
|
3920
4110
|
process.on("SIGINT", topLevelSigintHandler);
|
|
3921
4111
|
const unforwardSigterm = forwardSigtermToSigint();
|
|
3922
4112
|
let preflightBackendForCleanup;
|
|
@@ -4033,13 +4223,11 @@ Force-quit: stack locks may not be released. If the next run reports a lock, run
|
|
|
4033
4223
|
const assetPublisher = new AssetPublisher();
|
|
4034
4224
|
const useCdkBootstrapAssets = resolveUseCdkBootstrapAssets(options.useCdkBootstrapAssets);
|
|
4035
4225
|
const autoAssetStorage = resolveAutoAssetStorage(options.autoAssetStorage);
|
|
4036
|
-
const confirmAutoAssetStorage =
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
return promptYesNo(`Region '${assetRegion}' has no cdkd asset storage yet. Create it now (S3 bucket cdkd-assets-${accountId}-${assetRegion} + container-asset ECR repo, out of 'cdk gc' reach)?`);
|
|
4042
|
-
};
|
|
4226
|
+
const confirmAutoAssetStorage = (assetRegion) => confirmAutoAssetStorageCreate({
|
|
4227
|
+
assetRegion,
|
|
4228
|
+
accountId,
|
|
4229
|
+
yes: options.yes === true
|
|
4230
|
+
});
|
|
4043
4231
|
const assetModeResolver = new AssetModeResolver(preflightStateBackend, accountId, {
|
|
4044
4232
|
...options.profile && { profile: options.profile },
|
|
4045
4233
|
...useCdkBootstrapAssets && { useCdkBootstrapAssets: true },
|
|
@@ -5718,6 +5906,7 @@ async function bindParametersAndConditions({ template, parameters, stackName, st
|
|
|
5718
5906
|
resources: currentState.resources,
|
|
5719
5907
|
stateBackend,
|
|
5720
5908
|
stackName,
|
|
5909
|
+
stackIdTail: () => stackIdTailOf(currentState, stackName),
|
|
5721
5910
|
bestEffort: true,
|
|
5722
5911
|
...mergedParameters && { parameters: mergedParameters },
|
|
5723
5912
|
...inheritedForResolver && { inheritedSecrets: inheritedForResolver },
|
|
@@ -5729,7 +5918,9 @@ async function bindParametersAndConditions({ template, parameters, stackName, st
|
|
|
5729
5918
|
effectiveTemplate = new TemplateParser().filterResourcesByCondition(template, conditions);
|
|
5730
5919
|
everyConditionKnown = unboundParameterNames.size === 0 && unknownConditions.size === 0;
|
|
5731
5920
|
} catch (error) {
|
|
5732
|
-
|
|
5921
|
+
const message = `Diff condition evaluation for stack ${displayStackName(stackName)} skipped: ${describeAwsFailure(error).detail}`;
|
|
5922
|
+
if (isSelectOutOfBounds(error)) logger.warn(`${message}. \`cdkd deploy\` refuses this template.`);
|
|
5923
|
+
else logger.debug(message);
|
|
5733
5924
|
}
|
|
5734
5925
|
if (mismatchedRecords.length > 0) logger.warn(safeMsg`Stack ${displayStackName(stackName)}: condition(s) ${mismatchedRecords.map((name) => displayIdent(name)).join(", ")} read a secret-fed parameter and changed since the last deploy, or one of their inputs did. This diff cannot tell which branch the next deploy takes, and shows each Fn::If on them as its FALSE branch.`);
|
|
5735
5926
|
const stillUnknown = [...unknownConditions].filter((name) => !Object.hasOwn(recordedVerdicts, name));
|
|
@@ -5903,6 +6094,7 @@ async function resolveChildStackParameters(parentStackRow, parentTemplate, paren
|
|
|
5903
6094
|
secretNameSink: derivedNameSink ?? /* @__PURE__ */ new Map(),
|
|
5904
6095
|
stateBackend,
|
|
5905
6096
|
stackName: parentStackName,
|
|
6097
|
+
stackIdTail: () => stackIdTailOf(parentState, parentStackName),
|
|
5906
6098
|
bestEffort: true,
|
|
5907
6099
|
...parentParameters && { parameters: parentParameters },
|
|
5908
6100
|
...parentConditions && { conditions: parentConditions },
|
|
@@ -6048,6 +6240,7 @@ async function computeStackDiff(currentState, template, region, stackName, state
|
|
|
6048
6240
|
resources: currentState.resources,
|
|
6049
6241
|
stateBackend,
|
|
6050
6242
|
stackName,
|
|
6243
|
+
stackIdTail: () => stackIdTailOf(currentState, stackName),
|
|
6051
6244
|
bestEffort: true,
|
|
6052
6245
|
...mergedParameters && { parameters: mergedParameters },
|
|
6053
6246
|
...conditions && { conditions },
|
|
@@ -6094,6 +6287,7 @@ async function computeStackDiff(currentState, template, region, stackName, state
|
|
|
6094
6287
|
resources: resourcesForInputs,
|
|
6095
6288
|
stateBackend,
|
|
6096
6289
|
stackName,
|
|
6290
|
+
stackIdTail: () => stackIdTailOf(currentState, stackName),
|
|
6097
6291
|
bestEffort: true,
|
|
6098
6292
|
...Object.keys(classified.bound).length > 0 && { parameters: classified.bound },
|
|
6099
6293
|
...conditions && Object.keys(conditions).length > 0 && { conditions },
|
|
@@ -6281,7 +6475,7 @@ async function loadStateOrEmpty(stackName, region, stateBackend, refusalRecovery
|
|
|
6281
6475
|
region,
|
|
6282
6476
|
resources: {},
|
|
6283
6477
|
outputs: {},
|
|
6284
|
-
version:
|
|
6478
|
+
version: 16,
|
|
6285
6479
|
lastModified: Date.now()
|
|
6286
6480
|
},
|
|
6287
6481
|
unreadable: [],
|
|
@@ -7693,7 +7887,7 @@ function abandonedScanWarning(subject, verdict) {
|
|
|
7693
7887
|
}
|
|
7694
7888
|
function abandonedScanStackNote(verdict, scans) {
|
|
7695
7889
|
const subject = `${scans} abandoned scan(s) above`;
|
|
7696
|
-
return verdict === "count" ? `${subject}: the resolver stops at the first {{resolve:...}} token it cannot fetch, so any secret after it in the same value recorded no needle and could not be rewritten. Re-run with --verbose for the cause of each
|
|
7890
|
+
return verdict === "count" ? `${subject}: the resolver stops at the first {{resolve:...}} token it cannot fetch, so any secret after it in the same value recorded no needle and could not be rewritten. ` + verboseAwareText("Re-run with --verbose for the cause of each.", "The cause of each is in the debug output above.") : `${subject}: the scan stopped on something cdkd scrub cannot resolve with template defaults alone — an unresolvable Ref or Fn::GetAtt, a parameter with no Default, or a reference whose own argument still holds an unsubstituted \${...}. These do NOT fail --fail, because scrub takes no --parameters and a gate failure here could not be cleared. Give the parameter a Default, or resolve the reference, to let scrub certify these records; otherwise accept that it cannot.`;
|
|
7697
7891
|
}
|
|
7698
7892
|
function abandonedScanVerdict(source, err) {
|
|
7699
7893
|
if (!carriesDynamicReference(source)) return "silent";
|
|
@@ -8865,7 +9059,7 @@ async function scrubStackRewritePass({ stack, region, stateBackend, opts, logger
|
|
|
8865
9059
|
const resolved = nestedRowParameters.get(logicalId);
|
|
8866
9060
|
const parameters = resolved?.complete === true ? nestedChildParameters(resolved.value) : void 0;
|
|
8867
9061
|
if (parameters === void 0) {
|
|
8868
|
-
refuse(`the Parameters ${shownStack} passes it could not be resolved to the values a deploy would hand it, so what it inherited is unknown`,
|
|
9062
|
+
refuse(`the Parameters ${shownStack} passes it could not be resolved to the values a deploy would hand it, so what it inherited is unknown`, verboseAwareText("Re-run cdkd scrub with --verbose to see which value failed to resolve, and fix that.", "The debug output above shows which value failed to resolve; fix that."));
|
|
8869
9063
|
continue;
|
|
8870
9064
|
}
|
|
8871
9065
|
nestedChildren.push({
|
|
@@ -9294,6 +9488,7 @@ async function scrubStack(stack, region, stateBackend, lockManager, opts) {
|
|
|
9294
9488
|
...Object.keys(parameters).length > 0 && { parameters },
|
|
9295
9489
|
...Object.keys(conditions).length > 0 && { conditions },
|
|
9296
9490
|
stackName: stack.stackName,
|
|
9491
|
+
stackIdTail: () => stackIdTailOf(state, stack.stackName),
|
|
9297
9492
|
stateBackend: resolverStateBackend,
|
|
9298
9493
|
...recordedSecretValues && { recordedSecretValues },
|
|
9299
9494
|
producerRegions,
|
|
@@ -12514,7 +12709,7 @@ function createIamPrincipalUniqueIdResolver(awsClients) {
|
|
|
12514
12709
|
const denied = /^AccessDenied|^NotAuthorized/i.test(name) || status === 403;
|
|
12515
12710
|
if (!warnedOnDenied && denied) {
|
|
12516
12711
|
warnedOnDenied = true;
|
|
12517
|
-
getLogger().warn(`Cannot read IAM principals (${name || "access denied"}). A resource policy whose principal AWS rendered as a unique id (AROA…/AIDA…) may therefore report drift that is only a spelling difference; grant iam:GetRole / iam:GetUser to resolve it, or re-run with --verbose for the full error.`);
|
|
12712
|
+
getLogger().warn(`Cannot read IAM principals (${name || "access denied"}). A resource policy whose principal AWS rendered as a unique id (AROA…/AIDA…) may therefore report drift that is only a spelling difference; grant iam:GetRole / iam:GetUser to resolve ` + safeMsg`it${verboseAwareText(", or re-run with --verbose for the full error", " (the full error is in the debug output)")}.`);
|
|
12518
12713
|
}
|
|
12519
12714
|
getLogger().debug(`Could not resolve the unique id of principal ${displayIdent(arn, { maxCodePoints: 613 })} (${displayAwsMessage(message)}); leaving the policy principal comparison untouched.`);
|
|
12520
12715
|
if (isThrottlingError(error)) return void 0;
|
|
@@ -16662,6 +16857,7 @@ async function buildResolvedParametersPerStack(args) {
|
|
|
16662
16857
|
secretNameSink: /* @__PURE__ */ new Map(),
|
|
16663
16858
|
parameters: parentParamValues,
|
|
16664
16859
|
stackName: parentNode.cdkdName,
|
|
16860
|
+
stackIdTail: () => stackIdTailOf(parentNode.state, parentNode.cdkdName),
|
|
16665
16861
|
...args.stateBackend && { stateBackend: args.stateBackend }
|
|
16666
16862
|
};
|
|
16667
16863
|
const { params, intrinsicSkipped } = await resolveChildImportParameters(parentNode.template, parentResolverContext, parentLogicalId, args.resolver);
|
|
@@ -21014,7 +21210,7 @@ function refuseDivergentRecordRegionForRollback(state, stackName, keyRegion, div
|
|
|
21014
21210
|
const resourceCount = isReadableBag(state.resources) ? Object.keys(state.resources).length : void 0;
|
|
21015
21211
|
if (resourceCount === 0 && provenOrphans === 0) return;
|
|
21016
21212
|
const lists = resourceCount === void 0 ? "its resources map cannot be read" : resourceCount > 0 ? `it still lists ${resourceCount} resource${resourceCount === 1 ? "" : "s"}` : `its journal holds ${provenOrphans} failed create${provenOrphans === 1 ? "" : "s"} whose resource the rollback would delete`;
|
|
21017
|
-
throw markNonRetryable(new CdkdError(`cdkd will not roll back ${plainOrDescribed(stackName, "stack name")} (${plainOrDescribed(keyRegion, "region")}): the state record read from that region's key carries a 'region' of its own (${describeRegionValueKind(divergentBodyRegion)}) that is not the key's, and ${lists} — so cdkd cannot tell which region they are in. cdkd stamps the key's region into every record it writes, so this record was not written by cdkd. The replay would issue every delete and revert against the key's region; if the record's own region is the honest half, each delete comes back not-found, which the replay reads as ALREADY DELETED — it would report the resource rolled back, drop it from the record, and leave it standing in the other region. Nothing was changed. Re-run with --verbose to see what the record's region field holds, repair that field to match the key it is stored under, and run the rollback again
|
|
21213
|
+
throw markNonRetryable(new CdkdError(`cdkd will not roll back ${plainOrDescribed(stackName, "stack name")} (${plainOrDescribed(keyRegion, "region")}): the state record read from that region's key carries a 'region' of its own (${describeRegionValueKind(divergentBodyRegion)}) that is not the key's, and ${lists} — so cdkd cannot tell which region they are in. cdkd stamps the key's region into every record it writes, so this record was not written by cdkd. The replay would issue every delete and revert against the key's region; if the record's own region is the honest half, each delete comes back not-found, which the replay reads as ALREADY DELETED — it would report the resource rolled back, drop it from the record, and leave it standing in the other region. Nothing was changed. ` + verboseAwareText("Re-run with --verbose to see what the record's region field holds, ", "The debug output shows what the record's region field holds; ") + "repair that field to match the key it is stored under, and run the rollback again.", STATE_REGION_DIVERGED));
|
|
21018
21214
|
}
|
|
21019
21215
|
function divergedDuringRollbackMessage(divergentBodyRegion) {
|
|
21020
21216
|
return `the state record was rewritten during this rollback, and the rewrite carries a 'region' of its own (${describeRegionValueKind(divergentBodyRegion)}) that is not the region of its key, so cdkd did not write over it`;
|
|
@@ -21296,7 +21492,7 @@ async function runRollbackReplay(ctx) {
|
|
|
21296
21492
|
...carriedState,
|
|
21297
21493
|
...stackInstanceIdCarriedFrom(baseState),
|
|
21298
21494
|
...supersededAfterRollback(baseState, supersededHost),
|
|
21299
|
-
version:
|
|
21495
|
+
version: 16,
|
|
21300
21496
|
region,
|
|
21301
21497
|
resources: { ...stateResources },
|
|
21302
21498
|
...orphansAfterRollback(baseState, mintedOrphans),
|
|
@@ -24563,7 +24759,9 @@ async function resolveImportedProperties(stackState, template, region, stateBack
|
|
|
24563
24759
|
parameters
|
|
24564
24760
|
});
|
|
24565
24761
|
} catch (err) {
|
|
24566
|
-
|
|
24762
|
+
const message = `Template condition evaluation failed during import-time property resolution: ${describeAwsFailure(err).detail} — continuing without conditions.`;
|
|
24763
|
+
if (isSelectOutOfBounds(err)) logger.warn(message);
|
|
24764
|
+
else logger.debug(message);
|
|
24567
24765
|
}
|
|
24568
24766
|
const unboundParameterNames = Object.keys(template.Parameters ?? {}).filter((name) => isUnboundTemplateParameter(name, template, parameters));
|
|
24569
24767
|
let divergentParameters;
|
|
@@ -24592,7 +24790,8 @@ async function resolveImportedProperties(stackState, template, region, stateBack
|
|
|
24592
24790
|
...Object.keys(parameters).length > 0 && { parameters },
|
|
24593
24791
|
...Object.keys(conditions).length > 0 && { conditions },
|
|
24594
24792
|
stateBackend,
|
|
24595
|
-
stackName: stackState.stackName
|
|
24793
|
+
stackName: stackState.stackName,
|
|
24794
|
+
stackIdTail: () => stackIdTailOf(stackState, stackState.stackName)
|
|
24596
24795
|
};
|
|
24597
24796
|
const noEchoInputs = /* @__PURE__ */ new Map();
|
|
24598
24797
|
for (const [logicalId, resource] of entries) {
|
|
@@ -24811,7 +25010,7 @@ function buildStackState(stackName, region, rows, templateParser, template, exis
|
|
|
24811
25010
|
}
|
|
24812
25011
|
if (namesParameter?.failedClosed !== void 0) getLogger().debug(`The template's parameter dependence could not be judged (${namesParameter.failedClosed}): every prior observed-baseline refusal recorded without a reason is carried as an unverifiable-parameter refusal.`);
|
|
24813
25012
|
return {
|
|
24814
|
-
version:
|
|
25013
|
+
version: 16,
|
|
24815
25014
|
stackName,
|
|
24816
25015
|
region,
|
|
24817
25016
|
resources,
|
|
@@ -25097,6 +25296,14 @@ async function runLockedImport(ctx) {
|
|
|
25097
25296
|
}
|
|
25098
25297
|
}
|
|
25099
25298
|
const deployedParameters = !namesAnyDeclaredParameter(stateTemplate) ? void 0 : migrationCfnStackName !== void 0 ? await readDeployedParameters(migrationCfnStackName, regionClients.cloudFormation, logger, displaySafe(migrationCfnStackName)) : await readDeployedParameters(stackInfo.stackName, regionClients.cloudFormation, logger, displaySafe(stackInfo.stackName), { absentStackIsNoSource: true });
|
|
25299
|
+
if (existingState === null && typeof stateBackend.peekStackInstanceSibling === "function") {
|
|
25300
|
+
const sibling = await stateBackend.peekStackInstanceSibling(stackInfo.stackName, targetRegion);
|
|
25301
|
+
if (sibling?.stackIdFromInstance === true) stackState = {
|
|
25302
|
+
...stackState,
|
|
25303
|
+
stackInstanceId: sibling.stackInstanceId,
|
|
25304
|
+
stackIdFromInstance: true
|
|
25305
|
+
};
|
|
25306
|
+
}
|
|
25100
25307
|
const unsafeObservedBaselineLogicalIds = await withSharedDrainBudget(() => resolveImportedProperties(stackState, stateTemplate, targetRegion, stateBackend, logger, deployedParameters));
|
|
25101
25308
|
await captureObservedForImportedResources(stackState, providerRegistry, logger, unsafeObservedBaselineLogicalIds, rebuiltLogicalIdsFrom(rows, stateTemplate));
|
|
25102
25309
|
const saveOptions = {};
|
|
@@ -25148,7 +25355,6 @@ async function importCommand(stackArg, options) {
|
|
|
25148
25355
|
const effectiveRegion = await resolveEffectiveRegion(options);
|
|
25149
25356
|
exportInferredRegionForSdk(effectiveRegion);
|
|
25150
25357
|
const region = effectiveRegion.region;
|
|
25151
|
-
const stateBucket = await resolveStateBucketWithDefault(options.stateBucket, region, legacyStateBucketFallbackRegion(effectiveRegion));
|
|
25152
25358
|
if (options.region) {
|
|
25153
25359
|
process.env["AWS_REGION"] = options.region;
|
|
25154
25360
|
process.env["AWS_DEFAULT_REGION"] = options.region;
|
|
@@ -25160,6 +25366,13 @@ async function importCommand(stackArg, options) {
|
|
|
25160
25366
|
setAwsClients(awsClients);
|
|
25161
25367
|
let targetClients;
|
|
25162
25368
|
try {
|
|
25369
|
+
if (!options.dryRun) await ensureAwsEmulatorStateBucket({
|
|
25370
|
+
cliBucket: options.stateBucket,
|
|
25371
|
+
region,
|
|
25372
|
+
s3: awsClients.s3,
|
|
25373
|
+
sts: awsClients.sts
|
|
25374
|
+
});
|
|
25375
|
+
const stateBucket = await resolveStateBucketWithDefault(options.stateBucket, region, legacyStateBucketFallbackRegion(effectiveRegion));
|
|
25163
25376
|
const stateConfig = {
|
|
25164
25377
|
bucket: stateBucket,
|
|
25165
25378
|
prefix: options.statePrefix
|
|
@@ -25387,20 +25600,21 @@ function hasSdkMetadata(error) {
|
|
|
25387
25600
|
async function loadStateForStack(stackName, synthRegion, opts) {
|
|
25388
25601
|
const logger = getLogger();
|
|
25389
25602
|
const prefix = opts.logPrefix ?? "--from-state";
|
|
25603
|
+
const warn = opts.warn ?? ((message) => logger.warn(message));
|
|
25390
25604
|
const region = canonicalizeRegion(opts.region ?? process.env["AWS_REGION"] ?? process.env["AWS_DEFAULT_REGION"] ?? synthRegion ?? "us-east-1");
|
|
25391
25605
|
const clientRegion = canonicalizeRegion(opts.region) || void 0;
|
|
25392
25606
|
let stateBucket;
|
|
25393
25607
|
try {
|
|
25394
25608
|
stateBucket = await resolveStateBucketWithDefault(opts.stateBucket, region);
|
|
25395
25609
|
} catch (err) {
|
|
25396
|
-
|
|
25610
|
+
warn(`${prefix}: could not resolve state bucket: ${describeLocalAwsFailureForWarn(err, "state bucket resolution")}. Falling back.`);
|
|
25397
25611
|
return;
|
|
25398
25612
|
}
|
|
25399
25613
|
const awsClients = new AwsClients({
|
|
25400
25614
|
...clientRegion !== void 0 && { region: clientRegion },
|
|
25401
25615
|
...opts.profile !== void 0 && { profile: opts.profile }
|
|
25402
25616
|
});
|
|
25403
|
-
setAwsClients(awsClients);
|
|
25617
|
+
if (!opts.scopedClients) setAwsClients(awsClients);
|
|
25404
25618
|
try {
|
|
25405
25619
|
const stateConfig = {
|
|
25406
25620
|
bucket: stateBucket,
|
|
@@ -25417,7 +25631,7 @@ async function loadStateForStack(stackName, synthRegion, opts) {
|
|
|
25417
25631
|
}
|
|
25418
25632
|
const refs = (await stateBackend.listStacks()).filter((r) => r.stackName === stackName);
|
|
25419
25633
|
if (refs.length === 0) {
|
|
25420
|
-
|
|
25634
|
+
warn(`${prefix}: no cdkd state found for stack '${stackName}' in bucket '${stateBucket}'. Was it deployed via 'cdkd deploy'? Falling back.`);
|
|
25421
25635
|
return;
|
|
25422
25636
|
}
|
|
25423
25637
|
const findByRegion = (candidate, source) => {
|
|
@@ -25426,7 +25640,7 @@ async function loadStateForStack(stackName, synthRegion, opts) {
|
|
|
25426
25640
|
const chosen = exact ?? folded[0];
|
|
25427
25641
|
if (folded.length > 1 && chosen) {
|
|
25428
25642
|
const how = exact ? `matches ${source} '${candidate}' exactly` : `no record spells ${source} '${candidate}' exactly, so this is a case-insensitive recovery`;
|
|
25429
|
-
|
|
25643
|
+
warn(`${prefix}: stack '${stackName}' has state under ${folded.length} case-variant spellings of ${source} '${candidate}' (${folded.map((r) => r.region ?? "(legacy)").join(", ")}). Reading '${chosen.region ?? "(legacy)"}' — ${how}.`);
|
|
25430
25644
|
}
|
|
25431
25645
|
return chosen;
|
|
25432
25646
|
};
|
|
@@ -25437,8 +25651,7 @@ async function loadStateForStack(stackName, synthRegion, opts) {
|
|
|
25437
25651
|
const requestedRegion = opts.rawStackRegion ?? opts.stackRegion;
|
|
25438
25652
|
const found = findByRegion(requestedRegion, "--stack-region");
|
|
25439
25653
|
if (!found) {
|
|
25440
|
-
|
|
25441
|
-
logger.warn(`${prefix}: stack '${stackName}' has no state in region '${requestedRegion}' (available: ${seen}). Falling back.`);
|
|
25654
|
+
warn(`${prefix}: stack '${stackName}' has no state in region '${requestedRegion}' (available: ${refs.map((r) => r.region ?? "(legacy)").join(", ")}). Falling back.`);
|
|
25442
25655
|
return;
|
|
25443
25656
|
}
|
|
25444
25657
|
targetRegion = found.region ?? requestedRegion;
|
|
@@ -25446,12 +25659,12 @@ async function loadStateForStack(stackName, synthRegion, opts) {
|
|
|
25446
25659
|
else if (refs.length === 1) targetRegion = refs[0].region ?? synthRegion ?? region;
|
|
25447
25660
|
else {
|
|
25448
25661
|
const seen = refs.map((r) => r.region === void 0 ? "(legacy)" : regionShown(r.region)).join(", ");
|
|
25449
|
-
|
|
25662
|
+
warn(`${prefix}: stack ${quotedOrDescribed(stackName, "stack name")} has state in multiple regions (${seen}). Re-run with --stack-region '<region>'. Falling back.`);
|
|
25450
25663
|
return;
|
|
25451
25664
|
}
|
|
25452
25665
|
const stateData = await stateBackend.getState(stackName, targetRegion);
|
|
25453
25666
|
if (!stateData) {
|
|
25454
|
-
|
|
25667
|
+
warn(`${prefix}: state record for '${stackName}' (${targetRegion}) returned empty. Falling back.`);
|
|
25455
25668
|
return;
|
|
25456
25669
|
}
|
|
25457
25670
|
logger.debug(`${prefix}: loaded state for ${stackName} (${targetRegion})`);
|
|
@@ -25461,7 +25674,8 @@ async function loadStateForStack(stackName, synthRegion, opts) {
|
|
|
25461
25674
|
stateBucket
|
|
25462
25675
|
};
|
|
25463
25676
|
} finally {
|
|
25464
|
-
|
|
25677
|
+
if (opts.scopedClients) awsClients.destroy();
|
|
25678
|
+
else resetAwsClients();
|
|
25465
25679
|
}
|
|
25466
25680
|
}
|
|
25467
25681
|
async function loadBootstrapContainerRepo(synthRegion, opts) {
|
|
@@ -25645,12 +25859,13 @@ function describeStateBucketAccessFailure(err) {
|
|
|
25645
25859
|
|
|
25646
25860
|
// src/local/s3-local-state-provider.ts
|
|
25647
25861
|
var S3LocalStateProvider = class {
|
|
25648
|
-
label
|
|
25862
|
+
label;
|
|
25649
25863
|
opts;
|
|
25650
25864
|
disposers = [];
|
|
25651
25865
|
warnedMalformedProducers = /* @__PURE__ */ new Set();
|
|
25652
25866
|
constructor(opts) {
|
|
25653
25867
|
this.opts = opts;
|
|
25868
|
+
this.label = opts.logPrefix ?? "--from-state";
|
|
25654
25869
|
}
|
|
25655
25870
|
async load(stackName, synthRegion) {
|
|
25656
25871
|
const loadOpts = {
|
|
@@ -25659,7 +25874,10 @@ var S3LocalStateProvider = class {
|
|
|
25659
25874
|
...this.opts.rawStackRegion !== void 0 && { rawStackRegion: this.opts.rawStackRegion },
|
|
25660
25875
|
...this.opts.stateBucket !== void 0 && { stateBucket: this.opts.stateBucket },
|
|
25661
25876
|
...this.opts.region !== void 0 && { region: this.opts.region },
|
|
25662
|
-
...this.opts.profile !== void 0 && { profile: this.opts.profile }
|
|
25877
|
+
...this.opts.profile !== void 0 && { profile: this.opts.profile },
|
|
25878
|
+
...this.opts.logPrefix !== void 0 && { logPrefix: this.opts.logPrefix },
|
|
25879
|
+
...this.opts.warn !== void 0 && { warn: this.opts.warn },
|
|
25880
|
+
...this.opts.scopedClients === true && { scopedClients: true }
|
|
25663
25881
|
};
|
|
25664
25882
|
const loaded = await loadStateForStack(stackName, synthRegion, loadOpts);
|
|
25665
25883
|
if (!loaded) return void 0;
|
|
@@ -25705,24 +25923,92 @@ var S3LocalStateProvider = class {
|
|
|
25705
25923
|
}
|
|
25706
25924
|
};
|
|
25707
25925
|
|
|
25926
|
+
// src/local/mixed-mode-state.ts
|
|
25927
|
+
const REAL_FROM_STATE_LABEL = "--from-state (real AWS)";
|
|
25928
|
+
function realMissReason(message) {
|
|
25929
|
+
return (message.startsWith(`${"--from-state (real AWS)"}: `) ? message.slice(25) : message).replace(/\s*Was it deployed via 'cdkd deploy'\?/, "").replace(/\s*Falling back\.\s*$/, "").replace(/\.\s*$/, "");
|
|
25930
|
+
}
|
|
25931
|
+
function serialQueue() {
|
|
25932
|
+
let tail = Promise.resolve();
|
|
25933
|
+
return (job) => {
|
|
25934
|
+
const run = tail.then(job, job);
|
|
25935
|
+
tail = run.catch(() => void 0);
|
|
25936
|
+
return run;
|
|
25937
|
+
};
|
|
25938
|
+
}
|
|
25939
|
+
function createMixedModeFromStateProvider(opts, realServices) {
|
|
25940
|
+
if (realServices.length === 0) return new S3LocalStateProvider(opts);
|
|
25941
|
+
const serial = serialQueue();
|
|
25942
|
+
const emulatorInner = new S3LocalStateProvider(opts);
|
|
25943
|
+
const emulator = {
|
|
25944
|
+
label: emulatorInner.label,
|
|
25945
|
+
load: (stackName, synthRegion) => serial(() => emulatorInner.load(stackName, synthRegion)),
|
|
25946
|
+
buildCrossStackResolver: (region) => serial(() => emulatorInner.buildCrossStackResolver(region)),
|
|
25947
|
+
dispose: () => emulatorInner.dispose()
|
|
25948
|
+
};
|
|
25949
|
+
let lastLoadError;
|
|
25950
|
+
const realInner = new S3LocalStateProvider({
|
|
25951
|
+
...opts,
|
|
25952
|
+
logPrefix: REAL_FROM_STATE_LABEL,
|
|
25953
|
+
warn: (message) => {
|
|
25954
|
+
lastLoadError ??= realMissReason(message);
|
|
25955
|
+
getLogger().debug(message);
|
|
25956
|
+
},
|
|
25957
|
+
scopedClients: true
|
|
25958
|
+
});
|
|
25959
|
+
return createMixedModeStateProvider({
|
|
25960
|
+
emulator,
|
|
25961
|
+
real: {
|
|
25962
|
+
label: REAL_FROM_STATE_LABEL,
|
|
25963
|
+
load: (stackName, synthRegion) => serial(() => runWithRealAws(async () => {
|
|
25964
|
+
lastLoadError = void 0;
|
|
25965
|
+
const region = canonicalizeRegion(opts.stackRegion ?? opts.region ?? synthRegion ?? process.env["AWS_REGION"] ?? process.env["AWS_DEFAULT_REGION"]) || "us-east-1";
|
|
25966
|
+
const clients = new AwsClients({
|
|
25967
|
+
region,
|
|
25968
|
+
...opts.profile && { profile: opts.profile }
|
|
25969
|
+
});
|
|
25970
|
+
try {
|
|
25971
|
+
return await runWithStackAwsClients(clients, () => realInner.load(stackName, synthRegion));
|
|
25972
|
+
} catch (err) {
|
|
25973
|
+
lastLoadError = realMissReason(err instanceof Error ? err.message : String(err));
|
|
25974
|
+
return;
|
|
25975
|
+
} finally {
|
|
25976
|
+
clients.destroy();
|
|
25977
|
+
}
|
|
25978
|
+
})),
|
|
25979
|
+
buildCrossStackResolver: () => Promise.resolve(void 0),
|
|
25980
|
+
getLastLoadError: () => lastLoadError,
|
|
25981
|
+
dispose: () => realInner.dispose()
|
|
25982
|
+
},
|
|
25983
|
+
realServices
|
|
25984
|
+
});
|
|
25985
|
+
}
|
|
25986
|
+
|
|
25708
25987
|
// src/cli/commands/local-state-source.ts
|
|
25709
|
-
const fromStateFactory = (options) => {
|
|
25988
|
+
const fromStateFactory = (options, behavior) => {
|
|
25989
|
+
const providerOpts = s3ProviderOptions(options);
|
|
25990
|
+
const mixed = getActiveWorkloadAwsWiring()?.mixed;
|
|
25991
|
+
if (!mixed) return new S3LocalStateProvider(providerOpts);
|
|
25992
|
+
const realServices = awsEmulatorRealServices(behavior.workload) ?? mixed.realServices;
|
|
25993
|
+
return createMixedModeFromStateProvider(providerOpts, realServices);
|
|
25994
|
+
};
|
|
25995
|
+
function s3ProviderOptions(options) {
|
|
25710
25996
|
const opts = options;
|
|
25711
25997
|
const clientRegion = canonicalizeRegion(opts.region) || void 0;
|
|
25712
25998
|
const stackRegion = canonicalizeRegion(opts.stackRegion) || void 0;
|
|
25713
25999
|
const rawStackRegion = opts.rawStackRegion || opts.stackRegion || void 0;
|
|
25714
|
-
return
|
|
26000
|
+
return {
|
|
25715
26001
|
statePrefix: opts.statePrefix,
|
|
25716
26002
|
...opts.stateBucket !== void 0 && { stateBucket: opts.stateBucket },
|
|
25717
26003
|
...clientRegion !== void 0 && { region: clientRegion },
|
|
25718
26004
|
...opts.profile !== void 0 && { profile: opts.profile },
|
|
25719
26005
|
...stackRegion !== void 0 && { stackRegion },
|
|
25720
26006
|
...rawStackRegion !== void 0 && { rawStackRegion }
|
|
25721
|
-
}
|
|
25722
|
-
}
|
|
26007
|
+
};
|
|
26008
|
+
}
|
|
25723
26009
|
const cdkdExtraStateProviders = { fromState: fromStateFactory };
|
|
25724
|
-
function createLocalStateProvider$1(options, cdkdStackName, synthRegion) {
|
|
25725
|
-
return createLocalStateProvider(options, cdkdStackName, synthRegion, cdkdExtraStateProviders);
|
|
26010
|
+
function createLocalStateProvider$1(options, cdkdStackName, synthRegion, behavior = {}) {
|
|
26011
|
+
return createLocalStateProvider(options, cdkdStackName, synthRegion, cdkdExtraStateProviders, behavior);
|
|
25726
26012
|
}
|
|
25727
26013
|
|
|
25728
26014
|
// src/local/docker-runner.ts
|
|
@@ -25763,6 +26049,7 @@ async function runDetached(opts) {
|
|
|
25763
26049
|
const wiring = getActiveWorkloadAwsWiring$1();
|
|
25764
26050
|
if (!wiring) return runDetachedContainer(opts);
|
|
25765
26051
|
const wired = await applyLocalAwsWiring(wiring, opts.env, opts.extraMounts ?? [], opts.mounts.map((m) => m.containerPath));
|
|
26052
|
+
if (opts.network === "host" && wiring.sidecar?.passthrough && wired.env["AWS_ENDPOINT_URL_SQS"] === wiring.sidecar.endpoint) delete wired.env["AWS_ENDPOINT_URL_SQS"];
|
|
25766
26053
|
const wiredOpts = {
|
|
25767
26054
|
...opts,
|
|
25768
26055
|
env: wired.env,
|
|
@@ -25805,7 +26092,7 @@ async function runDetachedContainer(opts) {
|
|
|
25805
26092
|
args.push("--entrypoint", opts.entryPoint[0]);
|
|
25806
26093
|
entryPointTail = opts.entryPoint.slice(1);
|
|
25807
26094
|
}
|
|
25808
|
-
args.push(opts.image, ...entryPointTail, ...opts.cmd);
|
|
26095
|
+
args.push(...noImplicitEcrPullArgs(opts.image), opts.image, ...entryPointTail, ...opts.cmd);
|
|
25809
26096
|
const logger = getLogger().child("docker");
|
|
25810
26097
|
logger.debug(`${getDockerCmd()} ${redactDockerArgvValues(args).join(" ")}`);
|
|
25811
26098
|
if (collisions.length > 0) logger.warn(`Env var(s) ${collisions.map((k) => JSON.stringify(k)).join(", ")} share a name with a variable the container client reads (docker, or the CDK_DOCKER binary) or have a malformed name (empty, or containing '=' / NUL), and were NOT passed to the container at all (a colliding name would hijack that client; a malformed name cannot form a valid environment variable). Rename the env var if the container needs it.`);
|
|
@@ -27271,22 +27558,30 @@ function dynamicReferenceSpecOptions(options) {
|
|
|
27271
27558
|
// src/local/dynamic-reference.ts
|
|
27272
27559
|
function createCallerDynamicReferenceResolver(profile) {
|
|
27273
27560
|
return new DynamicReferenceResolver({
|
|
27274
|
-
secretsManagerClientFactory: (region) =>
|
|
27275
|
-
|
|
27276
|
-
|
|
27277
|
-
|
|
27278
|
-
|
|
27279
|
-
|
|
27280
|
-
|
|
27281
|
-
|
|
27282
|
-
|
|
27283
|
-
|
|
27284
|
-
|
|
27285
|
-
|
|
27286
|
-
|
|
27287
|
-
|
|
27288
|
-
|
|
27289
|
-
|
|
27561
|
+
secretsManagerClientFactory: (region, route) => {
|
|
27562
|
+
const realAws = realAwsException("SECRETS_MANAGER", route.workload);
|
|
27563
|
+
return new SecretsManagerClient({
|
|
27564
|
+
...awsClientDefaults({
|
|
27565
|
+
profile,
|
|
27566
|
+
ignoreAssumedRole: true,
|
|
27567
|
+
realAws
|
|
27568
|
+
}),
|
|
27569
|
+
...region && { region: canonicalizeRegion(region) },
|
|
27570
|
+
...profile && { profile }
|
|
27571
|
+
});
|
|
27572
|
+
},
|
|
27573
|
+
ssmClientFactory: (region, route) => {
|
|
27574
|
+
const realAws = realAwsException("SSM", route.workload);
|
|
27575
|
+
return new SSMClient({
|
|
27576
|
+
...awsClientDefaults({
|
|
27577
|
+
profile,
|
|
27578
|
+
ignoreAssumedRole: true,
|
|
27579
|
+
realAws
|
|
27580
|
+
}),
|
|
27581
|
+
...region && { region: canonicalizeRegion(region) },
|
|
27582
|
+
...profile && { profile }
|
|
27583
|
+
});
|
|
27584
|
+
}
|
|
27290
27585
|
});
|
|
27291
27586
|
}
|
|
27292
27587
|
|
|
@@ -27372,7 +27667,12 @@ function isCredentialFresh(creds) {
|
|
|
27372
27667
|
if (!creds.expiration) return false;
|
|
27373
27668
|
return creds.expiration.getTime() - Date.now() > STS_CREDENTIAL_SAFETY_MARGIN_MS;
|
|
27374
27669
|
}
|
|
27670
|
+
const ECR_EMULATOR_REFUSAL = (image) => `--aws-emulator: image ${image} is in a real ECR registry, and ECR is not excepted to real AWS for this workload, so it is not pulled (AWS Emulator serves no registry docker can pull from). To pull it from real ECR with your real identity, except ECR for the workload in the --env-vars file ("AWS_ENDPOINT_URL_ECR": "real-aws", under "Parameters" or the workload's own section); or pull the image yourself and pass --no-pull.`;
|
|
27375
27671
|
async function pullEcrImage(imageUri, options) {
|
|
27672
|
+
if (realAwsException("ECR", options.workload)) return runWithRealAws(() => pullEcrImageOnSide(imageUri, options, "real"));
|
|
27673
|
+
return pullEcrImageOnSide(imageUri, options, "default");
|
|
27674
|
+
}
|
|
27675
|
+
async function pullEcrImageOnSide(imageUri, options, side) {
|
|
27376
27676
|
const logger = getLogger().child("ecr-puller");
|
|
27377
27677
|
const parsed = parseEcrUri(imageUri);
|
|
27378
27678
|
if (!parsed) throw new LocalInvokeBuildError$1(`Image URI '${imageUri}' is not an ECR URI. cdkd local invoke v1 only authenticates against ECR for the deployed-image fallback path.`);
|
|
@@ -27383,8 +27683,9 @@ async function pullEcrImage(imageUri, options) {
|
|
|
27383
27683
|
await verifyImageInLocalCache(canonicalUri);
|
|
27384
27684
|
return canonicalUri;
|
|
27385
27685
|
}
|
|
27686
|
+
if (side === "default" && isAwsServiceRoutedToEmulator("ECR", options.workload)) throw new LocalInvokeBuildError$1(ECR_EMULATOR_REFUSAL(displayIdent(canonicalUri)));
|
|
27386
27687
|
const credentialConfig = ambientCredentialConfig();
|
|
27387
|
-
const identityFingerprint = credentialFingerprint(credentialConfig);
|
|
27688
|
+
const identityFingerprint = injectiveKey(side, credentialFingerprint(credentialConfig));
|
|
27388
27689
|
const callerIdentityKey = injectiveKey(identityFingerprint, callerRegion ?? "_unset");
|
|
27389
27690
|
let callerAccount = CALLER_IDENTITY_CACHE.get(callerIdentityKey);
|
|
27390
27691
|
if (callerAccount === void 0) {
|
|
@@ -27431,8 +27732,9 @@ async function pullEcrImage(imageUri, options) {
|
|
|
27431
27732
|
region: parsed.region,
|
|
27432
27733
|
...assumed && { credentials: assumed }
|
|
27433
27734
|
});
|
|
27735
|
+
const dockerEnv = dockerRegistryEnv(options.workload);
|
|
27434
27736
|
try {
|
|
27435
|
-
await ecrLogin(ecr, {
|
|
27737
|
+
await ecrLogin(ecr, dockerEnv, {
|
|
27436
27738
|
accountId: parsed.accountId,
|
|
27437
27739
|
region: parsed.region,
|
|
27438
27740
|
registryHost: canonicalUri.slice(0, canonicalUri.indexOf("/"))
|
|
@@ -27443,7 +27745,7 @@ async function pullEcrImage(imageUri, options) {
|
|
|
27443
27745
|
logger.info(`Pulling ${canonicalUri}...`);
|
|
27444
27746
|
const pullArgs = ["pull", canonicalUri];
|
|
27445
27747
|
try {
|
|
27446
|
-
await runDockerForeground(pullArgs);
|
|
27748
|
+
await runDockerForeground(pullArgs, { env: dockerEnv });
|
|
27447
27749
|
} catch (err) {
|
|
27448
27750
|
throw new LocalInvokeBuildError$1(`docker pull ${canonicalUri} failed: ${describeDockerFailure(err, pullArgs)}`, redactedDockerCause(err, pullArgs));
|
|
27449
27751
|
}
|
|
@@ -27477,7 +27779,7 @@ async function assumeRoleForEcr(roleArn, callerRegion, credentialConfig, logger)
|
|
|
27477
27779
|
sts.destroy();
|
|
27478
27780
|
}
|
|
27479
27781
|
}
|
|
27480
|
-
async function ecrLogin(client, target) {
|
|
27782
|
+
async function ecrLogin(client, dockerEnv, target) {
|
|
27481
27783
|
const { accountId, region, registryHost } = target;
|
|
27482
27784
|
getLogger().child("ecr-puller").debug(`ECR login (account=${accountId}, region=${region}, host=${registryHost})`);
|
|
27483
27785
|
let response;
|
|
@@ -27500,7 +27802,10 @@ async function ecrLogin(client, target) {
|
|
|
27500
27802
|
endpoint
|
|
27501
27803
|
];
|
|
27502
27804
|
try {
|
|
27503
|
-
await runDockerStreaming(loginArgs, {
|
|
27805
|
+
await runDockerStreaming(loginArgs, {
|
|
27806
|
+
input: password,
|
|
27807
|
+
env: dockerEnv
|
|
27808
|
+
});
|
|
27504
27809
|
} catch (err) {
|
|
27505
27810
|
throw new LocalInvokeBuildError$1(`ECR login failed: ${formatDockerLoginError(describeDockerFailure(err, loginArgs), endpoint)}`, redactedDockerCause(err, loginArgs));
|
|
27506
27811
|
}
|
|
@@ -28168,7 +28473,7 @@ function readEnvOverridesFile$3(filePath) {
|
|
|
28168
28473
|
if (!filePath) return void 0;
|
|
28169
28474
|
let raw;
|
|
28170
28475
|
try {
|
|
28171
|
-
raw =
|
|
28476
|
+
raw = readEnvVarsFileText(filePath);
|
|
28172
28477
|
} catch (err) {
|
|
28173
28478
|
throw new Error(`Failed to read --env-vars file '${filePath}': ${describeAwsFailure(err).detail}`);
|
|
28174
28479
|
}
|
|
@@ -28203,7 +28508,8 @@ async function resolveProfileCredentials(profile) {
|
|
|
28203
28508
|
const sts = new STSClient({
|
|
28204
28509
|
...awsClientDefaults({
|
|
28205
28510
|
profile,
|
|
28206
|
-
ignoreAssumedRole: true
|
|
28511
|
+
ignoreAssumedRole: true,
|
|
28512
|
+
realAws: mixedModeActive()
|
|
28207
28513
|
}),
|
|
28208
28514
|
profile
|
|
28209
28515
|
});
|
|
@@ -28234,7 +28540,10 @@ async function assumeLambdaExecutionRole$1(roleArn, region) {
|
|
|
28234
28540
|
assertSendableRoleArn(roleArn);
|
|
28235
28541
|
const { STSClient } = await import("@aws-sdk/client-sts");
|
|
28236
28542
|
const sts = new STSClient({
|
|
28237
|
-
...awsClientDefaults({
|
|
28543
|
+
...awsClientDefaults({
|
|
28544
|
+
ignoreAssumedRole: true,
|
|
28545
|
+
realAws: mixedModeActive()
|
|
28546
|
+
}),
|
|
28238
28547
|
...region && { region }
|
|
28239
28548
|
});
|
|
28240
28549
|
try {
|
|
@@ -28258,243 +28567,6 @@ async function assumeLambdaExecutionRole$1(roleArn, region) {
|
|
|
28258
28567
|
}
|
|
28259
28568
|
}
|
|
28260
28569
|
|
|
28261
|
-
// src/cli/commands/local-start-api/container-spec.ts
|
|
28262
|
-
async function buildContainerSpec(args) {
|
|
28263
|
-
const { logicalId, stacks, overrides, assumeRole, containerHost, debugPort, stsRegion, inlineTmpDirs, layerTmpDirs, stateByStack, skipPull, layerRoleArn, profileCredentials, profileCredsFile, profile, stackRegionOverride } = args;
|
|
28264
|
-
const lambda = resolveLambdaByLogicalId(logicalId, stacks);
|
|
28265
|
-
let codeDir;
|
|
28266
|
-
let optDir;
|
|
28267
|
-
let imageRef;
|
|
28268
|
-
let platform;
|
|
28269
|
-
if (lambda.kind === "zip") {
|
|
28270
|
-
codeDir = lambda.codePath ?? materializeInlineCode$1(lambda.handler, lambda.inlineCode ?? "", resolveRuntimeFileExtension(lambda.runtime), inlineTmpDirs);
|
|
28271
|
-
optDir = await materializeLambdaLayers$1(lambda.layers, layerTmpDirs, layerRoleArn);
|
|
28272
|
-
platform = architectureToPlatform(lambda.architecture);
|
|
28273
|
-
} else {
|
|
28274
|
-
imageRef = (await resolveContainerImageForStartApi(lambda, skipPull)).imageRef;
|
|
28275
|
-
platform = architectureToPlatform(lambda.architecture);
|
|
28276
|
-
}
|
|
28277
|
-
let templateEnv = getTemplateEnv$1(lambda.resource);
|
|
28278
|
-
const stateBundle = stateByStack.get(lambda.stack.stackName);
|
|
28279
|
-
let stateAudit;
|
|
28280
|
-
if (stateBundle) {
|
|
28281
|
-
const context = { resources: stateBundle.state.resources };
|
|
28282
|
-
if (stateBundle.pseudoParameters) context.pseudoParameters = stateBundle.pseudoParameters;
|
|
28283
|
-
const { env, audit } = substituteEnvVarsFromState(templateEnv, context);
|
|
28284
|
-
templateEnv = env;
|
|
28285
|
-
stateAudit = audit;
|
|
28286
|
-
for (const key of audit.resolvedKeys) getLogger().debug(`Lambda ${logicalId}: --from-state substituted env var ${key}`);
|
|
28287
|
-
for (const { key, reason } of audit.unresolved) getLogger().warn(`Lambda ${logicalId}: --from-state could not substitute env var ${key} (${reason}). Override it via --env-vars or it will be dropped.`);
|
|
28288
|
-
}
|
|
28289
|
-
const lambdaCdkPath = readCdkPathOrUndefined(lambda.resource);
|
|
28290
|
-
const envResult = resolveEnvVars(logicalId, lambdaCdkPath, templateEnv, overrides);
|
|
28291
|
-
for (const key of envResult.unresolved) {
|
|
28292
|
-
if (stateAudit && stateAudit.unresolved.some((u) => u.key === key)) continue;
|
|
28293
|
-
const overrideKeyExample = lambdaCdkPath?.replace(/\/Resource$/, "") ?? logicalId;
|
|
28294
|
-
getLogger().warn(`Lambda ${logicalId}: env var ${key} contains a CloudFormation intrinsic and was dropped. Override it with --env-vars (e.g. {"${overrideKeyExample}":{"${key}":"<literal>"}}) or pass --from-state to recover deployed values.`);
|
|
28295
|
-
}
|
|
28296
|
-
const plaintextKeys = new Set(stateAudit?.sensitiveKeys ?? []);
|
|
28297
|
-
for (const key of keysNotFromTemplate(templateEnv, envResult.resolved)) plaintextKeys.add(key);
|
|
28298
|
-
const dynamicRefs = createCallerDynamicReferenceResolver(profile);
|
|
28299
|
-
let dynamic;
|
|
28300
|
-
try {
|
|
28301
|
-
dynamic = await resolveDynamicReferencesInEnv(envResult.resolved, {
|
|
28302
|
-
region: firstUsableRegion(stateBundle?.region, stackRegionOverride, lambda.stack.region, stsRegion),
|
|
28303
|
-
label: `Lambda ${logicalId}`,
|
|
28304
|
-
skipKeys: plaintextKeys,
|
|
28305
|
-
resolver: dynamicRefs
|
|
28306
|
-
});
|
|
28307
|
-
} finally {
|
|
28308
|
-
dynamicRefs.dispose();
|
|
28309
|
-
}
|
|
28310
|
-
const sensitiveKeyList = [...stateAudit?.sensitiveKeys ?? [], ...dynamic.resolvedKeys];
|
|
28311
|
-
const sensitiveEnvKeys = sensitiveKeyList.length > 0 ? new Set(sensitiveKeyList) : void 0;
|
|
28312
|
-
const dockerEnv = {
|
|
28313
|
-
AWS_LAMBDA_FUNCTION_NAME: logicalId,
|
|
28314
|
-
AWS_LAMBDA_FUNCTION_MEMORY_SIZE: String(lambda.memoryMb),
|
|
28315
|
-
AWS_LAMBDA_FUNCTION_TIMEOUT: String(lambda.timeoutSec),
|
|
28316
|
-
AWS_LAMBDA_FUNCTION_VERSION: "$LATEST",
|
|
28317
|
-
AWS_LAMBDA_LOG_GROUP_NAME: `/aws/lambda/${logicalId}`,
|
|
28318
|
-
AWS_LAMBDA_LOG_STREAM_NAME: "local",
|
|
28319
|
-
...dynamic.env
|
|
28320
|
-
};
|
|
28321
|
-
const roleArn = resolveStartApiAssumeRoleArn({
|
|
28322
|
-
logicalId,
|
|
28323
|
-
assumeRole,
|
|
28324
|
-
lambdaResource: lambda.resource,
|
|
28325
|
-
stateBundle
|
|
28326
|
-
});
|
|
28327
|
-
if (roleArn) {
|
|
28328
|
-
const creds = await assumeLambdaExecutionRole$1(roleArn, stsRegion);
|
|
28329
|
-
dockerEnv["AWS_ACCESS_KEY_ID"] = creds.accessKeyId;
|
|
28330
|
-
dockerEnv["AWS_SECRET_ACCESS_KEY"] = creds.secretAccessKey;
|
|
28331
|
-
dockerEnv["AWS_SESSION_TOKEN"] = creds.sessionToken;
|
|
28332
|
-
setContainerRegion(dockerEnv, stsRegion);
|
|
28333
|
-
} else {
|
|
28334
|
-
forwardAwsEnv$2(dockerEnv);
|
|
28335
|
-
const containerRegion = firstUsableRegion(stsRegion, lambda.stack.region);
|
|
28336
|
-
setContainerRegion(dockerEnv, containerRegion);
|
|
28337
|
-
if (profileCredentials) {
|
|
28338
|
-
dockerEnv["AWS_ACCESS_KEY_ID"] = profileCredentials.accessKeyId;
|
|
28339
|
-
dockerEnv["AWS_SECRET_ACCESS_KEY"] = profileCredentials.secretAccessKey;
|
|
28340
|
-
if (profileCredentials.sessionToken) dockerEnv["AWS_SESSION_TOKEN"] = profileCredentials.sessionToken;
|
|
28341
|
-
else delete dockerEnv["AWS_SESSION_TOKEN"];
|
|
28342
|
-
}
|
|
28343
|
-
if (profileCredsFile) {
|
|
28344
|
-
dockerEnv["AWS_SHARED_CREDENTIALS_FILE"] = profileCredsFile.containerPath;
|
|
28345
|
-
dockerEnv["AWS_PROFILE"] = profileCredsFile.profileName;
|
|
28346
|
-
}
|
|
28347
|
-
}
|
|
28348
|
-
if (debugPort !== void 0) dockerEnv["NODE_OPTIONS"] = `--inspect-brk=0.0.0.0:${debugPort}`;
|
|
28349
|
-
const tmpfs = lambda.ephemeralStorageMb !== void 0 ? {
|
|
28350
|
-
target: "/tmp",
|
|
28351
|
-
sizeMb: lambda.ephemeralStorageMb
|
|
28352
|
-
} : void 0;
|
|
28353
|
-
if (lambda.kind === "zip") return {
|
|
28354
|
-
kind: "zip",
|
|
28355
|
-
lambda,
|
|
28356
|
-
codeDir,
|
|
28357
|
-
platform,
|
|
28358
|
-
env: dockerEnv,
|
|
28359
|
-
...sensitiveEnvKeys !== void 0 && { sensitiveEnvKeys },
|
|
28360
|
-
containerHost,
|
|
28361
|
-
...optDir !== void 0 && { optDir },
|
|
28362
|
-
...debugPort !== void 0 && { debugPort },
|
|
28363
|
-
...tmpfs !== void 0 && { tmpfs },
|
|
28364
|
-
...profileCredsFile && { profileCredentialsFile: {
|
|
28365
|
-
hostPath: profileCredsFile.hostPath,
|
|
28366
|
-
containerPath: profileCredsFile.containerPath
|
|
28367
|
-
} }
|
|
28368
|
-
};
|
|
28369
|
-
const rie = await resolveRieWrap({
|
|
28370
|
-
image: imageRef,
|
|
28371
|
-
platform,
|
|
28372
|
-
entryPoint: lambda.imageConfig.entryPoint,
|
|
28373
|
-
command: lambda.imageConfig.command,
|
|
28374
|
-
skipPull
|
|
28375
|
-
});
|
|
28376
|
-
return {
|
|
28377
|
-
kind: "image",
|
|
28378
|
-
lambda,
|
|
28379
|
-
image: imageRef,
|
|
28380
|
-
platform,
|
|
28381
|
-
command: rie ? rie.cmd : lambda.imageConfig.command ?? [],
|
|
28382
|
-
...rie && {
|
|
28383
|
-
entryPoint: rie.entryPoint,
|
|
28384
|
-
rieMount: rie.mount
|
|
28385
|
-
},
|
|
28386
|
-
...!rie && lambda.imageConfig.entryPoint !== void 0 && lambda.imageConfig.entryPoint.length > 0 && { entryPoint: lambda.imageConfig.entryPoint },
|
|
28387
|
-
...lambda.imageConfig.workingDirectory !== void 0 && { workingDir: lambda.imageConfig.workingDirectory },
|
|
28388
|
-
env: dockerEnv,
|
|
28389
|
-
...sensitiveEnvKeys !== void 0 && { sensitiveEnvKeys },
|
|
28390
|
-
containerHost,
|
|
28391
|
-
...debugPort !== void 0 && { debugPort },
|
|
28392
|
-
...tmpfs !== void 0 && { tmpfs },
|
|
28393
|
-
...profileCredsFile && { profileCredentialsFile: {
|
|
28394
|
-
hostPath: profileCredsFile.hostPath,
|
|
28395
|
-
containerPath: profileCredsFile.containerPath
|
|
28396
|
-
} }
|
|
28397
|
-
};
|
|
28398
|
-
}
|
|
28399
|
-
async function resolveContainerImageForStartApi(lambda, skipPull) {
|
|
28400
|
-
const logger = getLogger();
|
|
28401
|
-
const localBuild = await resolveLocalBuildPlan$1(lambda);
|
|
28402
|
-
if (localBuild) return { imageRef: await buildContainerImage$1(localBuild.asset, localBuild.cdkOutDir, {
|
|
28403
|
-
assetOutdir: localBuild.assetOutdir,
|
|
28404
|
-
architecture: lambda.architecture
|
|
28405
|
-
}) };
|
|
28406
|
-
if (!parseEcrUri(lambda.imageUri)) throw new Error(`Container Lambda '${lambda.logicalId}' has no matching asset in cdk.out, and Code.ImageUri '${lambda.imageUri}' is not an ECR URI cdkd can authenticate against. Re-synthesize the CDK app (so cdk.out includes the build context) or deploy the image to ECR first.`);
|
|
28407
|
-
logger.info(`No matching cdk.out asset for ${lambda.imageUri}; falling back to ECR pull (uses your own credentials — this command has no --ecr-role-arn, so a cross-account image needs cross-account ECR permissions)...`);
|
|
28408
|
-
return { imageRef: await pullEcrImage(lambda.imageUri, { skipPull }) };
|
|
28409
|
-
}
|
|
28410
|
-
async function resolveLocalBuildPlan$1(lambda) {
|
|
28411
|
-
if (!lambda.stack.assetManifestPath) return void 0;
|
|
28412
|
-
const { manifestDir: cdkOutDir, assetOutdir } = assetPathDirs(lambda.stack);
|
|
28413
|
-
const manifest = await new AssetManifestLoader().loadStackManifest(lambda.stack, cdkOutDir);
|
|
28414
|
-
if (!manifest) return void 0;
|
|
28415
|
-
const entry = getDockerImageBySourceHash(manifest, lambda.imageUri);
|
|
28416
|
-
if (!entry) return void 0;
|
|
28417
|
-
return {
|
|
28418
|
-
asset: entry.asset,
|
|
28419
|
-
cdkOutDir,
|
|
28420
|
-
assetOutdir
|
|
28421
|
-
};
|
|
28422
|
-
}
|
|
28423
|
-
async function materializeLambdaLayers$1(layers, layerTmpDirs, layerRoleArn) {
|
|
28424
|
-
if (layers.length === 0) return void 0;
|
|
28425
|
-
const flat = [];
|
|
28426
|
-
for (const layer of layers) {
|
|
28427
|
-
if (layer.kind === "asset") {
|
|
28428
|
-
flat.push({
|
|
28429
|
-
logicalId: layer.logicalId,
|
|
28430
|
-
assetPath: layer.assetPath
|
|
28431
|
-
});
|
|
28432
|
-
continue;
|
|
28433
|
-
}
|
|
28434
|
-
const dir = await materializeLayerFromArn(layer, { ...layerRoleArn !== void 0 && { roleArn: explicitRoleArnOrThrow("--layer-role-arn", layerRoleArn) } });
|
|
28435
|
-
layerTmpDirs.add(dir);
|
|
28436
|
-
flat.push({
|
|
28437
|
-
logicalId: layer.arn,
|
|
28438
|
-
assetPath: dir
|
|
28439
|
-
});
|
|
28440
|
-
}
|
|
28441
|
-
if (flat.length === 1) return flat[0].assetPath;
|
|
28442
|
-
const dir = mkdtempSync(path.join(tmpdir(), "cdkd-local-start-api-layers-"));
|
|
28443
|
-
try {
|
|
28444
|
-
for (const layer of flat) copyLayerTreeLastWins(layer.assetPath, dir);
|
|
28445
|
-
} catch (error) {
|
|
28446
|
-
rmSync(dir, {
|
|
28447
|
-
recursive: true,
|
|
28448
|
-
force: true
|
|
28449
|
-
});
|
|
28450
|
-
throw error;
|
|
28451
|
-
}
|
|
28452
|
-
layerTmpDirs.add(dir);
|
|
28453
|
-
return dir;
|
|
28454
|
-
}
|
|
28455
|
-
|
|
28456
|
-
// src/cli/commands/local-start-api/reload.ts
|
|
28457
|
-
async function reloadAllServers(args) {
|
|
28458
|
-
const { synthesizeAndBuild, servers, buildPool, logger, isClosing, retiredPoolDisposals } = args;
|
|
28459
|
-
let material;
|
|
28460
|
-
try {
|
|
28461
|
-
material = await synthesizeAndBuild();
|
|
28462
|
-
} catch (err) {
|
|
28463
|
-
logger.warn(`cdk synth failed during reload; keeping previous version. (${describeAwsFailure(err).detail})`);
|
|
28464
|
-
return;
|
|
28465
|
-
}
|
|
28466
|
-
if (isClosing?.()) return;
|
|
28467
|
-
const newGroups = groupRoutesByServer(material.routes);
|
|
28468
|
-
const newByKey = new Map(newGroups.map((g) => [g.serverKey, g]));
|
|
28469
|
-
const oldKeys = new Set(servers.map((s) => s.group.serverKey));
|
|
28470
|
-
const newKeys = new Set(newByKey.keys());
|
|
28471
|
-
const added = [...newKeys].filter((k) => !oldKeys.has(k));
|
|
28472
|
-
const removed = [...oldKeys].filter((k) => !newKeys.has(k));
|
|
28473
|
-
if (added.length > 0) logger.warn(`Reload detected new API surface(s): ${added.join(", ")}. Restart 'cdkd local start-api' to serve them.`);
|
|
28474
|
-
if (removed.length > 0) logger.warn(`Reload detected removed API surface(s): ${removed.join(", ")}. Their servers will keep serving stale routes until restart.`);
|
|
28475
|
-
for (const booted of servers) {
|
|
28476
|
-
const group = newByKey.get(booted.group.serverKey);
|
|
28477
|
-
if (!group) continue;
|
|
28478
|
-
const newPool = buildPool(filterSpecsForGroup(group, material));
|
|
28479
|
-
const newState = {
|
|
28480
|
-
routes: group.routes,
|
|
28481
|
-
pool: newPool,
|
|
28482
|
-
corsConfigByApiId: corsConfigForGroup(group, material)
|
|
28483
|
-
};
|
|
28484
|
-
const previousState = booted.server.setServerState(newState);
|
|
28485
|
-
booted.group = group;
|
|
28486
|
-
const disposal = previousState.pool.dispose().catch((err) => {
|
|
28487
|
-
logger.debug(`Previous pool dispose() failed for ${group.displayName}: ${describeAwsFailure(err).detail}`);
|
|
28488
|
-
});
|
|
28489
|
-
retiredPoolDisposals?.add(disposal);
|
|
28490
|
-
disposal.then(() => retiredPoolDisposals?.delete(disposal));
|
|
28491
|
-
}
|
|
28492
|
-
printPerServerRouteTables(servers);
|
|
28493
|
-
const allRoutes = servers.flatMap((s) => s.group.routes.map((r) => r.route));
|
|
28494
|
-
warnUnsupportedRoutes(allRoutes, logger);
|
|
28495
|
-
warnSsrfRiskyIntegrations(allRoutes, logger);
|
|
28496
|
-
}
|
|
28497
|
-
|
|
28498
28570
|
// src/local/ecs-task-resolver/image.ts
|
|
28499
28571
|
const CDK_ASSET_IMAGE_REPO_RE = /(?:cdk-[a-z0-9]+|cdkd)-container-assets-/;
|
|
28500
28572
|
function extractEcrRepoComponent(uri) {
|
|
@@ -28640,6 +28712,67 @@ function extractImageString(value) {
|
|
|
28640
28712
|
}
|
|
28641
28713
|
}
|
|
28642
28714
|
|
|
28715
|
+
// src/local/ecs-task-resolver/role-arn.ts
|
|
28716
|
+
const TASK_ROLE_ACCOUNT_PLACEHOLDER = "${AWS::AccountId}";
|
|
28717
|
+
const TASK_ROLE_PARTITION_PLACEHOLDER = "${AWS::Partition}";
|
|
28718
|
+
function placeholderRoleArn(pathAndName) {
|
|
28719
|
+
return `arn:${TASK_ROLE_PARTITION_PLACEHOLDER}:iam::${TASK_ROLE_ACCOUNT_PLACEHOLDER}:role${pathAndName}`;
|
|
28720
|
+
}
|
|
28721
|
+
function sameStackRoleLogicalId(value, resources) {
|
|
28722
|
+
if (!value || typeof value !== "object") return void 0;
|
|
28723
|
+
const obj = value;
|
|
28724
|
+
let refLogicalId;
|
|
28725
|
+
if ("Ref" in obj && typeof obj["Ref"] === "string") refLogicalId = obj["Ref"];
|
|
28726
|
+
else if ("Fn::GetAtt" in obj) {
|
|
28727
|
+
const arg = obj["Fn::GetAtt"];
|
|
28728
|
+
if (Array.isArray(arg) && typeof arg[0] === "string") {
|
|
28729
|
+
const attr = typeof arg[1] === "string" ? arg[1] : "";
|
|
28730
|
+
if (attr === "" || attr === "Arn") refLogicalId = arg[0];
|
|
28731
|
+
}
|
|
28732
|
+
}
|
|
28733
|
+
if (refLogicalId === void 0) return void 0;
|
|
28734
|
+
return resources[refLogicalId]?.Type === "AWS::IAM::Role" ? refLogicalId : void 0;
|
|
28735
|
+
}
|
|
28736
|
+
function roleArnFromStateRecord(logicalId, role, subContext) {
|
|
28737
|
+
if (!subContext) return { reason: "no-state" };
|
|
28738
|
+
const record = subContext.resources[logicalId];
|
|
28739
|
+
if (!record) return { reason: "no-record" };
|
|
28740
|
+
const arn = record.attributes?.["Arn"];
|
|
28741
|
+
if (typeof arn === "string" && arn.length > 0) return { arn };
|
|
28742
|
+
const name = record.physicalId;
|
|
28743
|
+
if (typeof name !== "string" || name.length === 0) return { reason: "no-record" };
|
|
28744
|
+
const rawPath = role.Properties?.["Path"];
|
|
28745
|
+
if (rawPath === void 0) return { arn: placeholderRoleArn(`/${name}`) };
|
|
28746
|
+
if (typeof rawPath !== "string" || !/^\/(?:.*\/)?$/.test(rawPath)) return { reason: "path-not-literal" };
|
|
28747
|
+
return { arn: placeholderRoleArn(`${rawPath}${name}`) };
|
|
28748
|
+
}
|
|
28749
|
+
function resolveRoleArn(value, resources, subContext) {
|
|
28750
|
+
if (value === void 0 || value === null) return {};
|
|
28751
|
+
if (typeof value === "string") return { arn: value };
|
|
28752
|
+
if (typeof value !== "object") return {};
|
|
28753
|
+
const obj = value;
|
|
28754
|
+
if ("Ref" in obj || "Fn::GetAtt" in obj) {
|
|
28755
|
+
const logicalId = sameStackRoleLogicalId(value, resources);
|
|
28756
|
+
if (logicalId === void 0) return {};
|
|
28757
|
+
const fromState = roleArnFromStateRecord(logicalId, resources[logicalId], subContext);
|
|
28758
|
+
if ("arn" in fromState) return { arn: fromState.arn };
|
|
28759
|
+
return {
|
|
28760
|
+
arn: placeholderRoleArn(`/${logicalId}`),
|
|
28761
|
+
unresolved: {
|
|
28762
|
+
logicalId,
|
|
28763
|
+
reason: fromState.reason
|
|
28764
|
+
}
|
|
28765
|
+
};
|
|
28766
|
+
}
|
|
28767
|
+
if ("Fn::Join" in obj || "Fn::Sub" in obj) {
|
|
28768
|
+
if (!subContext) return {};
|
|
28769
|
+
const sub = substituteAgainstState(value, subContext);
|
|
28770
|
+
if (sub.kind === "literal" && typeof sub.value === "string" && sub.value.length > 0) return { arn: sub.value };
|
|
28771
|
+
return {};
|
|
28772
|
+
}
|
|
28773
|
+
return {};
|
|
28774
|
+
}
|
|
28775
|
+
|
|
28643
28776
|
// src/local/ecs-task-resolver/needs.ts
|
|
28644
28777
|
function detectEcsImageResolutionNeeds(stack) {
|
|
28645
28778
|
const resources = stack.template.Resources ?? {};
|
|
@@ -28648,6 +28781,7 @@ function detectEcsImageResolutionNeeds(stack) {
|
|
|
28648
28781
|
let needsEnvOrSecretSubstitution = false;
|
|
28649
28782
|
let needsCrossStackResolver = false;
|
|
28650
28783
|
let needsAssetRepoMarker = false;
|
|
28784
|
+
let needsTaskRoleState = false;
|
|
28651
28785
|
for (const res of Object.values(resources)) {
|
|
28652
28786
|
if (res.Type !== "AWS::ECS::TaskDefinition") continue;
|
|
28653
28787
|
const props = res.Properties ?? {};
|
|
@@ -28674,6 +28808,7 @@ function detectEcsImageResolutionNeeds(stack) {
|
|
|
28674
28808
|
break;
|
|
28675
28809
|
}
|
|
28676
28810
|
}
|
|
28811
|
+
if (sameStackRoleLogicalId(props["TaskRoleArn"], resources) !== void 0) needsTaskRoleState = true;
|
|
28677
28812
|
if (isFnJoinOrSubIntrinsic(props["TaskRoleArn"]) || isFnJoinOrSubIntrinsic(props["ExecutionRoleArn"])) needsEnvOrSecretSubstitution = true;
|
|
28678
28813
|
}
|
|
28679
28814
|
return {
|
|
@@ -28681,7 +28816,8 @@ function detectEcsImageResolutionNeeds(stack) {
|
|
|
28681
28816
|
needsStateResources,
|
|
28682
28817
|
needsEnvOrSecretSubstitution,
|
|
28683
28818
|
needsCrossStackResolver,
|
|
28684
|
-
needsAssetRepoMarker
|
|
28819
|
+
needsAssetRepoMarker,
|
|
28820
|
+
needsTaskRoleState
|
|
28685
28821
|
};
|
|
28686
28822
|
}
|
|
28687
28823
|
function containerHasCrossStackEnvOrSecret(c) {
|
|
@@ -28998,34 +29134,6 @@ function buildSubstitutionContextFromImageContext(context) {
|
|
|
28998
29134
|
return subContext;
|
|
28999
29135
|
}
|
|
29000
29136
|
|
|
29001
|
-
// src/local/ecs-task-resolver/role-arn.ts
|
|
29002
|
-
const TASK_ROLE_ACCOUNT_PLACEHOLDER = "${AWS::AccountId}";
|
|
29003
|
-
function resolveRoleArn(value, resources, subContext) {
|
|
29004
|
-
if (value === void 0 || value === null) return void 0;
|
|
29005
|
-
if (typeof value === "string") return value;
|
|
29006
|
-
if (typeof value !== "object") return void 0;
|
|
29007
|
-
const obj = value;
|
|
29008
|
-
let refLogicalId;
|
|
29009
|
-
if ("Ref" in obj && typeof obj["Ref"] === "string") refLogicalId = obj["Ref"];
|
|
29010
|
-
else if ("Fn::GetAtt" in obj) {
|
|
29011
|
-
const arg = obj["Fn::GetAtt"];
|
|
29012
|
-
if (Array.isArray(arg) && typeof arg[0] === "string") {
|
|
29013
|
-
const attr = typeof arg[1] === "string" ? arg[1] : "";
|
|
29014
|
-
if (attr === "" || attr === "Arn") refLogicalId = arg[0];
|
|
29015
|
-
}
|
|
29016
|
-
}
|
|
29017
|
-
if (refLogicalId !== void 0) {
|
|
29018
|
-
if (resources[refLogicalId]?.Type !== "AWS::IAM::Role") return void 0;
|
|
29019
|
-
return `arn:aws:iam::${TASK_ROLE_ACCOUNT_PLACEHOLDER}:role/${refLogicalId}`;
|
|
29020
|
-
}
|
|
29021
|
-
if ("Fn::Join" in obj || "Fn::Sub" in obj) {
|
|
29022
|
-
if (!subContext) return void 0;
|
|
29023
|
-
const sub = substituteAgainstState(value, subContext);
|
|
29024
|
-
if (sub.kind === "literal" && typeof sub.value === "string" && sub.value.length > 0) return sub.value;
|
|
29025
|
-
return;
|
|
29026
|
-
}
|
|
29027
|
-
}
|
|
29028
|
-
|
|
29029
29137
|
// src/local/ecs-task-resolver/volume.ts
|
|
29030
29138
|
function parseVolume(raw, idx, taskLogicalId, subContext) {
|
|
29031
29139
|
if (!raw || typeof raw !== "object") throw new EcsTaskResolutionError(`Task '${taskLogicalId}' Volumes[${idx}] is not an object.`);
|
|
@@ -29160,8 +29268,13 @@ function extractTaskDefinitionProperties(stack, logicalId, resource, context) {
|
|
|
29160
29268
|
if (props["ProxyConfiguration"]) warnings.push(`Task definition '${logicalId}' declares 'ProxyConfiguration' (custom Envoy / App Mesh bootstrap), which is NOT honored by 'cdkd local start-service' / 'cdkd local run-task' in v1. Local execution will run without the configured proxy. See design doc § 2 for the rationale.`);
|
|
29161
29269
|
const resources = stack.template.Resources ?? {};
|
|
29162
29270
|
const subContext = buildSubstitutionContextFromImageContext(context);
|
|
29163
|
-
const
|
|
29164
|
-
|
|
29271
|
+
const roleSubContext = context?.ignoreStateForRoles && subContext ? {
|
|
29272
|
+
...subContext,
|
|
29273
|
+
resources: Object.fromEntries(Object.entries(subContext.resources).filter(([, r]) => r.resourceType !== "AWS::IAM::Role"))
|
|
29274
|
+
} : subContext;
|
|
29275
|
+
const taskRole = resolveRoleArn(props["TaskRoleArn"], resources, roleSubContext);
|
|
29276
|
+
const taskRoleArn = taskRole.arn;
|
|
29277
|
+
const executionRoleArn = resolveRoleArn(props["ExecutionRoleArn"], resources, roleSubContext).arn;
|
|
29165
29278
|
const runtimePlatform = parseRuntimePlatform(props["RuntimePlatform"]);
|
|
29166
29279
|
const rawContainers = props["ContainerDefinitions"];
|
|
29167
29280
|
if (!Array.isArray(rawContainers) || rawContainers.length === 0) throw new EcsTaskResolutionError(`Task definition '${logicalId}' has no ContainerDefinitions.`);
|
|
@@ -29182,6 +29295,7 @@ function extractTaskDefinitionProperties(stack, logicalId, resource, context) {
|
|
|
29182
29295
|
warnings
|
|
29183
29296
|
};
|
|
29184
29297
|
if (taskRoleArn !== void 0) out.taskRoleArn = taskRoleArn;
|
|
29298
|
+
if (taskRole.unresolved !== void 0) out.taskRoleUnresolved = taskRole.unresolved;
|
|
29185
29299
|
if (executionRoleArn !== void 0) out.executionRoleArn = executionRoleArn;
|
|
29186
29300
|
if (runtimePlatform !== void 0) out.runtimePlatform = runtimePlatform;
|
|
29187
29301
|
return out;
|
|
@@ -29295,6 +29409,10 @@ async function applyCrossStackResolverToTask(task, context) {
|
|
|
29295
29409
|
}
|
|
29296
29410
|
|
|
29297
29411
|
// src/cli/commands/local-start-api/state.ts
|
|
29412
|
+
function stateBundleKey(stackName, workload) {
|
|
29413
|
+
const real = awsEmulatorRealServices(workload);
|
|
29414
|
+
return real === void 0 ? stackName : JSON.stringify([stackName, real]);
|
|
29415
|
+
}
|
|
29298
29416
|
function envHasIntrinsicValue$1(templateEnv) {
|
|
29299
29417
|
if (!templateEnv) return false;
|
|
29300
29418
|
for (const v of Object.values(templateEnv)) {
|
|
@@ -29316,10 +29434,36 @@ async function loadStateForRoutedStacks(stacks, routes, routesWithAuth, options)
|
|
|
29316
29434
|
}
|
|
29317
29435
|
const stackHasIntrinsicEnv = (stackName) => intrinsicEnvStacks.has(stackName);
|
|
29318
29436
|
rejectExplicitCfnStackWithMultipleStacks(options, reachableStackNames.size);
|
|
29319
|
-
|
|
29437
|
+
const loads = /* @__PURE__ */ new Map();
|
|
29438
|
+
const lambdas = [];
|
|
29439
|
+
for (const ref of reachedLambdas(routes, routesWithAuth)) for (const owner of lambdaOwners(ref, stacks)) {
|
|
29440
|
+
const resource = owner.template.Resources?.[ref.logicalId];
|
|
29441
|
+
lambdas.push({
|
|
29442
|
+
stackName: owner.stackName,
|
|
29443
|
+
workload: {
|
|
29444
|
+
logicalId: ref.logicalId,
|
|
29445
|
+
cdkPath: resource ? readCdkPathOrUndefined(resource) : void 0
|
|
29446
|
+
}
|
|
29447
|
+
});
|
|
29448
|
+
}
|
|
29449
|
+
for (const { stackName } of lambdas) {
|
|
29450
|
+
const key = stateBundleKey(stackName, UNNAMED_WORKLOAD);
|
|
29451
|
+
if (!loads.has(key)) loads.set(key, {
|
|
29452
|
+
stackName,
|
|
29453
|
+
workload: UNNAMED_WORKLOAD
|
|
29454
|
+
});
|
|
29455
|
+
}
|
|
29456
|
+
for (const group of groupWorkloadsRoutedApart(lambdas, (l) => l.workload)) for (const { stackName } of group.items) {
|
|
29457
|
+
const key = stateBundleKey(stackName, group.workload);
|
|
29458
|
+
if (!loads.has(key)) loads.set(key, {
|
|
29459
|
+
stackName,
|
|
29460
|
+
workload: group.workload
|
|
29461
|
+
});
|
|
29462
|
+
}
|
|
29463
|
+
for (const [key, { stackName, workload }] of loads) {
|
|
29320
29464
|
const stack = stacks.find((s) => s.stackName === stackName);
|
|
29321
29465
|
if (!stack) continue;
|
|
29322
|
-
const provider = createLocalStateProvider$1(options, stack.stackName, stack.region);
|
|
29466
|
+
const provider = createLocalStateProvider$1(options, stack.stackName, stack.region, { workload });
|
|
29323
29467
|
if (!provider) continue;
|
|
29324
29468
|
try {
|
|
29325
29469
|
const loaded = await provider.load(stack.stackName, stack.region);
|
|
@@ -29338,7 +29482,7 @@ async function loadStateForRoutedStacks(stacks, routes, routesWithAuth, options)
|
|
|
29338
29482
|
const pseudo = await resolvePseudoParametersForStartApi(loaded.region, options);
|
|
29339
29483
|
if (pseudo) bundle.pseudoParameters = pseudo;
|
|
29340
29484
|
}
|
|
29341
|
-
out.set(
|
|
29485
|
+
out.set(key, bundle);
|
|
29342
29486
|
logger.debug(`${provider.label}: loaded state for ${stackName} (${loaded.region})`);
|
|
29343
29487
|
} finally {
|
|
29344
29488
|
provider.dispose();
|
|
@@ -29354,19 +29498,25 @@ async function resolvePseudoParametersForStartApi(stateRegion, options) {
|
|
|
29354
29498
|
try {
|
|
29355
29499
|
const { STSClient, GetCallerIdentityCommand } = await import("@aws-sdk/client-sts");
|
|
29356
29500
|
let sts;
|
|
29357
|
-
if (!options.fromState)
|
|
29501
|
+
if (!options.fromState) {
|
|
29502
|
+
const realAws = realAwsException("STS");
|
|
29503
|
+
sts = new STSClient({
|
|
29504
|
+
...awsClientDefaults({
|
|
29505
|
+
profile: options.profile,
|
|
29506
|
+
ignoreAssumedRole: true,
|
|
29507
|
+
realAws
|
|
29508
|
+
}),
|
|
29509
|
+
...region && { region },
|
|
29510
|
+
...options.profile && { profile: options.profile }
|
|
29511
|
+
});
|
|
29512
|
+
} else sts = new STSClient({
|
|
29358
29513
|
...awsClientDefaults({
|
|
29359
29514
|
profile: options.profile,
|
|
29360
|
-
|
|
29515
|
+
realAws: realAwsException("STS")
|
|
29361
29516
|
}),
|
|
29362
29517
|
...region && { region },
|
|
29363
29518
|
...options.profile && { profile: options.profile }
|
|
29364
29519
|
});
|
|
29365
|
-
else sts = new STSClient({
|
|
29366
|
-
...awsClientDefaults({ profile: options.profile }),
|
|
29367
|
-
...region && { region },
|
|
29368
|
-
...options.profile && { profile: options.profile }
|
|
29369
|
-
});
|
|
29370
29520
|
try {
|
|
29371
29521
|
accountId = (await sts.send(new GetCallerIdentityCommand({}))).Account;
|
|
29372
29522
|
} finally {
|
|
@@ -29387,6 +29537,267 @@ async function resolvePseudoParametersForStartApi(stateRegion, options) {
|
|
|
29387
29537
|
return Object.keys(bag).length === 0 ? void 0 : bag;
|
|
29388
29538
|
}
|
|
29389
29539
|
|
|
29540
|
+
// src/cli/commands/local-start-api/container-spec.ts
|
|
29541
|
+
async function buildContainerSpec(args) {
|
|
29542
|
+
const { logicalId, stacks, overrides, assumeRole, containerHost, debugPort, stsRegion, inlineTmpDirs, layerTmpDirs, stateByStack, stateSourceActive, skipPull, layerRoleArn, profileCredentials, profileCredsFile, profile, stackRegionOverride } = args;
|
|
29543
|
+
const lambda = resolveLambdaByLogicalId(logicalId, stacks);
|
|
29544
|
+
let codeDir;
|
|
29545
|
+
let optDir;
|
|
29546
|
+
let imageRef;
|
|
29547
|
+
let platform;
|
|
29548
|
+
if (lambda.kind === "zip") {
|
|
29549
|
+
codeDir = lambda.codePath ?? materializeInlineCode$1(lambda.handler, lambda.inlineCode ?? "", resolveRuntimeFileExtension(lambda.runtime), inlineTmpDirs);
|
|
29550
|
+
optDir = await materializeLambdaLayers$1(lambda.layers, layerTmpDirs, layerRoleArn, {
|
|
29551
|
+
logicalId,
|
|
29552
|
+
cdkPath: readCdkPathOrUndefined(lambda.resource)
|
|
29553
|
+
});
|
|
29554
|
+
platform = architectureToPlatform(lambda.architecture);
|
|
29555
|
+
} else {
|
|
29556
|
+
imageRef = (await resolveContainerImageForStartApi(lambda, skipPull)).imageRef;
|
|
29557
|
+
platform = architectureToPlatform(lambda.architecture);
|
|
29558
|
+
}
|
|
29559
|
+
let templateEnv = getTemplateEnv$1(lambda.resource);
|
|
29560
|
+
const stateBundle = stateByStack.get(stateBundleKey(lambda.stack.stackName, {
|
|
29561
|
+
logicalId,
|
|
29562
|
+
cdkPath: readCdkPathOrUndefined(lambda.resource)
|
|
29563
|
+
}));
|
|
29564
|
+
let stateAudit;
|
|
29565
|
+
if (stateBundle) {
|
|
29566
|
+
const context = { resources: stateBundle.state.resources };
|
|
29567
|
+
if (stateBundle.pseudoParameters) context.pseudoParameters = stateBundle.pseudoParameters;
|
|
29568
|
+
const { env, audit } = substituteEnvVarsFromState(templateEnv, context);
|
|
29569
|
+
templateEnv = env;
|
|
29570
|
+
stateAudit = audit;
|
|
29571
|
+
for (const key of audit.resolvedKeys) getLogger().debug(`Lambda ${logicalId}: --from-state substituted env var ${key}`);
|
|
29572
|
+
for (const { key, reason } of audit.unresolved) getLogger().warn(`Lambda ${logicalId}: --from-state could not substitute env var ${key} (${reason}). Override it via --env-vars or it will be dropped.`);
|
|
29573
|
+
}
|
|
29574
|
+
const lambdaCdkPath = readCdkPathOrUndefined(lambda.resource);
|
|
29575
|
+
const envResult = resolveEnvVars(logicalId, lambdaCdkPath, templateEnv, overrides);
|
|
29576
|
+
for (const key of envResult.unresolved) {
|
|
29577
|
+
if (stateAudit && stateAudit.unresolved.some((u) => u.key === key)) continue;
|
|
29578
|
+
const overrideKeyExample = lambdaCdkPath?.replace(/\/Resource$/, "") ?? logicalId;
|
|
29579
|
+
getLogger().warn(`Lambda ${logicalId}: env var ${key} contains a CloudFormation intrinsic and was dropped. Override it with --env-vars (e.g. {"${overrideKeyExample}":{"${key}":"<literal>"}}) or pass --from-state to recover deployed values.`);
|
|
29580
|
+
}
|
|
29581
|
+
warnAwsEmulatorStateSourceHint(envResult.unresolved.length, stateSourceActive === true);
|
|
29582
|
+
const plaintextKeys = new Set(stateAudit?.sensitiveKeys ?? []);
|
|
29583
|
+
for (const key of keysNotFromTemplate(templateEnv, envResult.resolved)) plaintextKeys.add(key);
|
|
29584
|
+
const dynamicRefs = createCallerDynamicReferenceResolver(profile);
|
|
29585
|
+
let dynamic;
|
|
29586
|
+
try {
|
|
29587
|
+
dynamic = await resolveDynamicReferencesInEnv(envResult.resolved, {
|
|
29588
|
+
workload: {
|
|
29589
|
+
logicalId,
|
|
29590
|
+
cdkPath: lambdaCdkPath
|
|
29591
|
+
},
|
|
29592
|
+
region: firstUsableRegion(stateBundle?.region, stackRegionOverride, lambda.stack.region, stsRegion),
|
|
29593
|
+
label: `Lambda ${logicalId}`,
|
|
29594
|
+
skipKeys: plaintextKeys,
|
|
29595
|
+
resolver: dynamicRefs
|
|
29596
|
+
});
|
|
29597
|
+
} finally {
|
|
29598
|
+
dynamicRefs.dispose();
|
|
29599
|
+
}
|
|
29600
|
+
const sensitiveKeyList = [...stateAudit?.sensitiveKeys ?? [], ...dynamic.resolvedKeys];
|
|
29601
|
+
const sensitiveEnvKeys = sensitiveKeyList.length > 0 ? new Set(sensitiveKeyList) : void 0;
|
|
29602
|
+
const dockerEnv = {
|
|
29603
|
+
AWS_LAMBDA_FUNCTION_NAME: logicalId,
|
|
29604
|
+
AWS_LAMBDA_FUNCTION_MEMORY_SIZE: String(lambda.memoryMb),
|
|
29605
|
+
AWS_LAMBDA_FUNCTION_TIMEOUT: String(lambda.timeoutSec),
|
|
29606
|
+
AWS_LAMBDA_FUNCTION_VERSION: "$LATEST",
|
|
29607
|
+
AWS_LAMBDA_LOG_GROUP_NAME: `/aws/lambda/${logicalId}`,
|
|
29608
|
+
AWS_LAMBDA_LOG_STREAM_NAME: "local",
|
|
29609
|
+
...dynamic.env
|
|
29610
|
+
};
|
|
29611
|
+
const roleArn = resolveStartApiAssumeRoleArn({
|
|
29612
|
+
logicalId,
|
|
29613
|
+
assumeRole,
|
|
29614
|
+
lambdaResource: lambda.resource,
|
|
29615
|
+
stateBundle
|
|
29616
|
+
});
|
|
29617
|
+
if (roleArn) {
|
|
29618
|
+
const creds = await assumeLambdaExecutionRole$1(roleArn, stsRegion);
|
|
29619
|
+
dockerEnv["AWS_ACCESS_KEY_ID"] = creds.accessKeyId;
|
|
29620
|
+
dockerEnv["AWS_SECRET_ACCESS_KEY"] = creds.secretAccessKey;
|
|
29621
|
+
dockerEnv["AWS_SESSION_TOKEN"] = creds.sessionToken;
|
|
29622
|
+
setContainerRegion(dockerEnv, stsRegion);
|
|
29623
|
+
} else {
|
|
29624
|
+
forwardAwsEnv$2(dockerEnv);
|
|
29625
|
+
const containerRegion = firstUsableRegion(stsRegion, lambda.stack.region);
|
|
29626
|
+
setContainerRegion(dockerEnv, containerRegion);
|
|
29627
|
+
if (profileCredentials) {
|
|
29628
|
+
dockerEnv["AWS_ACCESS_KEY_ID"] = profileCredentials.accessKeyId;
|
|
29629
|
+
dockerEnv["AWS_SECRET_ACCESS_KEY"] = profileCredentials.secretAccessKey;
|
|
29630
|
+
if (profileCredentials.sessionToken) dockerEnv["AWS_SESSION_TOKEN"] = profileCredentials.sessionToken;
|
|
29631
|
+
else delete dockerEnv["AWS_SESSION_TOKEN"];
|
|
29632
|
+
}
|
|
29633
|
+
if (profileCredsFile) {
|
|
29634
|
+
dockerEnv["AWS_SHARED_CREDENTIALS_FILE"] = profileCredsFile.containerPath;
|
|
29635
|
+
dockerEnv["AWS_PROFILE"] = profileCredsFile.profileName;
|
|
29636
|
+
}
|
|
29637
|
+
}
|
|
29638
|
+
if (debugPort !== void 0) dockerEnv["NODE_OPTIONS"] = `--inspect-brk=0.0.0.0:${debugPort}`;
|
|
29639
|
+
const tmpfs = lambda.ephemeralStorageMb !== void 0 ? {
|
|
29640
|
+
target: "/tmp",
|
|
29641
|
+
sizeMb: lambda.ephemeralStorageMb
|
|
29642
|
+
} : void 0;
|
|
29643
|
+
if (lambda.kind === "zip") return {
|
|
29644
|
+
kind: "zip",
|
|
29645
|
+
lambda,
|
|
29646
|
+
codeDir,
|
|
29647
|
+
platform,
|
|
29648
|
+
env: dockerEnv,
|
|
29649
|
+
...sensitiveEnvKeys !== void 0 && { sensitiveEnvKeys },
|
|
29650
|
+
containerHost,
|
|
29651
|
+
...optDir !== void 0 && { optDir },
|
|
29652
|
+
...debugPort !== void 0 && { debugPort },
|
|
29653
|
+
...tmpfs !== void 0 && { tmpfs },
|
|
29654
|
+
...profileCredsFile && { profileCredentialsFile: {
|
|
29655
|
+
hostPath: profileCredsFile.hostPath,
|
|
29656
|
+
containerPath: profileCredsFile.containerPath
|
|
29657
|
+
} }
|
|
29658
|
+
};
|
|
29659
|
+
const rie = await resolveRieWrap({
|
|
29660
|
+
image: imageRef,
|
|
29661
|
+
platform,
|
|
29662
|
+
entryPoint: lambda.imageConfig.entryPoint,
|
|
29663
|
+
command: lambda.imageConfig.command,
|
|
29664
|
+
skipPull
|
|
29665
|
+
});
|
|
29666
|
+
return {
|
|
29667
|
+
kind: "image",
|
|
29668
|
+
lambda,
|
|
29669
|
+
image: imageRef,
|
|
29670
|
+
platform,
|
|
29671
|
+
command: rie ? rie.cmd : lambda.imageConfig.command ?? [],
|
|
29672
|
+
...rie && {
|
|
29673
|
+
entryPoint: rie.entryPoint,
|
|
29674
|
+
rieMount: rie.mount
|
|
29675
|
+
},
|
|
29676
|
+
...!rie && lambda.imageConfig.entryPoint !== void 0 && lambda.imageConfig.entryPoint.length > 0 && { entryPoint: lambda.imageConfig.entryPoint },
|
|
29677
|
+
...lambda.imageConfig.workingDirectory !== void 0 && { workingDir: lambda.imageConfig.workingDirectory },
|
|
29678
|
+
env: dockerEnv,
|
|
29679
|
+
...sensitiveEnvKeys !== void 0 && { sensitiveEnvKeys },
|
|
29680
|
+
containerHost,
|
|
29681
|
+
...debugPort !== void 0 && { debugPort },
|
|
29682
|
+
...tmpfs !== void 0 && { tmpfs },
|
|
29683
|
+
...profileCredsFile && { profileCredentialsFile: {
|
|
29684
|
+
hostPath: profileCredsFile.hostPath,
|
|
29685
|
+
containerPath: profileCredsFile.containerPath
|
|
29686
|
+
} }
|
|
29687
|
+
};
|
|
29688
|
+
}
|
|
29689
|
+
async function resolveContainerImageForStartApi(lambda, skipPull) {
|
|
29690
|
+
const logger = getLogger();
|
|
29691
|
+
const localBuild = await resolveLocalBuildPlan$1(lambda);
|
|
29692
|
+
if (localBuild) return { imageRef: await buildContainerImage$1(localBuild.asset, localBuild.cdkOutDir, {
|
|
29693
|
+
assetOutdir: localBuild.assetOutdir,
|
|
29694
|
+
architecture: lambda.architecture,
|
|
29695
|
+
workload: {
|
|
29696
|
+
logicalId: lambda.logicalId,
|
|
29697
|
+
cdkPath: readCdkPathOrUndefined(lambda.resource)
|
|
29698
|
+
}
|
|
29699
|
+
}) };
|
|
29700
|
+
if (!parseEcrUri(lambda.imageUri)) throw new Error(`Container Lambda '${lambda.logicalId}' has no matching asset in cdk.out, and Code.ImageUri '${lambda.imageUri}' is not an ECR URI cdkd can authenticate against. Re-synthesize the CDK app (so cdk.out includes the build context) or deploy the image to ECR first.`);
|
|
29701
|
+
logger.info(`No matching cdk.out asset for ${lambda.imageUri}; falling back to ECR pull (uses your own credentials — this command has no --ecr-role-arn, so a cross-account image needs cross-account ECR permissions)...`);
|
|
29702
|
+
return { imageRef: await pullEcrImage(lambda.imageUri, {
|
|
29703
|
+
skipPull,
|
|
29704
|
+
workload: {
|
|
29705
|
+
logicalId: lambda.logicalId,
|
|
29706
|
+
cdkPath: readCdkPathOrUndefined(lambda.resource)
|
|
29707
|
+
}
|
|
29708
|
+
}) };
|
|
29709
|
+
}
|
|
29710
|
+
async function resolveLocalBuildPlan$1(lambda) {
|
|
29711
|
+
if (!lambda.stack.assetManifestPath) return void 0;
|
|
29712
|
+
const { manifestDir: cdkOutDir, assetOutdir } = assetPathDirs(lambda.stack);
|
|
29713
|
+
const manifest = await new AssetManifestLoader().loadStackManifest(lambda.stack, cdkOutDir);
|
|
29714
|
+
if (!manifest) return void 0;
|
|
29715
|
+
const entry = getDockerImageBySourceHash(manifest, lambda.imageUri);
|
|
29716
|
+
if (!entry) return void 0;
|
|
29717
|
+
return {
|
|
29718
|
+
asset: entry.asset,
|
|
29719
|
+
cdkOutDir,
|
|
29720
|
+
assetOutdir
|
|
29721
|
+
};
|
|
29722
|
+
}
|
|
29723
|
+
async function materializeLambdaLayers$1(layers, layerTmpDirs, layerRoleArn, workload) {
|
|
29724
|
+
if (layers.length === 0) return void 0;
|
|
29725
|
+
const flat = [];
|
|
29726
|
+
for (const layer of layers) {
|
|
29727
|
+
if (layer.kind === "asset") {
|
|
29728
|
+
flat.push({
|
|
29729
|
+
logicalId: layer.logicalId,
|
|
29730
|
+
assetPath: layer.assetPath
|
|
29731
|
+
});
|
|
29732
|
+
continue;
|
|
29733
|
+
}
|
|
29734
|
+
const dir = await materializeLayerFromArn(layer, {
|
|
29735
|
+
...workload && { workload },
|
|
29736
|
+
...layerRoleArn !== void 0 && { roleArn: explicitRoleArnOrThrow("--layer-role-arn", layerRoleArn) }
|
|
29737
|
+
});
|
|
29738
|
+
layerTmpDirs.add(dir);
|
|
29739
|
+
flat.push({
|
|
29740
|
+
logicalId: layer.arn,
|
|
29741
|
+
assetPath: dir
|
|
29742
|
+
});
|
|
29743
|
+
}
|
|
29744
|
+
if (flat.length === 1) return flat[0].assetPath;
|
|
29745
|
+
const dir = mkdtempSync(path.join(tmpdir(), "cdkd-local-start-api-layers-"));
|
|
29746
|
+
try {
|
|
29747
|
+
for (const layer of flat) copyLayerTreeLastWins(layer.assetPath, dir);
|
|
29748
|
+
} catch (error) {
|
|
29749
|
+
rmSync(dir, {
|
|
29750
|
+
recursive: true,
|
|
29751
|
+
force: true
|
|
29752
|
+
});
|
|
29753
|
+
throw error;
|
|
29754
|
+
}
|
|
29755
|
+
layerTmpDirs.add(dir);
|
|
29756
|
+
return dir;
|
|
29757
|
+
}
|
|
29758
|
+
|
|
29759
|
+
// src/cli/commands/local-start-api/reload.ts
|
|
29760
|
+
async function reloadAllServers(args) {
|
|
29761
|
+
const { synthesizeAndBuild, servers, buildPool, logger, isClosing, retiredPoolDisposals } = args;
|
|
29762
|
+
let material;
|
|
29763
|
+
try {
|
|
29764
|
+
material = await synthesizeAndBuild();
|
|
29765
|
+
} catch (err) {
|
|
29766
|
+
logger.warn(`cdk synth failed during reload; keeping previous version. (${describeAwsFailure(err).detail})`);
|
|
29767
|
+
return;
|
|
29768
|
+
}
|
|
29769
|
+
if (isClosing?.()) return;
|
|
29770
|
+
const newGroups = groupRoutesByServer(material.routes);
|
|
29771
|
+
const newByKey = new Map(newGroups.map((g) => [g.serverKey, g]));
|
|
29772
|
+
const oldKeys = new Set(servers.map((s) => s.group.serverKey));
|
|
29773
|
+
const newKeys = new Set(newByKey.keys());
|
|
29774
|
+
const added = [...newKeys].filter((k) => !oldKeys.has(k));
|
|
29775
|
+
const removed = [...oldKeys].filter((k) => !newKeys.has(k));
|
|
29776
|
+
if (added.length > 0) logger.warn(`Reload detected new API surface(s): ${added.join(", ")}. Restart 'cdkd local start-api' to serve them.`);
|
|
29777
|
+
if (removed.length > 0) logger.warn(`Reload detected removed API surface(s): ${removed.join(", ")}. Their servers will keep serving stale routes until restart.`);
|
|
29778
|
+
for (const booted of servers) {
|
|
29779
|
+
const group = newByKey.get(booted.group.serverKey);
|
|
29780
|
+
if (!group) continue;
|
|
29781
|
+
const newPool = buildPool(filterSpecsForGroup(group, material));
|
|
29782
|
+
const newState = {
|
|
29783
|
+
routes: group.routes,
|
|
29784
|
+
pool: newPool,
|
|
29785
|
+
corsConfigByApiId: corsConfigForGroup(group, material)
|
|
29786
|
+
};
|
|
29787
|
+
const previousState = booted.server.setServerState(newState);
|
|
29788
|
+
booted.group = group;
|
|
29789
|
+
const disposal = previousState.pool.dispose().catch((err) => {
|
|
29790
|
+
logger.debug(`Previous pool dispose() failed for ${group.displayName}: ${describeAwsFailure(err).detail}`);
|
|
29791
|
+
});
|
|
29792
|
+
retiredPoolDisposals?.add(disposal);
|
|
29793
|
+
disposal.then(() => retiredPoolDisposals?.delete(disposal));
|
|
29794
|
+
}
|
|
29795
|
+
printPerServerRouteTables(servers);
|
|
29796
|
+
const allRoutes = servers.flatMap((s) => s.group.routes.map((r) => r.route));
|
|
29797
|
+
warnUnsupportedRoutes(allRoutes, logger);
|
|
29798
|
+
warnSsrfRiskyIntegrations(allRoutes, logger);
|
|
29799
|
+
}
|
|
29800
|
+
|
|
29390
29801
|
// src/cli/commands/local-start-api/command.ts
|
|
29391
29802
|
function formatServerListeningBanner(scheme, host, port, pathSuffix, label) {
|
|
29392
29803
|
return `Server listening on ${scheme}://${formatAuthority(host, port)}${pathSuffix} (${label})\n`;
|
|
@@ -29473,7 +29884,8 @@ async function localStartApiCommand(target, options) {
|
|
|
29473
29884
|
...overrides !== void 0 && { overrides }
|
|
29474
29885
|
});
|
|
29475
29886
|
const corsConfigByStack = buildCorsConfigByStack(targetStacks);
|
|
29476
|
-
const
|
|
29887
|
+
const stateSourceActive = options.fromState || isCfnFlagPresent(options);
|
|
29888
|
+
const stateByStack = stateSourceActive ? await loadStateForRoutedStacks(targetStacks, routes, routesWithAuth, options) : /* @__PURE__ */ new Map();
|
|
29477
29889
|
const profileCredentials = await profileCredentialsForWorkload(options.profile, resolveProfileCredentials);
|
|
29478
29890
|
if (options.profile && profileCredentials && !profileCredsFile) profileCredsFile = await writeProfileCredentialsFile(options.profile, profileCredentials, {
|
|
29479
29891
|
onDirCreated: (hostPath) => {
|
|
@@ -29494,6 +29906,7 @@ async function localStartApiCommand(target, options) {
|
|
|
29494
29906
|
inlineTmpDirs,
|
|
29495
29907
|
layerTmpDirs,
|
|
29496
29908
|
stateByStack,
|
|
29909
|
+
stateSourceActive,
|
|
29497
29910
|
skipPull: options.pull === false,
|
|
29498
29911
|
...options.layerRoleArn !== void 0 && { layerRoleArn: options.layerRoleArn },
|
|
29499
29912
|
...profileCredentials && { profileCredentials },
|
|
@@ -29828,19 +30241,46 @@ var EcsSecretsResolutionError = class EcsSecretsResolutionError extends Error {
|
|
|
29828
30241
|
async function resolveEcsSecrets(entries, options = {}) {
|
|
29829
30242
|
if (entries.length === 0) return [];
|
|
29830
30243
|
const logger = getLogger().child("ecs-secrets");
|
|
29831
|
-
const
|
|
29832
|
-
|
|
29833
|
-
|
|
29834
|
-
|
|
29835
|
-
|
|
29836
|
-
|
|
29837
|
-
|
|
29838
|
-
|
|
29839
|
-
|
|
29840
|
-
|
|
30244
|
+
const owned = [];
|
|
30245
|
+
const secretsClients = /* @__PURE__ */ new Map();
|
|
30246
|
+
const ssmClients = /* @__PURE__ */ new Map();
|
|
30247
|
+
const secretsFor = (containerName) => {
|
|
30248
|
+
if (options.secretsManagerClient) return options.secretsManagerClient;
|
|
30249
|
+
const realAws = realAwsException("SECRETS_MANAGER", { containerName });
|
|
30250
|
+
let client = secretsClients.get(realAws);
|
|
30251
|
+
if (!client) {
|
|
30252
|
+
client = new SecretsManagerClient({
|
|
30253
|
+
...awsClientDefaults({
|
|
30254
|
+
ignoreAssumedRole: true,
|
|
30255
|
+
realAws
|
|
30256
|
+
}),
|
|
30257
|
+
...options.region && { region: options.region }
|
|
30258
|
+
});
|
|
30259
|
+
secretsClients.set(realAws, client);
|
|
30260
|
+
owned.push(client);
|
|
30261
|
+
}
|
|
30262
|
+
return client;
|
|
30263
|
+
};
|
|
30264
|
+
const ssmFor = (containerName) => {
|
|
30265
|
+
if (options.ssmClient) return options.ssmClient;
|
|
30266
|
+
const realAws = realAwsException("SSM", { containerName });
|
|
30267
|
+
let client = ssmClients.get(realAws);
|
|
30268
|
+
if (!client) {
|
|
30269
|
+
client = new SSMClient({
|
|
30270
|
+
...awsClientDefaults({
|
|
30271
|
+
ignoreAssumedRole: true,
|
|
30272
|
+
realAws
|
|
30273
|
+
}),
|
|
30274
|
+
...options.region && { region: options.region }
|
|
30275
|
+
});
|
|
30276
|
+
ssmClients.set(realAws, client);
|
|
30277
|
+
owned.push(client);
|
|
30278
|
+
}
|
|
30279
|
+
return client;
|
|
30280
|
+
};
|
|
29841
30281
|
try {
|
|
29842
30282
|
return await Promise.all(entries.map(async (entry) => {
|
|
29843
|
-
const value = await resolveOne(entry,
|
|
30283
|
+
const value = await resolveOne(entry, () => secretsFor(entry.containerName), () => ssmFor(entry.containerName));
|
|
29844
30284
|
logger.debug(`Resolved secret ${displayIdent(entry.containerName)}.${displayIdent(entry.name)} (${displayIdent(entry.valueFrom, { maxCodePoints: SECRET_REF_MAX_CODE_POINTS })})`);
|
|
29845
30285
|
return {
|
|
29846
30286
|
...entry,
|
|
@@ -29848,16 +30288,15 @@ async function resolveEcsSecrets(entries, options = {}) {
|
|
|
29848
30288
|
};
|
|
29849
30289
|
}));
|
|
29850
30290
|
} finally {
|
|
29851
|
-
|
|
29852
|
-
if (ownsSsmClient) ssmClient.destroy();
|
|
30291
|
+
for (const c of owned) c.destroy();
|
|
29853
30292
|
}
|
|
29854
30293
|
}
|
|
29855
30294
|
async function resolveOne(entry, secretsClient, ssmClient) {
|
|
29856
30295
|
const arn = entry.valueFrom;
|
|
29857
30296
|
const shape = classifySecretArn(arn);
|
|
29858
30297
|
switch (shape.kind) {
|
|
29859
|
-
case "secrets-manager": return resolveSecretsManager(entry, shape, secretsClient);
|
|
29860
|
-
case "ssm": return resolveSsm(entry, shape, ssmClient);
|
|
30298
|
+
case "secrets-manager": return resolveSecretsManager(entry, shape, secretsClient());
|
|
30299
|
+
case "ssm": return resolveSsm(entry, shape, ssmClient());
|
|
29861
30300
|
case "unknown": throw new EcsSecretsResolutionError(`Container ${displayIdent(entry.containerName)} secret ${displayIdent(entry.name)} references an unsupported ValueFrom shape ${displayIdent(arn, { maxCodePoints: SECRET_REF_MAX_CODE_POINTS })}. Expected Secrets Manager ARN (optionally with :<json-key>::) or SSM Parameter ARN.`);
|
|
29862
30301
|
}
|
|
29863
30302
|
}
|
|
@@ -30251,6 +30690,15 @@ function groupSecretsByContainer(resolved) {
|
|
|
30251
30690
|
}
|
|
30252
30691
|
return out;
|
|
30253
30692
|
}
|
|
30693
|
+
function previewContainerEnv(container, envOverrides) {
|
|
30694
|
+
const previewEnv = {};
|
|
30695
|
+
for (const [k, v] of Object.entries(container.environment)) defineOwnKey(previewEnv, k, v);
|
|
30696
|
+
if (envOverrides) {
|
|
30697
|
+
applyOverrideMap(previewEnv, envOverrides["Parameters"]);
|
|
30698
|
+
applyOverrideMap(previewEnv, envOverrides[container.name]);
|
|
30699
|
+
}
|
|
30700
|
+
return previewEnv;
|
|
30701
|
+
}
|
|
30254
30702
|
function buildDockerRunArgs(opts) {
|
|
30255
30703
|
const { task, container, image, network, volumeByName, secrets, containerHost, roleArn } = opts;
|
|
30256
30704
|
const args = ["run", "-d"];
|
|
@@ -30289,7 +30737,9 @@ function buildDockerRunArgs(opts) {
|
|
|
30289
30737
|
ownerPublish.push(publish);
|
|
30290
30738
|
}
|
|
30291
30739
|
const wiring = getActiveWorkloadAwsWiring();
|
|
30292
|
-
const
|
|
30740
|
+
const previewEnv = previewContainerEnv(container, opts.envOverrides);
|
|
30741
|
+
const emulatorKeysOnly = workloadGetsEmulatorKeysOnly(previewEnv, wiring);
|
|
30742
|
+
const profileCredentialsFile = emulatorKeysOnly ? void 0 : opts.profileCredentialsFile;
|
|
30293
30743
|
if (profileCredentialsFile) both("-v", `${profileCredentialsFile.hostPath}:${profileCredentialsFile.containerPath}:ro`);
|
|
30294
30744
|
for (const m of wiring?.mounts ?? []) if (!container.mountPoints.some((mp) => mp.containerPath === m.containerPath)) both("-v", `${m.hostPath}:${m.containerPath}:ro`);
|
|
30295
30745
|
for (const mp of container.mountPoints) {
|
|
@@ -30314,6 +30764,13 @@ function buildDockerRunArgs(opts) {
|
|
|
30314
30764
|
...opts.sidecarIp !== void 0 && { sidecarIp: opts.sidecarIp }
|
|
30315
30765
|
});
|
|
30316
30766
|
Object.assign(finalEnv, metaEnv);
|
|
30767
|
+
const mixedReal = taskRoleAssumedInRealAws(previewEnv, wiring) && opts.mixedModeRealTaskCredentials || opts.mixedModeRealCredentials;
|
|
30768
|
+
if (mixedReal && wiring?.mixed && !emulatorKeysOnly) {
|
|
30769
|
+
delete finalEnv["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"];
|
|
30770
|
+
finalEnv["AWS_ACCESS_KEY_ID"] = mixedReal.accessKeyId;
|
|
30771
|
+
finalEnv["AWS_SECRET_ACCESS_KEY"] = mixedReal.secretAccessKey;
|
|
30772
|
+
if (mixedReal.sessionToken) finalEnv["AWS_SESSION_TOKEN"] = mixedReal.sessionToken;
|
|
30773
|
+
}
|
|
30317
30774
|
if (profileCredentialsFile) {
|
|
30318
30775
|
finalEnv["AWS_SHARED_CREDENTIALS_FILE"] = profileCredentialsFile.containerPath;
|
|
30319
30776
|
finalEnv["AWS_PROFILE"] = profileCredentialsFile.profileName;
|
|
@@ -30326,10 +30783,16 @@ function buildDockerRunArgs(opts) {
|
|
|
30326
30783
|
applyOverrideMap(finalEnv, overrides["Parameters"]);
|
|
30327
30784
|
applyOverrideMap(finalEnv, overrides[container.name]);
|
|
30328
30785
|
}
|
|
30329
|
-
if (wiring)
|
|
30330
|
-
|
|
30331
|
-
|
|
30332
|
-
|
|
30786
|
+
if (wiring) {
|
|
30787
|
+
const task = opts.emulatorTaskCredentials;
|
|
30788
|
+
finalEnv = applyWorkloadAwsWiringToEnv(finalEnv, wiring.mode === "emulator" ? task ? {
|
|
30789
|
+
...wiring,
|
|
30790
|
+
emulatorCredentials: task
|
|
30791
|
+
} : wiring : {
|
|
30792
|
+
...wiring,
|
|
30793
|
+
env: {}
|
|
30794
|
+
});
|
|
30795
|
+
}
|
|
30333
30796
|
const sensitiveKeys = /* @__PURE__ */ new Set([
|
|
30334
30797
|
...SENSITIVE_ENV_KEYS,
|
|
30335
30798
|
...secrets.map((s) => s.name),
|
|
@@ -30360,7 +30823,7 @@ function buildDockerRunArgs(opts) {
|
|
|
30360
30823
|
both("--entrypoint", container.entryPoint[0]);
|
|
30361
30824
|
entryPointTail = container.entryPoint.slice(1);
|
|
30362
30825
|
}
|
|
30363
|
-
both(image, ...entryPointTail, ...container.command ?? []);
|
|
30826
|
+
both(...noImplicitEcrPullArgs(image), image, ...entryPointTail, ...container.command ?? []);
|
|
30364
30827
|
const loopbackPorts = wiring ? effectiveLoopbackPorts(finalEnv, wiring) : [];
|
|
30365
30828
|
return {
|
|
30366
30829
|
args,
|
|
@@ -30418,6 +30881,7 @@ async function prepareOneImage(task, container, options) {
|
|
|
30418
30881
|
await pullImage(image.uri, options.skipPull);
|
|
30419
30882
|
return image.uri;
|
|
30420
30883
|
case "ecr": return pullEcrImage(image.uri, {
|
|
30884
|
+
workload: { containerName: container.name },
|
|
30421
30885
|
skipPull: options.skipPull,
|
|
30422
30886
|
...options.region !== void 0 && { region: options.region },
|
|
30423
30887
|
...options.ecrRoleArn !== void 0 && { ecrRoleArn: options.ecrRoleArn }
|
|
@@ -30436,6 +30900,7 @@ async function prepareOneImage(task, container, options) {
|
|
|
30436
30900
|
const tag = `cdkd-local-run-task-${(image.assetHash ?? "single").slice(0, 16)}`;
|
|
30437
30901
|
const actualTag = await buildDockerImage(asset, cdkOutDir, {
|
|
30438
30902
|
tag,
|
|
30903
|
+
workload: { containerName: container.name },
|
|
30439
30904
|
...task.stack.assetOutdir !== void 0 && { assetOutdir: task.stack.assetOutdir },
|
|
30440
30905
|
...options.platformOverride !== void 0 && { platform: options.platformOverride },
|
|
30441
30906
|
wrapError: (stderr) => new LocalInvokeBuildError$1(`docker build failed for ECS container ${displayIdent(container.name)} (${asset.source.directory !== void 0 ? displayAssemblyPath(asset.source.directory) : asset.source.executable ? redactDockerArgvValues(asset.source.executable).join(" ") : void 0}): ${displaySafe(stderr)}`)
|
|
@@ -30505,16 +30970,19 @@ async function realizeDockerVolumes(volumes, state) {
|
|
|
30505
30970
|
// src/local/ecs-task-runner/loopback-forwarder.ts
|
|
30506
30971
|
const execFileAsync$2 = promisify(execFile);
|
|
30507
30972
|
async function startNamespaceForwarder(state, forwarder, containerName, ports, wiring) {
|
|
30508
|
-
const label = wiring.mode === "emulator" ? `--aws-emulator ${wiring.emulatorEndpoint?.url ?? ""}` : "The AWS endpoint override (AWS_ENDPOINT_URL*)";
|
|
30973
|
+
const label = wiring.mode === "emulator" ? `--aws-emulator ${wiring.emulatorEndpoint?.url ?? ""}` : wiring.mixed ? `--aws-emulator ${wiring.mixed.emulatorEndpoint.url} (mixed mode)` : "The AWS endpoint override (AWS_ENDPOINT_URL*)";
|
|
30974
|
+
const plan = loopbackForwarderPlan(wiring, ports);
|
|
30975
|
+
const fatal = wiring.mode === "emulator" || plan.resignConfigHostPath !== void 0;
|
|
30509
30976
|
await prepareLocalLoopbackForwarder(wiring);
|
|
30510
30977
|
const { name } = forwarder;
|
|
30511
30978
|
const args = buildNamespaceOwnerForwarderDockerArgs({
|
|
30512
30979
|
name,
|
|
30513
30980
|
namespace: forwarder.namespace,
|
|
30514
|
-
ports,
|
|
30981
|
+
ports: plan.ports,
|
|
30515
30982
|
probe: wiring.probeHealth ? "health" : "tcp",
|
|
30516
30983
|
...wiring.caHostPath ? { caHostPath: wiring.caHostPath } : {},
|
|
30517
|
-
...wiring.skipPull ? { skipPull: true } : {}
|
|
30984
|
+
...wiring.skipPull ? { skipPull: true } : {},
|
|
30985
|
+
...plan.resignConfigHostPath ? { resignConfigHostPath: plan.resignConfigHostPath } : {}
|
|
30518
30986
|
});
|
|
30519
30987
|
getLogger().child("ecs-runner").debug(`Starting loopback forwarder ${name} for ports ${ports.join(",")}`);
|
|
30520
30988
|
try {
|
|
@@ -30534,8 +31002,8 @@ async function startNamespaceForwarder(state, forwarder, containerName, ports, w
|
|
|
30534
31002
|
} catch (err) {
|
|
30535
31003
|
if (state.closing) throw interruptedError();
|
|
30536
31004
|
await removeNamespaceForwarder(state, name);
|
|
30537
|
-
if (
|
|
30538
|
-
return failed(state,
|
|
31005
|
+
if (fatal) throw err;
|
|
31006
|
+
return failed(state, fatal, `start:${containerName}`, `${label}: ${err.message}`);
|
|
30539
31007
|
}
|
|
30540
31008
|
let result;
|
|
30541
31009
|
try {
|
|
@@ -30543,12 +31011,12 @@ async function startNamespaceForwarder(state, forwarder, containerName, ports, w
|
|
|
30543
31011
|
} catch (err) {
|
|
30544
31012
|
if (state.closing) throw interruptedError();
|
|
30545
31013
|
await removeNamespaceForwarder(state, name);
|
|
30546
|
-
return failed(state,
|
|
31014
|
+
return failed(state, fatal, `start:${containerName}`, `${label}: ${err.message}`);
|
|
30547
31015
|
}
|
|
30548
31016
|
if (state.closing) throw interruptedError();
|
|
30549
31017
|
if (result.ok) return true;
|
|
30550
31018
|
await removeNamespaceForwarder(state, name);
|
|
30551
|
-
return failed(state,
|
|
31019
|
+
return failed(state, fatal, String(result.failedPort ?? 0), describeForwarderFailure(result, label));
|
|
30552
31020
|
}
|
|
30553
31021
|
async function runForwarderContainer(args, containerName) {
|
|
30554
31022
|
try {
|
|
@@ -30561,8 +31029,8 @@ async function removeNamespaceForwarder(state, name) {
|
|
|
30561
31029
|
await removeContainer(name);
|
|
30562
31030
|
state.forwarders = state.forwarders.filter((f) => f.name !== name);
|
|
30563
31031
|
}
|
|
30564
|
-
function failed(state,
|
|
30565
|
-
if (
|
|
31032
|
+
function failed(state, fatal, key, message) {
|
|
31033
|
+
if (fatal) throw new CdkdError(message, "LOCAL_AWS_EMULATOR_FORWARDER_FAILED");
|
|
30566
31034
|
state.forwarderWarnings ??= /* @__PURE__ */ new Set();
|
|
30567
31035
|
if (!state.forwarderWarnings.has(key)) {
|
|
30568
31036
|
state.forwarderWarnings.add(key);
|
|
@@ -30587,10 +31055,12 @@ function describeDetachedForwarders(state) {
|
|
|
30587
31055
|
const forwarders = joined.map((f) => f.name).join(", ");
|
|
30588
31056
|
return safeMsg`Under the loopback AWS endpoint, these task containers share the network of a forwarder container, so that filter does not list them: ${containers}. Remove them before their forwarders: ${forwarders}.`;
|
|
30589
31057
|
}
|
|
31058
|
+
const DROPPED_ENTRY = /(?:^|: )(?:Environment|Secret) '.*' dropped:/;
|
|
30590
31059
|
async function runEcsTask(task, options, state) {
|
|
30591
31060
|
const logger = getLogger();
|
|
30592
31061
|
if (task.containers.length === 0) throw new EcsTaskRunnerError(`Task '${task.taskDefinitionLogicalId}' has no containers — nothing to run.`);
|
|
30593
31062
|
for (const w of task.warnings) logger.warn(w);
|
|
31063
|
+
warnAwsEmulatorStateSourceHint(task.warnings.filter((w) => DROPPED_ENTRY.test(w)).length, options.stateSourceGiven === true);
|
|
30594
31064
|
const dag = buildDependencyGraph(task.containers);
|
|
30595
31065
|
const startOrder = topoSort(dag, task.containers);
|
|
30596
31066
|
const finchRefusals = [];
|
|
@@ -30640,6 +31110,7 @@ async function runEcsTask(task, options, state) {
|
|
|
30640
31110
|
const tokenKeys = new Set(dynamicReferenceEnvKeys(c, options.envOverrides));
|
|
30641
31111
|
if (tokenKeys.size === 0) continue;
|
|
30642
31112
|
dynamicEnvByContainer.set(c.name, await resolveDynamicReferencesInEnv(c.environment, {
|
|
31113
|
+
workload: { containerName: c.name },
|
|
30643
31114
|
region: firstUsableRegion(options.stateRecordRegion, options.stackRegion, task.stack.region, options.region),
|
|
30644
31115
|
label: `Container ${c.name}`,
|
|
30645
31116
|
skipKeys: new Set(Object.keys(c.environment).filter((k) => !tokenKeys.has(k))),
|
|
@@ -30715,7 +31186,10 @@ async function runEcsTask(task, options, state) {
|
|
|
30715
31186
|
...options.skipHostPortPublish ? { skipHostPortPublish: true } : {},
|
|
30716
31187
|
...mergedAddHostFlags.length > 0 ? { addHostFlags: mergedAddHostFlags } : {},
|
|
30717
31188
|
...(options.networkAliasesByContainer?.get(container.name)?.length ?? 0) > 0 ? { networkAliases: options.networkAliasesByContainer.get(container.name) } : {},
|
|
30718
|
-
...options.profileCredentialsFile && { profileCredentialsFile: options.profileCredentialsFile }
|
|
31189
|
+
...options.profileCredentialsFile && { profileCredentialsFile: options.profileCredentialsFile },
|
|
31190
|
+
...options.mixedModeRealCredentials && { mixedModeRealCredentials: options.mixedModeRealCredentials },
|
|
31191
|
+
...options.mixedModeRealTaskCredentials && { mixedModeRealTaskCredentials: options.mixedModeRealTaskCredentials },
|
|
31192
|
+
...options.emulatorTaskCredentials && { emulatorTaskCredentials: options.emulatorTaskCredentials }
|
|
30719
31193
|
});
|
|
30720
31194
|
dockerCmds.set(container.name, built.args);
|
|
30721
31195
|
dockerLoopbackPorts.set(container.name, built.loopbackPorts);
|
|
@@ -30805,28 +31279,34 @@ async function runEcsTask(task, options, state) {
|
|
|
30805
31279
|
function readFromCfnStack(source) {
|
|
30806
31280
|
return source.fromState !== true && source.fromCfnStack !== void 0 && source.fromCfnStack !== false;
|
|
30807
31281
|
}
|
|
30808
|
-
async function resolvePlaceholderAccount(arn, source) {
|
|
31282
|
+
async function resolvePlaceholderAccount(arn, source, route) {
|
|
30809
31283
|
const { region, profile } = source;
|
|
30810
|
-
if (!arn.includes("${AWS::AccountId}")) return arn;
|
|
31284
|
+
if (!arn.includes("${AWS::AccountId}") && !arn.includes("${AWS::Partition}")) return arn;
|
|
30811
31285
|
const { STSClient, GetCallerIdentityCommand } = await import("@aws-sdk/client-sts");
|
|
30812
31286
|
let sts;
|
|
30813
31287
|
if (readFromCfnStack(source)) sts = new STSClient({
|
|
30814
31288
|
...awsClientDefaults({
|
|
30815
31289
|
profile,
|
|
30816
|
-
ignoreAssumedRole: true
|
|
31290
|
+
ignoreAssumedRole: true,
|
|
31291
|
+
realAws: route.realAws
|
|
30817
31292
|
}),
|
|
30818
31293
|
...region && { region },
|
|
30819
31294
|
...profile && { profile }
|
|
30820
31295
|
});
|
|
30821
31296
|
else sts = new STSClient({
|
|
30822
|
-
...awsClientDefaults({
|
|
31297
|
+
...awsClientDefaults({
|
|
31298
|
+
profile,
|
|
31299
|
+
realAws: route.realAws
|
|
31300
|
+
}),
|
|
30823
31301
|
...region && { region },
|
|
30824
31302
|
...profile && { profile }
|
|
30825
31303
|
});
|
|
30826
31304
|
try {
|
|
30827
|
-
const
|
|
31305
|
+
const identity = await sts.send(new GetCallerIdentityCommand({}));
|
|
31306
|
+
const account = identity.Account;
|
|
30828
31307
|
if (!account) throw new CdkdError(`--assume-task-role: GetCallerIdentity returned no Account; cannot resolve placeholder ARN ${plainIdentOr(arn, VALUE_NOT_SHOWN, { maxCodePoints: 613 })}. Pass the ARN explicitly: --assume-task-role '<arn>'`, "LOCAL_RUN_TASK_PLACEHOLDER_NO_ACCOUNT");
|
|
30829
|
-
|
|
31308
|
+
const partition = partitionOfArn(identity.Arn);
|
|
31309
|
+
return arn.split(TASK_ROLE_ACCOUNT_PLACEHOLDER).join(account).split(TASK_ROLE_PARTITION_PLACEHOLDER).join(partition);
|
|
30830
31310
|
} catch (err) {
|
|
30831
31311
|
if (err instanceof CdkdError) throw err;
|
|
30832
31312
|
const rendered = describeLocalAwsFailureForWarn(err, "STS GetCallerIdentity");
|
|
@@ -30835,11 +31315,28 @@ async function resolvePlaceholderAccount(arn, source) {
|
|
|
30835
31315
|
sts.destroy();
|
|
30836
31316
|
}
|
|
30837
31317
|
}
|
|
30838
|
-
|
|
31318
|
+
function taskRoleNameIsLogicalIdWarning(logicalId, reason) {
|
|
31319
|
+
const id = displayIdent(logicalId);
|
|
31320
|
+
switch (reason) {
|
|
31321
|
+
case "no-state-source": return `--assume-task-role: TaskRoleArn references the same-stack role ${id}, and without --from-state (cdkd-deployed) or --from-cfn-stack (cdk-deployed) cdkd cannot read the name it was deployed under, so cdkd assumes a role named ${id}. A role CDK names for you is deployed as '<Stack>-<LogicalId>-<suffix>', where AssumeRole fails: pass --from-state / --from-cfn-stack, or pass the ARN explicitly: --assume-task-role '<arn>'.`;
|
|
31322
|
+
case "state-not-read": return `--assume-task-role: cdkd read no state record for the task role ${id} (the target names no single stack, or the stack has no record: it is not deployed), so cdkd assumes a role named ${id}. Name the stack in the target ('<Stack>:<LogicalId>' or a display path), deploy the stack first, or pass the ARN explicitly: --assume-task-role '<arn>'.`;
|
|
31323
|
+
case "mixed-mode-emulator-iam": return `--assume-task-role: in AWS Emulator mixed mode the task role is assumed in real AWS, but the state record's IAM roles are the emulator's, so cdkd does not read ${id} from it and assumes a role named ${id}. Mark IAM as a "real-aws" exception under Parameters (AWS_ENDPOINT_URL_IAM), or pass the ARN explicitly: --assume-task-role '<arn>'.`;
|
|
31324
|
+
case "no-record": return `--assume-task-role: the state source has no record of the task role ${id}, so cdkd assumes a role named ${id}. Deploy the stack first, or pass the ARN explicitly: --assume-task-role '<arn>'.`;
|
|
31325
|
+
case "path-not-literal": return `--assume-task-role: the template's Path for the task role ${id} is not a literal IAM path, so cdkd cannot build its ARN from the stack's record, so cdkd assumes a role named ${id}. Pass the ARN explicitly: --assume-task-role '<arn>'.`;
|
|
31326
|
+
}
|
|
31327
|
+
}
|
|
31328
|
+
function partitionOfArn(arn) {
|
|
31329
|
+
const segment = arn?.split(":")[1];
|
|
31330
|
+
return arn?.startsWith("arn:") && segment ? segment : "aws";
|
|
31331
|
+
}
|
|
31332
|
+
async function assumeTaskRole(roleArn, region, route) {
|
|
30839
31333
|
assertSendableRoleArn(roleArn);
|
|
30840
31334
|
const { STSClient } = await import("@aws-sdk/client-sts");
|
|
30841
31335
|
const sts = new STSClient({
|
|
30842
|
-
...awsClientDefaults({
|
|
31336
|
+
...awsClientDefaults({
|
|
31337
|
+
ignoreAssumedRole: true,
|
|
31338
|
+
realAws: route.realAws
|
|
31339
|
+
}),
|
|
30843
31340
|
...region && { region }
|
|
30844
31341
|
});
|
|
30845
31342
|
try {
|
|
@@ -30869,13 +31366,17 @@ async function resolveStackAccountId$1(source) {
|
|
|
30869
31366
|
if (readFromCfnStack(source)) sts = new STSClient({
|
|
30870
31367
|
...awsClientDefaults({
|
|
30871
31368
|
profile,
|
|
30872
|
-
ignoreAssumedRole: true
|
|
31369
|
+
ignoreAssumedRole: true,
|
|
31370
|
+
realAws: realAwsException("STS")
|
|
30873
31371
|
}),
|
|
30874
31372
|
...region && { region },
|
|
30875
31373
|
...profile && { profile }
|
|
30876
31374
|
});
|
|
30877
31375
|
else sts = new STSClient({
|
|
30878
|
-
...awsClientDefaults({
|
|
31376
|
+
...awsClientDefaults({
|
|
31377
|
+
profile,
|
|
31378
|
+
realAws: realAwsException("STS")
|
|
31379
|
+
}),
|
|
30879
31380
|
...region && { region },
|
|
30880
31381
|
...profile && { profile }
|
|
30881
31382
|
});
|
|
@@ -30895,8 +31396,11 @@ async function buildEcsImageResolutionContext$1(candidate, stateProvider, option
|
|
|
30895
31396
|
const logger = getLogger();
|
|
30896
31397
|
if (!candidate) return {};
|
|
30897
31398
|
const needs = detectEcsImageResolutionNeeds(candidate);
|
|
30898
|
-
|
|
31399
|
+
const roleRecordUsable = !taskRoleRecordIsEmulatorSide();
|
|
31400
|
+
const wantsStateForTaskRole = !!stateProvider && needs.needsTaskRoleState && options.assumeTaskRole === true && roleRecordUsable;
|
|
31401
|
+
if (!needs.needsPseudoParameters && !needs.needsStateResources && !needs.needsEnvOrSecretSubstitution && !needs.needsAssetRepoMarker && !wantsStateForTaskRole) return {};
|
|
30899
31402
|
const ctx = {};
|
|
31403
|
+
if (!roleRecordUsable) ctx.ignoreStateForRoles = true;
|
|
30900
31404
|
let stateRecordRegion;
|
|
30901
31405
|
const wantsPseudoForEnvOrSecret = !!stateProvider && needs.needsEnvOrSecretSubstitution;
|
|
30902
31406
|
if (needs.needsPseudoParameters || wantsPseudoForEnvOrSecret) {
|
|
@@ -30923,7 +31427,7 @@ async function buildEcsImageResolutionContext$1(candidate, stateProvider, option
|
|
|
30923
31427
|
}
|
|
30924
31428
|
};
|
|
30925
31429
|
}
|
|
30926
|
-
const wantsState = needs.needsStateResources || needs.needsEnvOrSecretSubstitution;
|
|
31430
|
+
const wantsState = needs.needsStateResources || needs.needsEnvOrSecretSubstitution || wantsStateForTaskRole;
|
|
30927
31431
|
if (stateProvider && wantsState) {
|
|
30928
31432
|
const loaded = await stateProvider.load(candidate.stackName, candidate.region);
|
|
30929
31433
|
if (loaded) {
|
|
@@ -30951,6 +31455,9 @@ async function buildEcsImageResolutionContext$1(candidate, stateProvider, option
|
|
|
30951
31455
|
...stateRecordRegion !== void 0 && { stateRecordRegion }
|
|
30952
31456
|
};
|
|
30953
31457
|
}
|
|
31458
|
+
function taskRoleRecordIsEmulatorSide() {
|
|
31459
|
+
return getActiveWorkloadAwsWiring$1()?.mixed !== void 0 && !realAwsException("IAM");
|
|
31460
|
+
}
|
|
30954
31461
|
function pickCandidateStack(parsed, target, stacks) {
|
|
30955
31462
|
const byPrefix = stackForPathFormTarget(parsed, target, stacks);
|
|
30956
31463
|
if (byPrefix) return byPrefix;
|
|
@@ -30968,7 +31475,7 @@ function readEnvOverridesFile$2(filePath) {
|
|
|
30968
31475
|
if (!filePath) return void 0;
|
|
30969
31476
|
let raw;
|
|
30970
31477
|
try {
|
|
30971
|
-
raw =
|
|
31478
|
+
raw = readEnvVarsFileText(filePath);
|
|
30972
31479
|
} catch (err) {
|
|
30973
31480
|
throw new Error(`Failed to read --env-vars file '${filePath}': ${describeAwsFailure(err).detail}`);
|
|
30974
31481
|
}
|
|
@@ -30984,17 +31491,48 @@ function readEnvOverridesFile$2(filePath) {
|
|
|
30984
31491
|
}
|
|
30985
31492
|
|
|
30986
31493
|
// src/cli/commands/local-run-task/credentials.ts
|
|
30987
|
-
async function resolveSidecarCredentials(options, assumedCredentials) {
|
|
31494
|
+
async function resolveSidecarCredentials(options, assumedCredentials, emulatorTaskCredentials) {
|
|
30988
31495
|
const wiring = getActiveWorkloadAwsWiring();
|
|
30989
|
-
if (wiring?.mode === "emulator"
|
|
31496
|
+
if (wiring?.mode === "emulator" || wiring?.mixed) {
|
|
31497
|
+
if (emulatorTaskCredentials) return emulatorTaskCredentials;
|
|
31498
|
+
return wiring.mode === "emulator" ? wiring.emulatorCredentials : wiring.mixed?.emulatorCredentials;
|
|
31499
|
+
}
|
|
30990
31500
|
if (assumedCredentials) return assumedCredentials;
|
|
30991
31501
|
if (options.profile) return resolveProfileCredentials(options.profile);
|
|
30992
31502
|
return resolveHostDefaultCredentials();
|
|
30993
31503
|
}
|
|
31504
|
+
function planTaskRoleCredentials(containers, envOverrides, roleRequested) {
|
|
31505
|
+
const wiring = getActiveWorkloadAwsWiring();
|
|
31506
|
+
const envs = containers.map((c) => previewContainerEnv(c, envOverrides));
|
|
31507
|
+
const realSts = envs.map((env) => taskRoleAssumedInRealAws(env, wiring));
|
|
31508
|
+
const assumeInRealAws = roleRequested && realSts.some((r) => r);
|
|
31509
|
+
return {
|
|
31510
|
+
assumeInRealAws,
|
|
31511
|
+
assumeInEmulator: roleRequested && wiring?.mode === "emulator",
|
|
31512
|
+
ignoredInMixedMode: roleRequested && wiring?.mixed !== void 0 && !assumeInRealAws,
|
|
31513
|
+
callerIdentityNeeded: envs.some((env, i) => !workloadGetsEmulatorKeysOnly(env, wiring) && !(assumeInRealAws && realSts[i]))
|
|
31514
|
+
};
|
|
31515
|
+
}
|
|
30994
31516
|
async function resolveTaskCredentialChannels(options, assumedCredentials, opts) {
|
|
30995
|
-
const
|
|
30996
|
-
const
|
|
30997
|
-
|
|
31517
|
+
const emulatorTaskCredentials = opts?.emulatorTaskCredentials;
|
|
31518
|
+
const sidecarCredentials = await resolveSidecarCredentials(options, assumedCredentials, emulatorTaskCredentials);
|
|
31519
|
+
const emulatorTask = emulatorTaskCredentials && { emulatorTaskCredentials };
|
|
31520
|
+
if (getActiveWorkloadAwsWiring()?.mixed) {
|
|
31521
|
+
const caller = opts?.callerIdentityNeeded === false ? void 0 : options.profile ? await resolveProfileCredentials(options.profile) : await resolveHostDefaultCredentials();
|
|
31522
|
+
return {
|
|
31523
|
+
sidecarCredentials,
|
|
31524
|
+
profileCredsFile: void 0,
|
|
31525
|
+
...caller && { mixedModeRealCredentials: caller },
|
|
31526
|
+
...assumedCredentials && { mixedModeRealTaskCredentials: assumedCredentials },
|
|
31527
|
+
...emulatorTask
|
|
31528
|
+
};
|
|
31529
|
+
}
|
|
31530
|
+
if (getActiveWorkloadAwsWiring()?.mode === "emulator") return {
|
|
31531
|
+
sidecarCredentials,
|
|
31532
|
+
profileCredsFile: void 0,
|
|
31533
|
+
...emulatorTask
|
|
31534
|
+
};
|
|
31535
|
+
if (options.profile && sidecarCredentials && !assumedCredentials) return {
|
|
30998
31536
|
sidecarCredentials,
|
|
30999
31537
|
profileCredsFile: await writeProfileCredentialsFile(options.profile, sidecarCredentials, opts)
|
|
31000
31538
|
};
|
|
@@ -31013,6 +31551,9 @@ function buildRunEcsTaskOptions(options, channels, extra = {}) {
|
|
|
31013
31551
|
};
|
|
31014
31552
|
if (extra.envOverrides) runOpts.envOverrides = extra.envOverrides;
|
|
31015
31553
|
if (channels.sidecarCredentials) runOpts.taskCredentials = channels.sidecarCredentials;
|
|
31554
|
+
if (channels.mixedModeRealCredentials) runOpts.mixedModeRealCredentials = channels.mixedModeRealCredentials;
|
|
31555
|
+
if (channels.mixedModeRealTaskCredentials) runOpts.mixedModeRealTaskCredentials = channels.mixedModeRealTaskCredentials;
|
|
31556
|
+
if (channels.emulatorTaskCredentials) runOpts.emulatorTaskCredentials = channels.emulatorTaskCredentials;
|
|
31016
31557
|
if (extra.resolvedRoleArn) runOpts.taskRoleArn = extra.resolvedRoleArn;
|
|
31017
31558
|
if (options.platform) runOpts.platformOverride = options.platform;
|
|
31018
31559
|
if (options.region) runOpts.region = options.region;
|
|
@@ -31149,9 +31690,10 @@ async function localRunTaskCommand(target, options) {
|
|
|
31149
31690
|
const parsed = parseEcsTarget(target);
|
|
31150
31691
|
const candidate = pickCandidateStack(parsed, target, stacks);
|
|
31151
31692
|
refuseFailedLookups(candidate ? [candidate] : [], stacks, failedLookups);
|
|
31152
|
-
stateProvider = createLocalStateProvider$1(options, candidate?.stackName ?? "", candidate?.region);
|
|
31693
|
+
stateProvider = createLocalStateProvider$1(options, candidate?.stackName ?? "", candidate?.region, getActiveWorkloadAwsWiring$1()?.mixed ? { workload: UNNAMED_WORKLOAD } : {});
|
|
31153
31694
|
const { context: imageContext, stateRecordRegion } = await buildEcsImageResolutionContext$1(candidate, stateProvider, options);
|
|
31154
31695
|
const task = resolveEcsTaskTarget(target, stacks, imageContext);
|
|
31696
|
+
await applyPerContainerNames(task, target, stacks, candidate, options, imageContext);
|
|
31155
31697
|
const canPrompt = options.interactiveOverrides !== false && Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
31156
31698
|
if (!options.imageOverride?.length && !canPrompt) assertEcsTaskImagesResolvable(task);
|
|
31157
31699
|
logger.info(`Target: ${task.stack.stackName}/${task.taskDefinitionLogicalId} (family=${task.family}, containers=${task.containers.length})`);
|
|
@@ -31167,9 +31709,10 @@ async function localRunTaskCommand(target, options) {
|
|
|
31167
31709
|
...imageContext?.pseudoParameters && { pseudoParameters: imageContext.pseudoParameters },
|
|
31168
31710
|
consumerRegion,
|
|
31169
31711
|
crossStackResolver: resolver,
|
|
31170
|
-
resolveDynamicReferences: (value, producerRegion) => dynamicRefs.resolveString(value, {
|
|
31712
|
+
resolveDynamicReferences: (value, producerRegion, workload) => dynamicRefs.resolveString(value, {
|
|
31171
31713
|
region: producerRegion,
|
|
31172
31714
|
consumer: `Task ${task.taskDefinitionLogicalId} cross-stack env value`,
|
|
31715
|
+
workload,
|
|
31173
31716
|
overridable: false
|
|
31174
31717
|
})
|
|
31175
31718
|
};
|
|
@@ -31191,15 +31734,26 @@ async function localRunTaskCommand(target, options) {
|
|
|
31191
31734
|
cleanup().then(() => process.exit(130));
|
|
31192
31735
|
};
|
|
31193
31736
|
process.on("SIGINT", sigintHandler);
|
|
31737
|
+
const envOverrides = readEnvOverridesFile$2(options.envVars);
|
|
31738
|
+
const roleRequested = options.assumeTaskRole === true || typeof options.assumeTaskRole === "string";
|
|
31739
|
+
const plan = planTaskRoleCredentials(task.containers, envOverrides, roleRequested);
|
|
31740
|
+
if (plan.ignoredInMixedMode) logger.warn("--assume-task-role has no effect in AWS Emulator mixed mode unless a container marks STS as an exception (AWS_ENDPOINT_URL_STS=\"real-aws\"): calls to the emulator are re-signed with the emulator's keys, so the role is not assumed.");
|
|
31194
31741
|
let assumedCredentials;
|
|
31742
|
+
let emulatorTaskCredentials;
|
|
31195
31743
|
let resolvedRoleArn;
|
|
31196
|
-
|
|
31197
|
-
|
|
31198
|
-
|
|
31199
|
-
|
|
31200
|
-
|
|
31201
|
-
|
|
31202
|
-
|
|
31744
|
+
const assumes = plan.assumeInRealAws || plan.assumeInEmulator;
|
|
31745
|
+
if (options.assumeTaskRole === true && !task.taskRoleArn && assumes) throw new Error("--assume-task-role passed without an ARN but the task definition has no resolvable TaskRoleArn. Either the task definition does not set TaskRoleArn, or it points at a resource cdkd cannot resolve to an IAM Role at synth time. Pass the ARN explicitly: --assume-task-role '<arn>'");
|
|
31746
|
+
const roleArnTemplate = options.assumeTaskRole === true ? task.taskRoleArn : typeof options.assumeTaskRole === "string" ? options.assumeTaskRole : void 0;
|
|
31747
|
+
if (roleArnTemplate !== void 0 && assumes) {
|
|
31748
|
+
const realAws = plan.assumeInRealAws;
|
|
31749
|
+
if (options.assumeTaskRole === true && task.taskRoleUnresolved !== void 0) {
|
|
31750
|
+
const { logicalId, reason } = task.taskRoleUnresolved;
|
|
31751
|
+
logger.warn(taskRoleNameIsLogicalIdWarning(logicalId, !stateProvider ? "no-state-source" : taskRoleRecordIsEmulatorSide() ? "mixed-mode-emulator-iam" : reason === "no-state" ? "state-not-read" : reason));
|
|
31752
|
+
}
|
|
31753
|
+
resolvedRoleArn = options.assumeTaskRole === true ? await resolvePlaceholderAccount(roleArnTemplate, options, { realAws }) : roleArnTemplate;
|
|
31754
|
+
const creds = await assumeTaskRole(resolvedRoleArn, options.region, { realAws });
|
|
31755
|
+
if (realAws) assumedCredentials = creds;
|
|
31756
|
+
else emulatorTaskCredentials = creds;
|
|
31203
31757
|
}
|
|
31204
31758
|
channels = await resolveTaskCredentialChannels(options, assumedCredentials, {
|
|
31205
31759
|
onDirCreated: (hostPath) => {
|
|
@@ -31207,9 +31761,10 @@ async function localRunTaskCommand(target, options) {
|
|
|
31207
31761
|
},
|
|
31208
31762
|
onDirRemoved: () => {
|
|
31209
31763
|
credsHostPath = void 0;
|
|
31210
|
-
}
|
|
31764
|
+
},
|
|
31765
|
+
emulatorTaskCredentials,
|
|
31766
|
+
callerIdentityNeeded: plan.callerIdentityNeeded
|
|
31211
31767
|
});
|
|
31212
|
-
const envOverrides = readEnvOverridesFile$2(options.envVars);
|
|
31213
31768
|
const runOpts = buildRunEcsTaskOptions(options, channels, {
|
|
31214
31769
|
...envOverrides !== void 0 && { envOverrides },
|
|
31215
31770
|
...resolvedRoleArn !== void 0 && { resolvedRoleArn },
|
|
@@ -31217,6 +31772,7 @@ async function localRunTaskCommand(target, options) {
|
|
|
31217
31772
|
});
|
|
31218
31773
|
const hostGatewayExtraHosts = await resolveHostGatewayExtraHosts();
|
|
31219
31774
|
if (hostGatewayExtraHosts.length > 0) runOpts.hostGatewayExtraHosts = hostGatewayExtraHosts;
|
|
31775
|
+
if (stateProvider) runOpts.stateSourceGiven = true;
|
|
31220
31776
|
const imageOverrideResult = await resolveRunTaskImageOverride({
|
|
31221
31777
|
task,
|
|
31222
31778
|
target,
|
|
@@ -31252,6 +31808,32 @@ async function localRunTaskCommand(target, options) {
|
|
|
31252
31808
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
31253
31809
|
}
|
|
31254
31810
|
}
|
|
31811
|
+
async function applyPerContainerNames(task, target, stacks, candidate, options, baseContext) {
|
|
31812
|
+
if (!getActiveWorkloadAwsWiring$1()?.mixed || !candidate || !baseContext) return;
|
|
31813
|
+
const groups = groupWorkloadsRoutedApart(task.containers, (c) => ({ containerName: c.name }));
|
|
31814
|
+
for (const group of groups) {
|
|
31815
|
+
const names = group.items.map((c) => c.name);
|
|
31816
|
+
const provider = createLocalStateProvider$1(options, candidate.stackName, candidate.region, { workload: group.workload });
|
|
31817
|
+
if (!provider) continue;
|
|
31818
|
+
try {
|
|
31819
|
+
const loaded = await provider.load(candidate.stackName, candidate.region);
|
|
31820
|
+
if (!loaded) continue;
|
|
31821
|
+
const own = resolveEcsTaskTarget(target, stacks, {
|
|
31822
|
+
...baseContext,
|
|
31823
|
+
stateResources: loaded.resources
|
|
31824
|
+
});
|
|
31825
|
+
for (const name of names) {
|
|
31826
|
+
const mine = own.containers.find((c) => c.name === name);
|
|
31827
|
+
const into = task.containers.find((c) => c.name === name);
|
|
31828
|
+
if (!mine || !into) continue;
|
|
31829
|
+
into.environment = mine.environment;
|
|
31830
|
+
into.secrets = mine.secrets;
|
|
31831
|
+
}
|
|
31832
|
+
} finally {
|
|
31833
|
+
provider.dispose();
|
|
31834
|
+
}
|
|
31835
|
+
}
|
|
31836
|
+
}
|
|
31255
31837
|
|
|
31256
31838
|
// src/cli/commands/local-run-task.ts
|
|
31257
31839
|
function createLocalRunTaskCommand() {
|
|
@@ -31606,7 +32188,7 @@ function readEnvOverridesFile$1(filePath) {
|
|
|
31606
32188
|
if (!filePath) return void 0;
|
|
31607
32189
|
let raw;
|
|
31608
32190
|
try {
|
|
31609
|
-
raw =
|
|
32191
|
+
raw = readEnvVarsFileText(filePath);
|
|
31610
32192
|
} catch (err) {
|
|
31611
32193
|
throw new CdkdError(`Failed to read --env-vars file '${filePath}': ${describeAwsFailure(err).detail}`, "LOCAL_INVOKE_AGENTCORE_ENV_VARS_READ_FAILED");
|
|
31612
32194
|
}
|
|
@@ -31634,6 +32216,10 @@ async function buildContainerEnvWith(resolved, options, profileCredentials, prof
|
|
|
31634
32216
|
const logger = getLogger();
|
|
31635
32217
|
const overrides = readEnvOverridesFile$1(options.envVars);
|
|
31636
32218
|
const cdkPath = readCdkPathOrUndefined(resolved.resource);
|
|
32219
|
+
const workload = {
|
|
32220
|
+
logicalId: resolved.logicalId,
|
|
32221
|
+
cdkPath
|
|
32222
|
+
};
|
|
31637
32223
|
const overriddenKeys = keysOverriddenBy(resolved.environmentVariables, (env) => resolveEnvVars(resolved.logicalId, cdkPath, env, overrides).resolved);
|
|
31638
32224
|
let templateEnv = withoutKeys(resolved.environmentVariables, overriddenKeys);
|
|
31639
32225
|
const sensitiveEnvKeys = /* @__PURE__ */ new Set();
|
|
@@ -31643,7 +32229,8 @@ async function buildContainerEnvWith(resolved, options, profileCredentials, prof
|
|
|
31643
32229
|
consumerRegion: loaded.region,
|
|
31644
32230
|
resolveDynamicReferences: (value, producerRegion) => dynamicRefs.resolveString(value, {
|
|
31645
32231
|
region: producerRegion,
|
|
31646
|
-
consumer: `AgentCore Runtime ${resolved.logicalId} cross-stack env value
|
|
32232
|
+
consumer: `AgentCore Runtime ${resolved.logicalId} cross-stack env value`,
|
|
32233
|
+
workload
|
|
31647
32234
|
})
|
|
31648
32235
|
};
|
|
31649
32236
|
const pseudo = imageContext?.pseudoParameters ?? derivePseudoParametersFromRegion$1(loaded.region);
|
|
@@ -31663,9 +32250,11 @@ async function buildContainerEnvWith(resolved, options, profileCredentials, prof
|
|
|
31663
32250
|
const overrideKeyExample = cdkPath?.replace(/\/Resource$/, "") ?? resolved.logicalId;
|
|
31664
32251
|
logger.warn(`Environment variable ${key} contains a CloudFormation intrinsic and was dropped. Override it with --env-vars (e.g. {"${overrideKeyExample}":{"${key}":"<literal>"}}), or pass a state-source flag (e.g. --from-cfn-stack) to recover deployed values.`);
|
|
31665
32252
|
}
|
|
32253
|
+
warnAwsEmulatorStateSourceHint(envResult.unresolved.length, stateProvider !== void 0);
|
|
31666
32254
|
const skipKeys = keysNotFromTemplate(templateEnv, envResult.resolved);
|
|
31667
32255
|
for (const key of sensitiveEnvKeys) skipKeys.add(key);
|
|
31668
32256
|
const dynamic = await resolveDynamicReferencesInEnv(envResult.resolved, {
|
|
32257
|
+
workload,
|
|
31669
32258
|
region: firstUsableRegion(loaded?.region, options.stackRegion, resolved.stack.region, options.region),
|
|
31670
32259
|
label: `AgentCore Runtime ${resolved.logicalId}`,
|
|
31671
32260
|
skipKeys,
|
|
@@ -31694,13 +32283,17 @@ async function resolveStackAccountId(region, profile, fromState, fromCfnStack) {
|
|
|
31694
32283
|
if (!fromState && fromCfnStack !== void 0 && fromCfnStack !== false) sts = new STSClient({
|
|
31695
32284
|
...awsClientDefaults({
|
|
31696
32285
|
profile,
|
|
31697
|
-
ignoreAssumedRole: true
|
|
32286
|
+
ignoreAssumedRole: true,
|
|
32287
|
+
realAws: realAwsException("STS")
|
|
31698
32288
|
}),
|
|
31699
32289
|
...region && { region },
|
|
31700
32290
|
...profile && { profile }
|
|
31701
32291
|
});
|
|
31702
32292
|
else sts = new STSClient({
|
|
31703
|
-
...awsClientDefaults({
|
|
32293
|
+
...awsClientDefaults({
|
|
32294
|
+
profile,
|
|
32295
|
+
realAws: realAwsException("STS")
|
|
32296
|
+
}),
|
|
31704
32297
|
...region && { region },
|
|
31705
32298
|
...profile && { profile }
|
|
31706
32299
|
});
|
|
@@ -31785,7 +32378,10 @@ async function assumeAgentCoreExecutionRole(roleArn, region) {
|
|
|
31785
32378
|
assertSendableRoleArn(roleArn, (m) => new CdkdError(m, "LOCAL_INVOKE_AGENTCORE_ASSUME_ROLE_INVALID"));
|
|
31786
32379
|
const { STSClient } = await import("@aws-sdk/client-sts");
|
|
31787
32380
|
const sts = new STSClient({
|
|
31788
|
-
...awsClientDefaults({
|
|
32381
|
+
...awsClientDefaults({
|
|
32382
|
+
ignoreAssumedRole: true,
|
|
32383
|
+
realAws: mixedModeActive()
|
|
32384
|
+
}),
|
|
31789
32385
|
...region && { region }
|
|
31790
32386
|
});
|
|
31791
32387
|
try {
|
|
@@ -31890,13 +32486,21 @@ async function resolveAgentCoreImage(resolved, options, assemblyDir, loaded) {
|
|
|
31890
32486
|
if (entry) return buildContainerImage$1(entry.asset, cdkOutDir, {
|
|
31891
32487
|
assetOutdir: assemblyDir,
|
|
31892
32488
|
architecture,
|
|
31893
|
-
noBuild: options.build === false
|
|
32489
|
+
noBuild: options.build === false,
|
|
32490
|
+
workload: {
|
|
32491
|
+
logicalId: resolved.logicalId,
|
|
32492
|
+
cdkPath: readCdkPathOrUndefined(resolved.resource)
|
|
32493
|
+
}
|
|
31894
32494
|
});
|
|
31895
32495
|
}
|
|
31896
32496
|
}
|
|
31897
32497
|
if (parseEcrUri(containerUri)) {
|
|
31898
32498
|
logger.info(`Pulling agent image from ECR: ${containerUri}`);
|
|
31899
32499
|
return pullEcrImage(containerUri, {
|
|
32500
|
+
workload: {
|
|
32501
|
+
logicalId: resolved.logicalId,
|
|
32502
|
+
cdkPath: readCdkPathOrUndefined(resolved.resource)
|
|
32503
|
+
},
|
|
31900
32504
|
skipPull: options.pull === false,
|
|
31901
32505
|
...options.region !== void 0 && { region: options.region },
|
|
31902
32506
|
...options.ecrRoleArn !== void 0 && { ecrRoleArn: options.ecrRoleArn },
|
|
@@ -31952,6 +32556,10 @@ async function resolveAgentCoreCodeImageFromS3(resolved, code, s3Source, options
|
|
|
31952
32556
|
}));
|
|
31953
32557
|
}
|
|
31954
32558
|
const bundle = await downloadAndExtractS3Bundle(location, {
|
|
32559
|
+
workload: {
|
|
32560
|
+
logicalId: resolved.logicalId,
|
|
32561
|
+
cdkPath: readCdkPathOrUndefined(resolved.resource)
|
|
32562
|
+
},
|
|
31955
32563
|
...region !== void 0 && { region },
|
|
31956
32564
|
...options.profile !== void 0 && { profile: options.profile },
|
|
31957
32565
|
...credentials !== void 0 && { credentials }
|
|
@@ -32325,7 +32933,7 @@ async function localInvokeAgentCoreCommand(target, options) {
|
|
|
32325
32933
|
});
|
|
32326
32934
|
const candidate = pickAgentCoreCandidateStack$1(resolvedTarget, stacks);
|
|
32327
32935
|
refuseFailedLookups(candidate ? [candidate] : [], stacks, failedLookups);
|
|
32328
|
-
stateProvider = createLocalStateProvider$1(options, candidate?.stackName ?? "", await resolveCfnFallbackRegion(options, candidate?.region));
|
|
32936
|
+
stateProvider = createLocalStateProvider$1(options, candidate?.stackName ?? "", await resolveCfnFallbackRegion(options, candidate?.region), { workload: agentCoreTargetWorkload(resolvedTarget, stacks) });
|
|
32329
32937
|
const { context: imageContext, loaded: loadedState } = stateProvider && candidate ? await buildAgentCoreImageContext(candidate, stateProvider, options) : {
|
|
32330
32938
|
context: void 0,
|
|
32331
32939
|
loaded: void 0
|
|
@@ -32522,6 +33130,16 @@ async function localInvokeAgentCoreCommand(target, options) {
|
|
|
32522
33130
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
32523
33131
|
}
|
|
32524
33132
|
}
|
|
33133
|
+
function agentCoreTargetWorkload(target, stacks) {
|
|
33134
|
+
const hits = listTargets([...stacks]).agentCoreRuntimes.filter((e) => e.qualifiedId === target || e.displayPath === target || e.logicalId === target);
|
|
33135
|
+
if (hits.length !== 1) return void 0;
|
|
33136
|
+
const hit = hits[0];
|
|
33137
|
+
const path = ((stacks.find((s) => s.stackName === hit.stackName)?.template.Resources?.[hit.logicalId])?.Metadata)?.["aws:cdk:path"];
|
|
33138
|
+
return {
|
|
33139
|
+
logicalId: hit.logicalId,
|
|
33140
|
+
cdkPath: typeof path === "string" ? path : void 0
|
|
33141
|
+
};
|
|
33142
|
+
}
|
|
32525
33143
|
|
|
32526
33144
|
// src/cli/commands/local-invoke-agentcore.ts
|
|
32527
33145
|
function parseTimeoutMs(raw) {
|
|
@@ -32640,7 +33258,10 @@ async function assumeLambdaExecutionRole(roleArn, region) {
|
|
|
32640
33258
|
assertSendableRoleArn(roleArn, (m) => new CdkdError(m, "LOCAL_INVOKE_ASSUME_ROLE_INVALID"));
|
|
32641
33259
|
const { STSClient } = await import("@aws-sdk/client-sts");
|
|
32642
33260
|
const sts = new STSClient({
|
|
32643
|
-
...awsClientDefaults({
|
|
33261
|
+
...awsClientDefaults({
|
|
33262
|
+
ignoreAssumedRole: true,
|
|
33263
|
+
realAws: mixedModeActive()
|
|
33264
|
+
}),
|
|
32644
33265
|
...region && { region }
|
|
32645
33266
|
});
|
|
32646
33267
|
try {
|
|
@@ -32806,7 +33427,10 @@ async function resolveZipImagePlan(lambda, options) {
|
|
|
32806
33427
|
}
|
|
32807
33428
|
const image = resolveRuntimeImage(lambda.runtime);
|
|
32808
33429
|
await pullImage(image, options.pull === false);
|
|
32809
|
-
const layerPlan = await materializeLambdaLayersIncludingArns(lambda.layers, options
|
|
33430
|
+
const layerPlan = await materializeLambdaLayersIncludingArns(lambda.layers, options, {
|
|
33431
|
+
logicalId: lambda.logicalId,
|
|
33432
|
+
cdkPath: readCdkPathOrUndefined(lambda.resource)
|
|
33433
|
+
});
|
|
32810
33434
|
const containerCodePath = resolveRuntimeCodeMountPath(lambda.runtime);
|
|
32811
33435
|
const tmpfs = resolveTmpfsForLambda(lambda);
|
|
32812
33436
|
return {
|
|
@@ -32825,7 +33449,7 @@ async function resolveZipImagePlan(lambda, options) {
|
|
|
32825
33449
|
...tmpfs !== void 0 && { tmpfs }
|
|
32826
33450
|
};
|
|
32827
33451
|
}
|
|
32828
|
-
async function materializeLambdaLayersIncludingArns(layers, options) {
|
|
33452
|
+
async function materializeLambdaLayersIncludingArns(layers, options, workload) {
|
|
32829
33453
|
const extraTmpDirs = [];
|
|
32830
33454
|
const flat = [];
|
|
32831
33455
|
for (const layer of layers) {
|
|
@@ -32836,7 +33460,10 @@ async function materializeLambdaLayersIncludingArns(layers, options) {
|
|
|
32836
33460
|
});
|
|
32837
33461
|
continue;
|
|
32838
33462
|
}
|
|
32839
|
-
const dir = await materializeLayerFromArn(layer, {
|
|
33463
|
+
const dir = await materializeLayerFromArn(layer, {
|
|
33464
|
+
...workload && { workload },
|
|
33465
|
+
...options.layerRoleArn !== void 0 && { roleArn: explicitRoleArnOrThrow("--layer-role-arn", options.layerRoleArn) }
|
|
33466
|
+
});
|
|
32840
33467
|
extraTmpDirs.push(dir);
|
|
32841
33468
|
flat.push({
|
|
32842
33469
|
logicalId: layer.arn,
|
|
@@ -32926,19 +33553,25 @@ async function resolvePseudoParametersForInvoke(stackRegion, options) {
|
|
|
32926
33553
|
try {
|
|
32927
33554
|
const { STSClient, GetCallerIdentityCommand } = await import("@aws-sdk/client-sts");
|
|
32928
33555
|
let sts;
|
|
32929
|
-
if (!options.fromState)
|
|
33556
|
+
if (!options.fromState) {
|
|
33557
|
+
const realAws = realAwsException("STS");
|
|
33558
|
+
sts = new STSClient({
|
|
33559
|
+
...awsClientDefaults({
|
|
33560
|
+
profile: options.profile,
|
|
33561
|
+
ignoreAssumedRole: true,
|
|
33562
|
+
realAws
|
|
33563
|
+
}),
|
|
33564
|
+
...region && { region },
|
|
33565
|
+
...options.profile && { profile: options.profile }
|
|
33566
|
+
});
|
|
33567
|
+
} else sts = new STSClient({
|
|
32930
33568
|
...awsClientDefaults({
|
|
32931
33569
|
profile: options.profile,
|
|
32932
|
-
|
|
33570
|
+
realAws: realAwsException("STS")
|
|
32933
33571
|
}),
|
|
32934
33572
|
...region && { region },
|
|
32935
33573
|
...options.profile && { profile: options.profile }
|
|
32936
33574
|
});
|
|
32937
|
-
else sts = new STSClient({
|
|
32938
|
-
...awsClientDefaults({ profile: options.profile }),
|
|
32939
|
-
...region && { region },
|
|
32940
|
-
...options.profile && { profile: options.profile }
|
|
32941
|
-
});
|
|
32942
33575
|
try {
|
|
32943
33576
|
accountId = (await sts.send(new GetCallerIdentityCommand({}))).Account;
|
|
32944
33577
|
} finally {
|
|
@@ -32969,7 +33602,7 @@ function readEnvOverridesFile(filePath) {
|
|
|
32969
33602
|
if (!filePath) return void 0;
|
|
32970
33603
|
let raw;
|
|
32971
33604
|
try {
|
|
32972
|
-
raw =
|
|
33605
|
+
raw = readEnvVarsFileText(filePath);
|
|
32973
33606
|
} catch (err) {
|
|
32974
33607
|
throw new Error(`Failed to read --env-vars file '${filePath}': ${describeAwsFailure(err).detail}`);
|
|
32975
33608
|
}
|
|
@@ -33166,7 +33799,11 @@ async function resolveInvokeTemplateEnvWith(lambda, options, dynamicRefs) {
|
|
|
33166
33799
|
const lambdaCdkPath = readCdkPathOrUndefined(lambda.resource);
|
|
33167
33800
|
const overriddenKeys = keysOverriddenBy(declaredEnv, (env) => resolveEnvVars(lambda.logicalId, lambdaCdkPath, env, overrides).resolved);
|
|
33168
33801
|
let templateEnv = declaredEnv && withoutKeys(declaredEnv, overriddenKeys);
|
|
33169
|
-
const
|
|
33802
|
+
const workload = {
|
|
33803
|
+
logicalId: lambda.logicalId,
|
|
33804
|
+
cdkPath: lambdaCdkPath
|
|
33805
|
+
};
|
|
33806
|
+
const stateProvider = createLocalStateProvider$1(options, lambda.stack.stackName, lambda.stack.region, { workload });
|
|
33170
33807
|
if (stateProvider) try {
|
|
33171
33808
|
const loaded = await stateProvider.load(lambda.stack.stackName, lambda.stack.region);
|
|
33172
33809
|
if (loaded) {
|
|
@@ -33183,7 +33820,8 @@ async function resolveInvokeTemplateEnvWith(lambda, options, dynamicRefs) {
|
|
|
33183
33820
|
consumerRegion: loaded.region,
|
|
33184
33821
|
resolveDynamicReferences: (value, producerRegion) => dynamicRefs.resolveString(value, {
|
|
33185
33822
|
region: producerRegion,
|
|
33186
|
-
consumer: `Lambda ${lambda.logicalId} cross-stack env value
|
|
33823
|
+
consumer: `Lambda ${lambda.logicalId} cross-stack env value`,
|
|
33824
|
+
workload
|
|
33187
33825
|
})
|
|
33188
33826
|
};
|
|
33189
33827
|
if (envHasIntrinsicValue(templateEnv)) {
|
|
@@ -33210,9 +33848,14 @@ async function resolveInvokeTemplateEnvWith(lambda, options, dynamicRefs) {
|
|
|
33210
33848
|
const overrideKeyExample = lambdaCdkPath?.replace(/\/Resource$/, "") ?? lambda.logicalId;
|
|
33211
33849
|
logger.warn(`Environment variable ${key} contains a CloudFormation intrinsic and was dropped. Override it with --env-vars (e.g. {"${overrideKeyExample}":{"${key}":"<literal>"}}), or pass --from-state (cdkd-deployed) / --from-cfn-stack (cdk-deployed) to recover deployed values.`);
|
|
33212
33850
|
}
|
|
33851
|
+
warnAwsEmulatorStateSourceHint(envResult.unresolved.length, stateProvider !== void 0);
|
|
33213
33852
|
const plaintextKeys = new Set(stateAudit?.sensitiveKeys ?? []);
|
|
33214
33853
|
for (const key of keysNotFromTemplate(templateEnv, envResult.resolved)) plaintextKeys.add(key);
|
|
33215
33854
|
const dynamic = await resolveDynamicReferencesInEnv(envResult.resolved, {
|
|
33855
|
+
workload: {
|
|
33856
|
+
logicalId: lambda.logicalId,
|
|
33857
|
+
cdkPath: readCdkPathOrUndefined(lambda.resource)
|
|
33858
|
+
},
|
|
33216
33859
|
region: firstUsableRegion(ownerRegion, options.stackRegion, lambda.stack.region, options.region),
|
|
33217
33860
|
label: `Lambda ${lambda.logicalId}`,
|
|
33218
33861
|
skipKeys: plaintextKeys,
|
|
@@ -33236,12 +33879,20 @@ async function resolveContainerImagePlan(lambda, options) {
|
|
|
33236
33879
|
if (localBuild) imageRef = await buildContainerImage$1(localBuild.asset, localBuild.cdkOutDir, {
|
|
33237
33880
|
assetOutdir: localBuild.assetOutdir,
|
|
33238
33881
|
architecture: lambda.architecture,
|
|
33239
|
-
noBuild: options.build === false
|
|
33882
|
+
noBuild: options.build === false,
|
|
33883
|
+
workload: {
|
|
33884
|
+
logicalId: lambda.logicalId,
|
|
33885
|
+
cdkPath: readCdkPathOrUndefined(lambda.resource)
|
|
33886
|
+
}
|
|
33240
33887
|
});
|
|
33241
33888
|
else {
|
|
33242
33889
|
if (!parseEcrUri(lambda.imageUri)) throw new Error(`Container Lambda '${lambda.logicalId}' has no matching asset in cdk.out, and Code.ImageUri '${lambda.imageUri}' is not an ECR URI cdkd can authenticate against. Re-synthesize the CDK app (so cdk.out includes the build context) or deploy the image to ECR first.`);
|
|
33243
33890
|
logger.info(`No matching cdk.out asset for ${lambda.imageUri}; falling back to ECR pull (cross-region is supported — the ECR client is built for the image URI's region; pass --ecr-role-arn for a cross-account image)...`);
|
|
33244
33891
|
imageRef = await pullEcrImage(lambda.imageUri, {
|
|
33892
|
+
workload: {
|
|
33893
|
+
logicalId: lambda.logicalId,
|
|
33894
|
+
cdkPath: readCdkPathOrUndefined(lambda.resource)
|
|
33895
|
+
},
|
|
33245
33896
|
skipPull: options.pull === false,
|
|
33246
33897
|
...options.region !== void 0 && { region: options.region },
|
|
33247
33898
|
...options.ecrRoleArn !== void 0 && { ecrRoleArn: options.ecrRoleArn }
|
|
@@ -33300,11 +33951,13 @@ const CDKD_EMBED_CONFIG = {
|
|
|
33300
33951
|
setLevel: (level) => getLogger().setLevel(level),
|
|
33301
33952
|
getLevel: () => getLogger().getLevel()
|
|
33302
33953
|
},
|
|
33303
|
-
workloadIdentity: "caller"
|
|
33954
|
+
workloadIdentity: "caller",
|
|
33955
|
+
awsEmulatorSqsSidecar: true,
|
|
33956
|
+
deployCommand: "cdkd deploy"
|
|
33304
33957
|
};
|
|
33305
33958
|
function createLocalCommand() {
|
|
33306
33959
|
setEmbedConfig(CDKD_EMBED_CONFIG);
|
|
33307
|
-
setAwsEndpointOverrideSource(
|
|
33960
|
+
setAwsEndpointOverrideSource(mixedModeEmulatorOverride);
|
|
33308
33961
|
const local = new Command("local").description("Local execution of Lambda functions (RIE) and ECS task definitions (Docker required)");
|
|
33309
33962
|
const invoke = new Command("invoke").description("Run a Lambda function locally in a Docker container (RIE-backed). Target accepts a CDK display path (MyStack/MyApi/Handler) or stack-qualified logical ID (MyStack:MyApiHandler1234ABCD). Single-stack apps may omit the stack prefix.").argument("<target>", "CDK display path or stack-qualified logical ID of the Lambda to invoke").addOption(new Option("-e, --event <file>", "JSON event payload file (default: {})")).addOption(new Option("--event-stdin", "Read event JSON from stdin").default(false)).addOption(new Option("--env-vars <file>", "JSON env-var overrides (SAM-compatible: {\"LogicalId\":{\"KEY\":\"VALUE\"}})")).addOption(new Option("--no-pull", "Skip docker pull (use cached image) — no-op for IMAGE local-build path; `docker build` does not pull base layers by default")).addOption(new Option("--no-build", "Skip docker build on the IMAGE local-build path (use the previously-built tag). Requires the deterministic tag to already be in the local registry; errors with an actionable message when missing. No-op for ZIP Lambdas and the IMAGE ECR-pull path. Compatible with --no-pull.")).addOption(new Option("--debug-port <port>", "Node --inspect-brk port (default: off)")).addOption(new Option("--container-host <host>", "Host to bind the RIE port to").default("127.0.0.1")).addOption(new Option("--assume-role [arn]", "Assume the Lambda's deployed execution role and forward STS-issued temp credentials to the container so the handler runs with the deployed function's narrow permissions (closes the \"developer admin / function narrow\" skew). Three forms: (1) `--assume-role <arn>` assumes the explicit ARN; (2) `--assume-role` (bare) auto-resolves the function's execution role ARN from cdkd state (requires --from-state); (3) `--no-assume-role` explicitly opts out (forces dev creds even with --from-state). Off by default — when omitted, the developer's shell credentials are forwarded unchanged (SAM-compatible default). STS failures degrade to a warn + dev-creds fallback.")).addOption(new Option("--no-assume-role", "Explicitly opt out of assuming the deployed execution role: forward your ambient AWS credentials (or the --profile overlay) even when --from-state is set, and suppress the \"run with --assume-role\" hint. Distinct from omitting the flag, which still prints that hint.")).addOption(new Option("--layer-role-arn <arn>", "Role to sts:AssumeRole before calling lambda:GetLayerVersion on every literal-ARN entry in Properties.Layers. Use only when the dev credentials cannot read the layer — typically cross-account layers. AWS-published public layers (e.g. Lambda Powertools) are readable from every account and need no role.")).addOption(new Option("--ecr-role-arn <arn>", "Role ARN to assume before authenticating against ECR for cross-account / centralized registries. Issues sts:AssumeRole via the default credential chain and uses the temporary credentials for ecr:GetAuthorizationToken + docker pull. Required when the caller does not have direct cross-account access to the target repository. A same-account pull in ANY region does not need this flag: the ECR client is built for the image URI's own region, so crossing a region costs nothing extra.")).addOption(new Option("--from-state", "Read cdkd S3 state for the target stack and substitute Ref / Fn::GetAtt / Fn::Sub in env vars with the deployed physical IDs / attributes. Off by default — keep PR 1 warn-and-drop semantics; turn on for stacks already deployed via cdkd deploy.").default(false)).addOption(new Option("--from-cfn-stack [cfn-stack-name]", "Read a deployed CloudFormation stack via ListStackResources and substitute Ref / Fn::ImportValue in env vars with the deployed physical IDs / exports. Use for CDK apps deployed via the upstream CDK CLI (`cdk deploy`). Bare form uses the cdkd stack name; pass an explicit value when CFn stack name differs. Mutually exclusive with --from-state. Fn::GetAtt is warn-and-dropped in v1 (CFn ListStackResources does not return per-attribute values).")).addOption(new Option("--stack-region <region>", "Region of the state record to read. Used with --from-state when the same stack name has state in multiple regions, and with --from-cfn-stack as the CFn client region (cdkd does not have a separate --cfn-stack-region flag).").argParser(parseStackRegion)).action(withErrorHandling(localInvokeCommand));
|
|
33310
33963
|
[
|
|
@@ -33397,4 +34050,4 @@ function collectVerbFlags(program) {
|
|
|
33397
34050
|
}
|
|
33398
34051
|
|
|
33399
34052
|
export { resolveSecretDerivedPrincipals as a, buildProgram, isResolvableSecretPrincipalList as i, runDestroyForStack as n, canonicalizeIpProtocolValue as o, holdsUnprovenSecretPrincipalToken as r, canonicalizeIpv4Cidr as t };
|
|
33400
|
-
//# sourceMappingURL=program-
|
|
34053
|
+
//# sourceMappingURL=program-DSlYCm_d.js.map
|