@go-to-k/cdkd 0.238.6 → 0.240.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/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { a as getLiveRenderer, c as PATTERN_B_RESOURCE_TYPES, d as generateResourceNameWithFallback, f as withSkipPrefix, i as runStackBuffered, n as getLogger, o as PATTERN_B_NAME_OPTIONS, p as withStackName, s as PATTERN_B_NAME_PROPERTIES, u as generateResourceName } from "./logger-BzO-joNR.js";
|
|
3
3
|
import { A as withErrorHandling, C as StackHasActiveImportsError, S as ResourceUpdateNotSupportedError, _ as MissingCdkCliError, a as normalizeAwsTagsToCfn, b as ProvisioningError, f as LocalInvokeBuildError$1, i as matchesCdkPath, k as normalizeAwsError, l as CdkdError, m as LocalStartServiceError, n as isTerminationProtectionPropagationError, o as resolveExplicitPhysicalId, p as LocalMigrateError, r as CDK_PATH_TAG, s as assertRegionMatch, t as disableInstanceApiTermination, v as NestedStackChildDirectDestroyError, w as StackTerminationProtectionError, x as ResourceTimeoutError, y as PartialFailureError } from "./ec2-termination-protection-q-WGWgxa.js";
|
|
4
4
|
import { a as setAwsClients, i as resetAwsClients, r as getAwsClients, t as AwsClients } from "./aws-clients-B15NAPbL.js";
|
|
5
|
-
import { $ as getDockerCmd, A as DiffCalculator, B as buildAssetRedirectMap, C as findActionableSilentDrops, Ct as resolveBucketRegion, D as refStateLookupFromResource, E as cfnRefValueFromPhysicalId, F as rebuildClientForBucketRegion, G as BOOTSTRAP_MARKER_PREFIX, H as loadPublishableAssetManifest, I as shouldRetainResource, J as parseBootstrapMarker, K as ensureAssetStorage, L as AssetPublisher, M as TemplateParser, N as LockManager, O as WAFv2WebACLProvider, P as S3StateBackend, Q as formatDockerLoginError, R as stringifyValue, S as ProviderRegistry, T as IntrinsicFunctionResolver, U as rewriteTemplateAssetReferences, V as createAssetRedirectResolver, W as AssetModeResolver, X as validateContainerRepoName, Y as validateAssetBucketName, Z as buildDockerImage, _ as green, _t as CFN_TEMPLATE_URL_LIMIT, a as withRetry, at as synthesisStatusMessage, b as IAMRoleProvider, bt as uploadCfnTemplate, c as computeImplicitDeleteEdges, ct as resolveApp, d as isStatefulRecreateTargetSync, dt as resolveSkipPrefix, et as runDockerForeground, f as renderStatefulReason, ft as resolveStateBucketWithDefault, g as gray, gt as CFN_TEMPLATE_BODY_LIMIT, h as cyan, ht as warnDeprecatedNoPrefixCliFlag, i as withResourceDeadline, it as Synthesizer, j as DagBuilder, k as applyRoleArnIfSet, l as extractDeploymentEventError, lt as resolveAutoAssetStorage, m as bold, mt as resolveUseCdkBootstrapAssets, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as AssetManifestLoader, o as isRetryableTransientError, ot as getDefaultStateBucketName, p as formatResourceLine, pt as resolveStateBucketWithDefaultAndSource, q as getBootstrapMarkerKey, r as DeployEngine, rt as getDockerImageBySourceHash, s as IMPLICIT_DELETE_DEPENDENCIES, st as getLegacyStateBucketName, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as runDockerStreaming, u as MULTI_REGION_RECREATE_BLOCKED_TYPES, ut as resolveCaptureObservedState, v as red, vt as MIGRATE_TMP_PREFIX, w as CloudControlProvider, x as collectInlinePolicyNamesManagedBySiblings, xt as AssemblyReader, y as yellow, yt as findLargeInlineResources, z as WorkGraph } from "./deploy-engine-
|
|
5
|
+
import { $ as getDockerCmd, A as DiffCalculator, B as buildAssetRedirectMap, C as findActionableSilentDrops, Ct as resolveBucketRegion, D as refStateLookupFromResource, E as cfnRefValueFromPhysicalId, F as rebuildClientForBucketRegion, G as BOOTSTRAP_MARKER_PREFIX, H as loadPublishableAssetManifest, I as shouldRetainResource, J as parseBootstrapMarker, K as ensureAssetStorage, L as AssetPublisher, M as TemplateParser, N as LockManager, O as WAFv2WebACLProvider, P as S3StateBackend, Q as formatDockerLoginError, R as stringifyValue, S as ProviderRegistry, T as IntrinsicFunctionResolver, U as rewriteTemplateAssetReferences, V as createAssetRedirectResolver, W as AssetModeResolver, X as validateContainerRepoName, Y as validateAssetBucketName, Z as buildDockerImage, _ as green, _t as CFN_TEMPLATE_URL_LIMIT, a as withRetry, at as synthesisStatusMessage, b as IAMRoleProvider, bt as uploadCfnTemplate, c as computeImplicitDeleteEdges, ct as resolveApp, d as isStatefulRecreateTargetSync, dt as resolveSkipPrefix, et as runDockerForeground, f as renderStatefulReason, ft as resolveStateBucketWithDefault, g as gray, gt as CFN_TEMPLATE_BODY_LIMIT, h as cyan, ht as warnDeprecatedNoPrefixCliFlag, i as withResourceDeadline, it as Synthesizer, j as DagBuilder, k as applyRoleArnIfSet, l as extractDeploymentEventError, lt as resolveAutoAssetStorage, m as bold, mt as resolveUseCdkBootstrapAssets, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as AssetManifestLoader, o as isRetryableTransientError, ot as getDefaultStateBucketName, p as formatResourceLine, pt as resolveStateBucketWithDefaultAndSource, q as getBootstrapMarkerKey, r as DeployEngine, rt as getDockerImageBySourceHash, s as IMPLICIT_DELETE_DEPENDENCIES, st as getLegacyStateBucketName, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as runDockerStreaming, u as MULTI_REGION_RECREATE_BLOCKED_TYPES, ut as resolveCaptureObservedState, v as red, vt as MIGRATE_TMP_PREFIX, w as CloudControlProvider, x as collectInlinePolicyNamesManagedBySiblings, xt as AssemblyReader, y as yellow, yt as findLargeInlineResources, z as WorkGraph } from "./deploy-engine-D_OJrSGP.js";
|
|
6
6
|
import { t as expectedOwnerParam } from "./expected-bucket-owner-BjEfUnkA.js";
|
|
7
7
|
import { t as ASGProvider } from "./asg-provider-Dbl1_mwT.js";
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -61,8 +61,10 @@ import { AccessPointNotFound, CreateAccessPointCommand, CreateFileSystemCommand,
|
|
|
61
61
|
import { CreateDeliveryStreamCommand, DeleteDeliveryStreamCommand, DescribeDeliveryStreamCommand, FirehoseClient, ListDeliveryStreamsCommand, ListTagsForDeliveryStreamCommand, ResourceNotFoundException as ResourceNotFoundException$10, TagDeliveryStreamCommand, UntagDeliveryStreamCommand, UpdateDestinationCommand } from "@aws-sdk/client-firehose";
|
|
62
62
|
import { AddTagsCommand as AddTagsCommand$1, CloudTrailClient, CreateTrailCommand, DeleteTrailCommand, GetEventSelectorsCommand, GetInsightSelectorsCommand, GetTrailCommand, GetTrailStatusCommand, ListTagsCommand as ListTagsCommand$1, ListTrailsCommand, PutEventSelectorsCommand, PutInsightSelectorsCommand, RemoveTagsCommand as RemoveTagsCommand$1, StartLoggingCommand, StopLoggingCommand, TrailNotFoundException, UpdateTrailCommand } from "@aws-sdk/client-cloudtrail";
|
|
63
63
|
import { BatchGetProjectsCommand, CodeBuildClient, CreateProjectCommand, DeleteProjectCommand, ListProjectsCommand, ResourceNotFoundException as ResourceNotFoundException$11, UpdateProjectCommand } from "@aws-sdk/client-codebuild";
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
64
|
+
import { CodeCommitClient, CreateRepositoryCommand as CreateRepositoryCommand$1, DeleteRepositoryCommand as DeleteRepositoryCommand$1, GetRepositoryCommand, ListRepositoriesCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$17, RepositoryDoesNotExistException, TagResourceCommand as TagResourceCommand$15, UntagResourceCommand as UntagResourceCommand$15, UpdateRepositoryDescriptionCommand, UpdateRepositoryEncryptionKeyCommand, UpdateRepositoryNameCommand } from "@aws-sdk/client-codecommit";
|
|
65
|
+
import { CreateLifecyclePolicyCommand, DLMClient, DeleteLifecyclePolicyCommand as DeleteLifecyclePolicyCommand$1, GetLifecyclePoliciesCommand, GetLifecyclePolicyCommand as GetLifecyclePolicyCommand$1, ResourceNotFoundException as ResourceNotFoundException$12, TagResourceCommand as TagResourceCommand$16, UntagResourceCommand as UntagResourceCommand$16, UpdateLifecyclePolicyCommand } from "@aws-sdk/client-dlm";
|
|
66
|
+
import { CreateVectorBucketCommand, DeleteIndexCommand, DeleteVectorBucketCommand, GetVectorBucketCommand, ListIndexesCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$18, ListVectorBucketsCommand, S3VectorsClient, TagResourceCommand as TagResourceCommand$17, UntagResourceCommand as UntagResourceCommand$17 } from "@aws-sdk/client-s3vectors";
|
|
67
|
+
import { CreateNamespaceCommand, CreateTableBucketCommand, CreateTableCommand as CreateTableCommand$2, DeleteNamespaceCommand as DeleteNamespaceCommand$1, DeleteTableBucketCommand, DeleteTableCommand as DeleteTableCommand$2, GetTableBucketCommand, GetTableCommand as GetTableCommand$1, ListNamespacesCommand as ListNamespacesCommand$1, ListTableBucketsCommand, ListTablesCommand as ListTablesCommand$1, ListTagsForResourceCommand as ListTagsForResourceCommand$19, NotFoundException as NotFoundException$5, S3TablesClient, TagResourceCommand as TagResourceCommand$18, UntagResourceCommand as UntagResourceCommand$18 } from "@aws-sdk/client-s3tables";
|
|
66
68
|
import { Document, Pair, Scalar, YAMLMap, YAMLSeq, parse as parse$1, stringify } from "yaml";
|
|
67
69
|
import { createLocalStartAgentCoreCommand, createLocalStartCloudFrontCommand, createLocalStateProvider, getEmbedConfig, isCfnFlagPresent, listTargets, rejectExplicitCfnStackWithMultipleStacks, resolveCfnFallbackRegion, setEmbedConfig, substituteAgainstState, substituteAgainstStateAsync, substituteEnvVarsFromState, substituteEnvVarsFromStateAsync } from "cdk-local";
|
|
68
70
|
import { A2A_CONTAINER_PORT, A2A_PATH, AGENTCORE_A2A_PROTOCOL, AGENTCORE_AGUI_PROTOCOL, AGENTCORE_MCP_PROTOCOL, ConnectionRegistry, EcsTaskResolutionError, HOST_GATEWAY_MIN_VERSION, LocalInvokeBuildError, MCP_CONTAINER_PORT, MCP_PATH, a2aInvokeOnce, addAlbSpecificOptions, addCommonEcsServiceOptions, addStartServiceSpecificOptions, albStrategy, architectureToPlatform, attachAuthorizers, attachStageContext, availableApiIdentifiers, bufferToBody, buildAgentCoreCodeImage, buildCognitoJwksUrl, buildConnectEvent, buildContainerImage, buildCorsConfigByApiId, buildCorsConfigFromCloudFrontChain, buildDisconnectEvent, buildJwksUrlFromIssuer, buildMessageEvent, buildMgmtEndpointEnvUrl, buildStageMap, classifySourceChange, createAuthorizerCache, createFileWatcher, createFileWatcher as createFileWatcher$1, createJwksCache, createWatchPredicates, defaultCredentialsLoader, derivePseudoParametersFromRegion, discoverRoutes, discoverWebSocketApis, downloadAndExtractS3Bundle, filterRoutesByApiIdentifier, groupRoutesByServer, handleConnectionsRequest, invokeAgentCore, invokeAgentCoreWs, materializeLayerFromArn, mcpInvokeOnce, parseConnectionsPath, parseSelectionExpressionPath, pickAgentCoreCandidateStack, pickAgentCoreCandidateStack as pickAgentCoreCandidateStack$1, probeHostGatewaySupport, readMtlsMaterialsFromDisk, resolveAgentCoreTarget, resolveEnvVars, resolveHostGatewayExtraHosts, resolveRuntimeCodeMountPath, resolveRuntimeFileExtension, resolveRuntimeImage, resolveSingleTarget, resolveWatchConfig, runEcsServiceEmulator, signAgentCoreInvocation, startApiServer, substituteImagePlaceholders, tryResolveImageFnJoin, verifyJwtViaDiscovery, waitForAgentCorePing } from "cdk-local/internal";
|
|
@@ -1885,7 +1887,7 @@ const FLUSH_INTERVAL_MS = 2e3;
|
|
|
1885
1887
|
const FLUSH_EVENT_THRESHOLD = 50;
|
|
1886
1888
|
/** Build-time cdkd version, with a dev fallback for non-built contexts. */
|
|
1887
1889
|
function getCdkdVersion() {
|
|
1888
|
-
return "0.
|
|
1890
|
+
return "0.240.0";
|
|
1889
1891
|
}
|
|
1890
1892
|
/**
|
|
1891
1893
|
* Generate a time-sortable unique run id, e.g.
|
|
@@ -35162,6 +35164,564 @@ var CodeBuildProvider = class {
|
|
|
35162
35164
|
}
|
|
35163
35165
|
};
|
|
35164
35166
|
|
|
35167
|
+
//#endregion
|
|
35168
|
+
//#region src/provisioning/providers/codecommit-repository-provider.ts
|
|
35169
|
+
/**
|
|
35170
|
+
* Convert the CFn `Tags` list shape to CodeCommit's `Record<string, string>`
|
|
35171
|
+
* map. Entries without a string `Key` are skipped; non-string values are
|
|
35172
|
+
* stringified (post-intrinsic-resolution values can be numbers/booleans).
|
|
35173
|
+
* Returns `undefined` for an absent/empty list so callers can omit the field.
|
|
35174
|
+
*/
|
|
35175
|
+
function toSdkTagMap(tags) {
|
|
35176
|
+
if (!tags || tags.length === 0) return void 0;
|
|
35177
|
+
const out = {};
|
|
35178
|
+
for (const tag of tags) {
|
|
35179
|
+
if (typeof tag?.Key !== "string" || tag.Key.length === 0) continue;
|
|
35180
|
+
const value = tag.Value;
|
|
35181
|
+
out[tag.Key] = typeof value === "string" ? value : typeof value === "number" || typeof value === "boolean" ? String(value) : "";
|
|
35182
|
+
}
|
|
35183
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
35184
|
+
}
|
|
35185
|
+
/** Order-independent equality for two SDK tag maps. */
|
|
35186
|
+
function tagMapsEqual(a, b) {
|
|
35187
|
+
const aKeys = Object.keys(a);
|
|
35188
|
+
if (aKeys.length !== Object.keys(b).length) return false;
|
|
35189
|
+
return aKeys.every((k) => b[k] === a[k]);
|
|
35190
|
+
}
|
|
35191
|
+
/**
|
|
35192
|
+
* AWS CodeCommit Repository Provider
|
|
35193
|
+
*
|
|
35194
|
+
* Implements resource provisioning for AWS::CodeCommit::Repository using the
|
|
35195
|
+
* CodeCommit SDK. The type is `ProvisioningType: NON_PROVISIONABLE`, so the
|
|
35196
|
+
* Cloud Control fallback cannot handle it — without this SDK provider cdkd's
|
|
35197
|
+
* pre-flight rejects the type outright (issue #1045). CodeCommit returned to
|
|
35198
|
+
* full General Availability on 2025-11-24, so the service is fully usable for
|
|
35199
|
+
* new sign-ups again.
|
|
35200
|
+
*
|
|
35201
|
+
* Physical id: the repository NAME (every CodeCommit API is name-based;
|
|
35202
|
+
* there is no lookup-by-id API). CloudFormation's `Ref` returns the
|
|
35203
|
+
* repository ID (a GUID), so `create()` stores `RepositoryId` in attributes
|
|
35204
|
+
* and the intrinsic resolver's `cfnRefValueFromPhysicalId` recovers it via
|
|
35205
|
+
* `stateLookup` for CFn `Ref` parity.
|
|
35206
|
+
*/
|
|
35207
|
+
var CodeCommitRepositoryProvider = class {
|
|
35208
|
+
client;
|
|
35209
|
+
providerRegion = process.env["AWS_REGION"];
|
|
35210
|
+
logger = getLogger().child("CodeCommitRepositoryProvider");
|
|
35211
|
+
handledProperties = new Map([["AWS::CodeCommit::Repository", new Set([
|
|
35212
|
+
"RepositoryName",
|
|
35213
|
+
"RepositoryDescription",
|
|
35214
|
+
"KmsKeyId",
|
|
35215
|
+
"Tags"
|
|
35216
|
+
])]]);
|
|
35217
|
+
unhandledByDesign = new Map([["AWS::CodeCommit::Repository", new Map([["Code", "CFn-only seed-content orchestration (S3 zip unpacked into an initial commit on a chosen branch); not wired in v1 — pre-flight rejects templates carrying it so nothing is silently dropped; a follow-up could implement it via CreateCommit/PutFile"], ["Triggers", "repository trigger management not wired in v1 — pre-flight rejects templates carrying it so nothing is silently dropped; a follow-up could implement it via PutRepositoryTriggers"]])]]);
|
|
35218
|
+
getClient() {
|
|
35219
|
+
if (!this.client) this.client = new CodeCommitClient(this.providerRegion ? { region: this.providerRegion } : {});
|
|
35220
|
+
return this.client;
|
|
35221
|
+
}
|
|
35222
|
+
/**
|
|
35223
|
+
* Build the `Fn::GetAtt` attribute map from a `RepositoryMetadata`
|
|
35224
|
+
* response. `RepositoryId` is additionally stored so the intrinsic
|
|
35225
|
+
* resolver can recover CFn's `Ref` value (the repository ID) from state.
|
|
35226
|
+
*/
|
|
35227
|
+
toAttributes(metadata) {
|
|
35228
|
+
return {
|
|
35229
|
+
Arn: metadata?.Arn ?? "",
|
|
35230
|
+
CloneUrlHttp: metadata?.cloneUrlHttp ?? "",
|
|
35231
|
+
CloneUrlSsh: metadata?.cloneUrlSsh ?? "",
|
|
35232
|
+
Name: metadata?.repositoryName ?? "",
|
|
35233
|
+
KmsKeyId: metadata?.kmsKeyId ?? "",
|
|
35234
|
+
RepositoryId: metadata?.repositoryId ?? ""
|
|
35235
|
+
};
|
|
35236
|
+
}
|
|
35237
|
+
/**
|
|
35238
|
+
* Create a CodeCommit Repository
|
|
35239
|
+
*/
|
|
35240
|
+
async create(logicalId, resourceType, properties) {
|
|
35241
|
+
this.logger.debug(`Creating CodeCommit Repository ${logicalId}`);
|
|
35242
|
+
const repositoryName = properties["RepositoryName"] || generateResourceName(logicalId, { maxLength: 100 });
|
|
35243
|
+
try {
|
|
35244
|
+
const tags = toSdkTagMap(properties["Tags"]);
|
|
35245
|
+
const description = properties["RepositoryDescription"];
|
|
35246
|
+
const kmsKeyId = properties["KmsKeyId"];
|
|
35247
|
+
const metadata = (await this.getClient().send(new CreateRepositoryCommand$1({
|
|
35248
|
+
repositoryName,
|
|
35249
|
+
...description !== void 0 ? { repositoryDescription: description } : {},
|
|
35250
|
+
...kmsKeyId !== void 0 ? { kmsKeyId } : {},
|
|
35251
|
+
...tags ? { tags } : {}
|
|
35252
|
+
}))).repositoryMetadata;
|
|
35253
|
+
if (!metadata?.repositoryName) throw new Error("CreateRepository did not return repository metadata");
|
|
35254
|
+
this.logger.debug(`Successfully created CodeCommit Repository ${logicalId}: ${metadata.repositoryName}`);
|
|
35255
|
+
return {
|
|
35256
|
+
physicalId: metadata.repositoryName,
|
|
35257
|
+
attributes: this.toAttributes(metadata)
|
|
35258
|
+
};
|
|
35259
|
+
} catch (error) {
|
|
35260
|
+
const cause = error instanceof Error ? error : void 0;
|
|
35261
|
+
throw new ProvisioningError(`Failed to create CodeCommit Repository ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, repositoryName, cause);
|
|
35262
|
+
}
|
|
35263
|
+
}
|
|
35264
|
+
/**
|
|
35265
|
+
* Update a CodeCommit Repository
|
|
35266
|
+
*
|
|
35267
|
+
* Mutable properties: RepositoryName (UpdateRepositoryName — CFn's docs
|
|
35268
|
+
* mark the property "Update requires: No interruption" and the registry
|
|
35269
|
+
* schema's createOnlyProperties is empty, so CFn parity is an IN-PLACE
|
|
35270
|
+
* rename that preserves the repository's git history; the repository ID —
|
|
35271
|
+
* CFn's `Ref` value — survives the rename), RepositoryDescription
|
|
35272
|
+
* (UpdateRepositoryDescription), KmsKeyId (UpdateRepositoryEncryptionKey),
|
|
35273
|
+
* Tags (TagResource / UntagResource — full tag removal handled explicitly,
|
|
35274
|
+
* see the ECR Tags regression class in issue #981).
|
|
35275
|
+
*
|
|
35276
|
+
* A rename returns the NEW repository name as `physicalId` with
|
|
35277
|
+
* `wasReplaced: false`; the deploy engine persists the returned physical
|
|
35278
|
+
* id into state unconditionally.
|
|
35279
|
+
*/
|
|
35280
|
+
async update(logicalId, physicalId, _resourceType, properties, previousProperties) {
|
|
35281
|
+
this.logger.debug(`Updating CodeCommit Repository ${logicalId} (${physicalId})`);
|
|
35282
|
+
let currentName = physicalId;
|
|
35283
|
+
try {
|
|
35284
|
+
const newName = properties["RepositoryName"];
|
|
35285
|
+
if (newName && newName !== physicalId) {
|
|
35286
|
+
try {
|
|
35287
|
+
await this.getClient().send(new UpdateRepositoryNameCommand({
|
|
35288
|
+
oldName: physicalId,
|
|
35289
|
+
newName
|
|
35290
|
+
}));
|
|
35291
|
+
} catch (err) {
|
|
35292
|
+
if (!(err instanceof RepositoryDoesNotExistException)) throw err;
|
|
35293
|
+
await this.getRepositoryMetadata(newName);
|
|
35294
|
+
this.logger.debug(`Rename ${physicalId} -> ${newName} already applied by a previous attempt`);
|
|
35295
|
+
}
|
|
35296
|
+
currentName = newName;
|
|
35297
|
+
this.logger.debug(`Renamed CodeCommit Repository ${physicalId} -> ${newName}`);
|
|
35298
|
+
}
|
|
35299
|
+
const newDescription = properties["RepositoryDescription"];
|
|
35300
|
+
if (newDescription !== previousProperties["RepositoryDescription"]) {
|
|
35301
|
+
await this.getClient().send(new UpdateRepositoryDescriptionCommand({
|
|
35302
|
+
repositoryName: currentName,
|
|
35303
|
+
repositoryDescription: newDescription ?? ""
|
|
35304
|
+
}));
|
|
35305
|
+
this.logger.debug(`Updated description for ${currentName}`);
|
|
35306
|
+
}
|
|
35307
|
+
const newKmsKeyId = properties["KmsKeyId"];
|
|
35308
|
+
if (newKmsKeyId !== previousProperties["KmsKeyId"]) {
|
|
35309
|
+
await this.getClient().send(new UpdateRepositoryEncryptionKeyCommand({
|
|
35310
|
+
repositoryName: currentName,
|
|
35311
|
+
kmsKeyId: newKmsKeyId ?? "alias/aws/codecommit"
|
|
35312
|
+
}));
|
|
35313
|
+
this.logger.debug(`Updated encryption key for ${currentName}`);
|
|
35314
|
+
}
|
|
35315
|
+
const newTags = properties["Tags"];
|
|
35316
|
+
const oldTags = previousProperties["Tags"];
|
|
35317
|
+
const newTagMap = toSdkTagMap(newTags) ?? {};
|
|
35318
|
+
const oldTagMap = toSdkTagMap(oldTags) ?? {};
|
|
35319
|
+
let metadata;
|
|
35320
|
+
if (!tagMapsEqual(newTagMap, oldTagMap)) {
|
|
35321
|
+
metadata = await this.getRepositoryMetadata(currentName);
|
|
35322
|
+
const repoArn = metadata?.Arn;
|
|
35323
|
+
if (repoArn) {
|
|
35324
|
+
const removedKeys = Object.keys(oldTagMap).filter((k) => !(k in newTagMap));
|
|
35325
|
+
if (removedKeys.length > 0) await this.getClient().send(new UntagResourceCommand$15({
|
|
35326
|
+
resourceArn: repoArn,
|
|
35327
|
+
tagKeys: removedKeys
|
|
35328
|
+
}));
|
|
35329
|
+
if (Object.keys(newTagMap).length > 0) await this.getClient().send(new TagResourceCommand$15({
|
|
35330
|
+
resourceArn: repoArn,
|
|
35331
|
+
tags: newTagMap
|
|
35332
|
+
}));
|
|
35333
|
+
this.logger.debug(`Updated tags for ${currentName}`);
|
|
35334
|
+
} else this.logger.warn(`Could not resolve ARN for CodeCommit Repository ${currentName}; tag update skipped`);
|
|
35335
|
+
}
|
|
35336
|
+
metadata = await this.getRepositoryMetadata(currentName);
|
|
35337
|
+
return {
|
|
35338
|
+
physicalId: currentName,
|
|
35339
|
+
wasReplaced: false,
|
|
35340
|
+
attributes: this.toAttributes(metadata)
|
|
35341
|
+
};
|
|
35342
|
+
} catch (error) {
|
|
35343
|
+
const cause = error instanceof Error ? error : void 0;
|
|
35344
|
+
throw new ProvisioningError(`Failed to update CodeCommit Repository ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, _resourceType, logicalId, physicalId, cause);
|
|
35345
|
+
}
|
|
35346
|
+
}
|
|
35347
|
+
/**
|
|
35348
|
+
* Delete a CodeCommit Repository
|
|
35349
|
+
*
|
|
35350
|
+
* `DeleteRepository` is idempotent on the AWS side: for an
|
|
35351
|
+
* already-deleted repository it does NOT throw — it returns a null
|
|
35352
|
+
* `repositoryId`. That silent-success shape would bypass the shared
|
|
35353
|
+
* region check entirely (the exact scenario `assertRegionMatch` exists
|
|
35354
|
+
* for: a client pointed at region B while the state says the repo lives
|
|
35355
|
+
* in region A), so a null `repositoryId` runs the region check before
|
|
35356
|
+
* being treated as idempotent success. A
|
|
35357
|
+
* `RepositoryDoesNotExistException` is additionally handled (same
|
|
35358
|
+
* check) for defense in depth.
|
|
35359
|
+
*/
|
|
35360
|
+
async delete(logicalId, physicalId, resourceType, _properties, context) {
|
|
35361
|
+
this.logger.debug(`Deleting CodeCommit Repository ${logicalId}: ${physicalId}`);
|
|
35362
|
+
let deletedRepositoryId;
|
|
35363
|
+
try {
|
|
35364
|
+
deletedRepositoryId = (await this.getClient().send(new DeleteRepositoryCommand$1({ repositoryName: physicalId }))).repositoryId;
|
|
35365
|
+
} catch (error) {
|
|
35366
|
+
if (error instanceof RepositoryDoesNotExistException) {
|
|
35367
|
+
assertRegionMatch(await this.getClient().config.region(), context?.expectedRegion, resourceType, logicalId, physicalId);
|
|
35368
|
+
this.logger.debug(`CodeCommit Repository ${physicalId} does not exist, skipping deletion`);
|
|
35369
|
+
return;
|
|
35370
|
+
}
|
|
35371
|
+
const cause = error instanceof Error ? error : void 0;
|
|
35372
|
+
throw new ProvisioningError(`Failed to delete CodeCommit Repository ${logicalId}: ${error instanceof Error ? error.message : String(error)}`, resourceType, logicalId, physicalId, cause);
|
|
35373
|
+
}
|
|
35374
|
+
if (!deletedRepositoryId) {
|
|
35375
|
+
assertRegionMatch(await this.getClient().config.region(), context?.expectedRegion, resourceType, logicalId, physicalId);
|
|
35376
|
+
this.logger.debug(`CodeCommit Repository ${physicalId} does not exist, skipping deletion`);
|
|
35377
|
+
return;
|
|
35378
|
+
}
|
|
35379
|
+
this.logger.debug(`Successfully deleted CodeCommit Repository ${logicalId}`);
|
|
35380
|
+
}
|
|
35381
|
+
/**
|
|
35382
|
+
* Get repository attributes for Fn::GetAtt resolution.
|
|
35383
|
+
*
|
|
35384
|
+
* Supported: `Arn`, `CloneUrlHttp`, `CloneUrlSsh`, `Name`, `KmsKeyId`
|
|
35385
|
+
* (the CFn-documented attribute set).
|
|
35386
|
+
*/
|
|
35387
|
+
async getAttribute(physicalId, _resourceType, attributeName) {
|
|
35388
|
+
switch (attributeName) {
|
|
35389
|
+
case "Name": return physicalId;
|
|
35390
|
+
case "Arn":
|
|
35391
|
+
case "CloneUrlHttp":
|
|
35392
|
+
case "CloneUrlSsh":
|
|
35393
|
+
case "KmsKeyId": {
|
|
35394
|
+
const metadata = await this.getRepositoryMetadata(physicalId);
|
|
35395
|
+
return this.toAttributes(metadata)[attributeName];
|
|
35396
|
+
}
|
|
35397
|
+
default: return;
|
|
35398
|
+
}
|
|
35399
|
+
}
|
|
35400
|
+
/**
|
|
35401
|
+
* Adopt an existing CodeCommit repository into cdkd state.
|
|
35402
|
+
*
|
|
35403
|
+
* Lookup order:
|
|
35404
|
+
* 1. `--resource` override or `Properties.RepositoryName` → verify via
|
|
35405
|
+
* `GetRepository`.
|
|
35406
|
+
* 2. `ListRepositories` paginated, then `ListTagsForResource(arn)` per
|
|
35407
|
+
* repository to match `aws:cdk:path` (CodeCommit uses the
|
|
35408
|
+
* `Record<string, string>` tag-map shape).
|
|
35409
|
+
*/
|
|
35410
|
+
async import(input) {
|
|
35411
|
+
const explicit = resolveExplicitPhysicalId(input, "RepositoryName");
|
|
35412
|
+
if (explicit) try {
|
|
35413
|
+
const resp = await this.getClient().send(new GetRepositoryCommand({ repositoryName: explicit }));
|
|
35414
|
+
return resp.repositoryMetadata?.repositoryName ? {
|
|
35415
|
+
physicalId: explicit,
|
|
35416
|
+
attributes: this.toAttributes(resp.repositoryMetadata)
|
|
35417
|
+
} : null;
|
|
35418
|
+
} catch (err) {
|
|
35419
|
+
if (err instanceof RepositoryDoesNotExistException) return null;
|
|
35420
|
+
throw err;
|
|
35421
|
+
}
|
|
35422
|
+
if (!input.cdkPath) return null;
|
|
35423
|
+
let nextToken;
|
|
35424
|
+
do {
|
|
35425
|
+
const list = await this.getClient().send(new ListRepositoriesCommand({ ...nextToken && { nextToken } }));
|
|
35426
|
+
for (const repo of list.repositories ?? []) {
|
|
35427
|
+
if (!repo.repositoryName) continue;
|
|
35428
|
+
let metadata;
|
|
35429
|
+
try {
|
|
35430
|
+
metadata = await this.getRepositoryMetadata(repo.repositoryName);
|
|
35431
|
+
} catch (err) {
|
|
35432
|
+
if (err instanceof RepositoryDoesNotExistException) continue;
|
|
35433
|
+
throw err;
|
|
35434
|
+
}
|
|
35435
|
+
if (!metadata?.Arn) continue;
|
|
35436
|
+
if ((await this.getClient().send(new ListTagsForResourceCommand$17({ resourceArn: metadata.Arn }))).tags?.["aws:cdk:path"] === input.cdkPath) return {
|
|
35437
|
+
physicalId: repo.repositoryName,
|
|
35438
|
+
attributes: this.toAttributes(metadata)
|
|
35439
|
+
};
|
|
35440
|
+
}
|
|
35441
|
+
nextToken = list.nextToken;
|
|
35442
|
+
} while (nextToken);
|
|
35443
|
+
return null;
|
|
35444
|
+
}
|
|
35445
|
+
/**
|
|
35446
|
+
* Fetch the repository's metadata via `GetRepository`. Throws
|
|
35447
|
+
* `RepositoryDoesNotExistException` through to the caller.
|
|
35448
|
+
*/
|
|
35449
|
+
async getRepositoryMetadata(repositoryName) {
|
|
35450
|
+
return (await this.getClient().send(new GetRepositoryCommand({ repositoryName }))).repositoryMetadata;
|
|
35451
|
+
}
|
|
35452
|
+
};
|
|
35453
|
+
|
|
35454
|
+
//#endregion
|
|
35455
|
+
//#region src/provisioning/providers/dlm-lifecycle-policy-provider.ts
|
|
35456
|
+
/**
|
|
35457
|
+
* SDK Provider for AWS::DLM::LifecyclePolicy (Data Lifecycle Manager).
|
|
35458
|
+
*
|
|
35459
|
+
* Why an SDK provider (issue #1040): the type is
|
|
35460
|
+
* `ProvisioningType: NON_PROVISIONABLE`, so cdkd's Cloud Control fallback
|
|
35461
|
+
* cannot handle it and pre-flight rejected it. The DLM API surface is small
|
|
35462
|
+
* and the CFn property shape maps 1:1 onto the SDK's PascalCase inputs; the
|
|
35463
|
+
* only conversion is the CFn `Tags` list <-> DLM tag-map.
|
|
35464
|
+
*
|
|
35465
|
+
* physicalId is the service-generated policy id (`policy-0123456789abcdef0`)
|
|
35466
|
+
* — matches CFn, where `Ref` returns the policy id (`Id` is the
|
|
35467
|
+
* primaryIdentifier). `Fn::GetAtt Arn` returns the policy ARN.
|
|
35468
|
+
*
|
|
35469
|
+
* API mapping:
|
|
35470
|
+
* - create -> CreateLifecyclePolicy (+ GetLifecyclePolicy for the Arn
|
|
35471
|
+
* attribute — the create response only carries PolicyId)
|
|
35472
|
+
* - update -> UpdateLifecyclePolicy for policy fields, plus explicit
|
|
35473
|
+
* TagResource / UntagResource for tag diffs (the update
|
|
35474
|
+
* API has no Tags parameter). Tag removal — including a
|
|
35475
|
+
* FULL `Tags` property removal — is handled explicitly
|
|
35476
|
+
* via UntagResource (the #981 ECR regression class).
|
|
35477
|
+
* - delete -> DeleteLifecyclePolicy (NotFound idempotent, guarded by
|
|
35478
|
+
* assertRegionMatch)
|
|
35479
|
+
* - getAttribute-> GetLifecyclePolicy (`Arn` from Policy.PolicyArn)
|
|
35480
|
+
*
|
|
35481
|
+
* `DefaultPolicy` is create-only at the API level (UpdateLifecyclePolicy has
|
|
35482
|
+
* no such parameter; CFn documents it as "Update requires: Replacement"), so
|
|
35483
|
+
* a change is rejected with `ResourceUpdateNotSupportedError` and the deploy
|
|
35484
|
+
* engine's `--replace` fallback recreates the policy.
|
|
35485
|
+
*/
|
|
35486
|
+
var DLMLifecyclePolicyProvider = class {
|
|
35487
|
+
client;
|
|
35488
|
+
providerRegion = process.env["AWS_REGION"];
|
|
35489
|
+
logger = getLogger().child("DLMLifecyclePolicyProvider");
|
|
35490
|
+
handledProperties = new Map([["AWS::DLM::LifecyclePolicy", new Set([
|
|
35491
|
+
"Description",
|
|
35492
|
+
"ExecutionRoleArn",
|
|
35493
|
+
"State",
|
|
35494
|
+
"PolicyDetails",
|
|
35495
|
+
"Tags",
|
|
35496
|
+
"DefaultPolicy",
|
|
35497
|
+
"CreateInterval",
|
|
35498
|
+
"RetainInterval",
|
|
35499
|
+
"CopyTags",
|
|
35500
|
+
"ExtendDeletion",
|
|
35501
|
+
"CrossRegionCopyTargets",
|
|
35502
|
+
"Exclusions"
|
|
35503
|
+
])]]);
|
|
35504
|
+
getClient() {
|
|
35505
|
+
if (!this.client) this.client = new DLMClient(this.providerRegion ? { region: this.providerRegion } : {});
|
|
35506
|
+
return this.client;
|
|
35507
|
+
}
|
|
35508
|
+
/**
|
|
35509
|
+
* Convert the CFn `Tags` list (`[{ Key, Value }]`) to the DLM tag map
|
|
35510
|
+
* (`Record<string, string>`). Returns `undefined` for an absent / empty
|
|
35511
|
+
* list so callers can omit the field.
|
|
35512
|
+
*/
|
|
35513
|
+
cfnTagsToMap(tags) {
|
|
35514
|
+
if (!Array.isArray(tags)) return void 0;
|
|
35515
|
+
const map = {};
|
|
35516
|
+
for (const t of tags) if (typeof t?.Key === "string" && t.Key.length > 0) map[t.Key] = typeof t.Value === "string" ? t.Value : "";
|
|
35517
|
+
return Object.keys(map).length > 0 ? map : void 0;
|
|
35518
|
+
}
|
|
35519
|
+
/**
|
|
35520
|
+
* Map the CFn property shape to the SDK input shape (shared by create and
|
|
35521
|
+
* update — every field name is PascalCase-identical). `Tags` and
|
|
35522
|
+
* `DefaultPolicy` are intentionally NOT included: create wires them
|
|
35523
|
+
* separately (update has neither parameter).
|
|
35524
|
+
*/
|
|
35525
|
+
toSdkFields(properties) {
|
|
35526
|
+
return {
|
|
35527
|
+
...properties["ExecutionRoleArn"] !== void 0 && { ExecutionRoleArn: properties["ExecutionRoleArn"] },
|
|
35528
|
+
...properties["Description"] !== void 0 && { Description: properties["Description"] },
|
|
35529
|
+
...properties["State"] !== void 0 && { State: properties["State"] },
|
|
35530
|
+
...properties["PolicyDetails"] !== void 0 && { PolicyDetails: properties["PolicyDetails"] },
|
|
35531
|
+
...properties["CreateInterval"] !== void 0 && { CreateInterval: properties["CreateInterval"] },
|
|
35532
|
+
...properties["RetainInterval"] !== void 0 && { RetainInterval: properties["RetainInterval"] },
|
|
35533
|
+
...properties["CopyTags"] !== void 0 && { CopyTags: properties["CopyTags"] },
|
|
35534
|
+
...properties["ExtendDeletion"] !== void 0 && { ExtendDeletion: properties["ExtendDeletion"] },
|
|
35535
|
+
...properties["CrossRegionCopyTargets"] !== void 0 && { CrossRegionCopyTargets: properties["CrossRegionCopyTargets"] },
|
|
35536
|
+
...properties["Exclusions"] !== void 0 && { Exclusions: properties["Exclusions"] }
|
|
35537
|
+
};
|
|
35538
|
+
}
|
|
35539
|
+
/** Fetch the policy ARN (`Fn::GetAtt Arn`) for a policy id. */
|
|
35540
|
+
async fetchPolicyArn(policyId) {
|
|
35541
|
+
return (await this.getClient().send(new GetLifecyclePolicyCommand$1({ PolicyId: policyId }))).Policy?.PolicyArn ?? "";
|
|
35542
|
+
}
|
|
35543
|
+
async create(logicalId, resourceType, properties) {
|
|
35544
|
+
this.logger.debug(`Creating DLM Lifecycle Policy ${logicalId}`);
|
|
35545
|
+
try {
|
|
35546
|
+
const tags = this.cfnTagsToMap(properties["Tags"]);
|
|
35547
|
+
const input = {
|
|
35548
|
+
...this.toSdkFields(properties),
|
|
35549
|
+
...properties["DefaultPolicy"] !== void 0 && { DefaultPolicy: properties["DefaultPolicy"] },
|
|
35550
|
+
...tags && { Tags: tags }
|
|
35551
|
+
};
|
|
35552
|
+
const response = await this.getClient().send(new CreateLifecyclePolicyCommand(input));
|
|
35553
|
+
if (!response.PolicyId) throw new Error("CreateLifecyclePolicy did not return a PolicyId");
|
|
35554
|
+
let arn = "";
|
|
35555
|
+
try {
|
|
35556
|
+
arn = await this.fetchPolicyArn(response.PolicyId);
|
|
35557
|
+
} catch (err) {
|
|
35558
|
+
this.logger.warn(`Created DLM Lifecycle Policy ${response.PolicyId} but could not fetch its ARN: ${err instanceof Error ? err.message : String(err)}`);
|
|
35559
|
+
}
|
|
35560
|
+
this.logger.debug(`Successfully created DLM Lifecycle Policy ${logicalId}: ${response.PolicyId}`);
|
|
35561
|
+
return {
|
|
35562
|
+
physicalId: response.PolicyId,
|
|
35563
|
+
attributes: arn ? { Arn: arn } : {}
|
|
35564
|
+
};
|
|
35565
|
+
} catch (error) {
|
|
35566
|
+
const cause = error instanceof Error ? error : void 0;
|
|
35567
|
+
throw new ProvisioningError(`Failed to create DLM Lifecycle Policy ${logicalId}: ${cause?.message ?? String(error)}`, resourceType, logicalId, void 0, cause);
|
|
35568
|
+
}
|
|
35569
|
+
}
|
|
35570
|
+
async update(logicalId, physicalId, resourceType, properties, previousProperties) {
|
|
35571
|
+
if (JSON.stringify(properties["DefaultPolicy"]) !== JSON.stringify(previousProperties["DefaultPolicy"])) throw new ResourceUpdateNotSupportedError(resourceType, logicalId, `DefaultPolicy cannot be changed in place; re-run with \`cdkd deploy --replace ${logicalId}\` to recreate the policy`);
|
|
35572
|
+
this.logger.debug(`Updating DLM Lifecycle Policy ${logicalId} (${physicalId})`);
|
|
35573
|
+
try {
|
|
35574
|
+
await this.getClient().send(new UpdateLifecyclePolicyCommand({
|
|
35575
|
+
PolicyId: physicalId,
|
|
35576
|
+
...this.toSdkFields(properties)
|
|
35577
|
+
}));
|
|
35578
|
+
const newTags = this.cfnTagsToMap(properties["Tags"]) ?? {};
|
|
35579
|
+
const oldTags = this.cfnTagsToMap(previousProperties["Tags"]) ?? {};
|
|
35580
|
+
const arn = await this.fetchPolicyArn(physicalId);
|
|
35581
|
+
const tagsChanged = JSON.stringify(newTags) !== JSON.stringify(oldTags);
|
|
35582
|
+
if (tagsChanged && !arn) this.logger.warn(`Skipping tag update for DLM Lifecycle Policy ${physicalId}: GetLifecyclePolicy returned no PolicyArn`);
|
|
35583
|
+
if (tagsChanged && arn) {
|
|
35584
|
+
const removedKeys = Object.keys(oldTags).filter((k) => !(k in newTags));
|
|
35585
|
+
if (removedKeys.length > 0) {
|
|
35586
|
+
await this.getClient().send(new UntagResourceCommand$16({
|
|
35587
|
+
ResourceArn: arn,
|
|
35588
|
+
TagKeys: removedKeys
|
|
35589
|
+
}));
|
|
35590
|
+
this.logger.debug(`Removed ${removedKeys.length} tag(s) from DLM Lifecycle Policy ${physicalId}`);
|
|
35591
|
+
}
|
|
35592
|
+
const tagsToAdd = {};
|
|
35593
|
+
for (const [k, v] of Object.entries(newTags)) if (oldTags[k] !== v) tagsToAdd[k] = v;
|
|
35594
|
+
if (Object.keys(tagsToAdd).length > 0) {
|
|
35595
|
+
await this.getClient().send(new TagResourceCommand$16({
|
|
35596
|
+
ResourceArn: arn,
|
|
35597
|
+
Tags: tagsToAdd
|
|
35598
|
+
}));
|
|
35599
|
+
this.logger.debug(`Added/updated ${Object.keys(tagsToAdd).length} tag(s) on DLM Lifecycle Policy ${physicalId}`);
|
|
35600
|
+
}
|
|
35601
|
+
}
|
|
35602
|
+
return {
|
|
35603
|
+
physicalId,
|
|
35604
|
+
wasReplaced: false,
|
|
35605
|
+
attributes: arn ? { Arn: arn } : {}
|
|
35606
|
+
};
|
|
35607
|
+
} catch (error) {
|
|
35608
|
+
if (error instanceof ResourceUpdateNotSupportedError) throw error;
|
|
35609
|
+
const cause = error instanceof Error ? error : void 0;
|
|
35610
|
+
throw new ProvisioningError(`Failed to update DLM Lifecycle Policy ${logicalId}: ${cause?.message ?? String(error)}`, resourceType, logicalId, physicalId, cause);
|
|
35611
|
+
}
|
|
35612
|
+
}
|
|
35613
|
+
async delete(logicalId, physicalId, resourceType, _properties, context) {
|
|
35614
|
+
this.logger.debug(`Deleting DLM Lifecycle Policy ${logicalId}: ${physicalId}`);
|
|
35615
|
+
try {
|
|
35616
|
+
await this.getClient().send(new DeleteLifecyclePolicyCommand$1({ PolicyId: physicalId }));
|
|
35617
|
+
this.logger.debug(`Successfully deleted DLM Lifecycle Policy ${logicalId}`);
|
|
35618
|
+
} catch (error) {
|
|
35619
|
+
if (error instanceof ResourceNotFoundException$12) {
|
|
35620
|
+
assertRegionMatch(await this.getClient().config.region(), context?.expectedRegion, resourceType, logicalId, physicalId);
|
|
35621
|
+
this.logger.debug(`DLM Lifecycle Policy ${physicalId} does not exist, skipping deletion`);
|
|
35622
|
+
return;
|
|
35623
|
+
}
|
|
35624
|
+
const cause = error instanceof Error ? error : void 0;
|
|
35625
|
+
throw new ProvisioningError(`Failed to delete DLM Lifecycle Policy ${logicalId}: ${cause?.message ?? String(error)}`, resourceType, logicalId, physicalId, cause);
|
|
35626
|
+
}
|
|
35627
|
+
}
|
|
35628
|
+
/**
|
|
35629
|
+
* Attribute fallback. `Arn` is cached in state at create/update time, so
|
|
35630
|
+
* this only fires for imported/degraded records.
|
|
35631
|
+
*/
|
|
35632
|
+
async getAttribute(physicalId, resourceType, attributeName) {
|
|
35633
|
+
if (attributeName === "Id" || attributeName === "PolicyId") return physicalId;
|
|
35634
|
+
if (attributeName !== "Arn") throw new ProvisioningError(`Unknown attribute ${attributeName} for ${resourceType}`, resourceType, physicalId);
|
|
35635
|
+
try {
|
|
35636
|
+
return await this.fetchPolicyArn(physicalId);
|
|
35637
|
+
} catch (error) {
|
|
35638
|
+
const cause = error instanceof Error ? error : void 0;
|
|
35639
|
+
throw new ProvisioningError(`Failed to resolve Arn for DLM Lifecycle Policy ${physicalId}: ${cause?.message ?? String(error)}`, resourceType, physicalId, physicalId, cause);
|
|
35640
|
+
}
|
|
35641
|
+
}
|
|
35642
|
+
/**
|
|
35643
|
+
* Drift read-back. Surfaces `Description`, `State`, `ExecutionRoleArn`,
|
|
35644
|
+
* and `Tags` (DLM tag map -> CFn list via `normalizeAwsTagsToCfn`).
|
|
35645
|
+
*
|
|
35646
|
+
* `PolicyDetails` is intentionally NOT surfaced (see
|
|
35647
|
+
* `getDriftUnknownPaths`): the service normalizes the stored details —
|
|
35648
|
+
* filling `PolicyType` / `ResourceTypes` / per-schedule defaults the
|
|
35649
|
+
* template omitted — and the drift comparator's positional array equality
|
|
35650
|
+
* would flag those AWS-added defaults as phantom drift on every clean run.
|
|
35651
|
+
* The default-policy shorthand fields (`CreateInterval` / `RetainInterval`
|
|
35652
|
+
* / `CopyTags` / `ExtendDeletion` / `CrossRegionCopyTargets` /
|
|
35653
|
+
* `Exclusions`) are folded into the normalized `PolicyDetails` by the
|
|
35654
|
+
* service (GetLifecyclePolicy does not return them at the top level), so
|
|
35655
|
+
* they are excluded for the same reason.
|
|
35656
|
+
*
|
|
35657
|
+
* Returns `undefined` when the policy is gone (ResourceNotFoundException).
|
|
35658
|
+
*/
|
|
35659
|
+
async readCurrentState(physicalId, _logicalId, _resourceType) {
|
|
35660
|
+
try {
|
|
35661
|
+
const policy = (await this.getClient().send(new GetLifecyclePolicyCommand$1({ PolicyId: physicalId }))).Policy;
|
|
35662
|
+
if (!policy) return void 0;
|
|
35663
|
+
return {
|
|
35664
|
+
...policy.Description !== void 0 && { Description: policy.Description },
|
|
35665
|
+
...policy.State !== void 0 && { State: policy.State },
|
|
35666
|
+
...policy.ExecutionRoleArn !== void 0 && { ExecutionRoleArn: policy.ExecutionRoleArn },
|
|
35667
|
+
Tags: normalizeAwsTagsToCfn(policy.Tags)
|
|
35668
|
+
};
|
|
35669
|
+
} catch (error) {
|
|
35670
|
+
if (error instanceof ResourceNotFoundException$12) return;
|
|
35671
|
+
throw error;
|
|
35672
|
+
}
|
|
35673
|
+
}
|
|
35674
|
+
/**
|
|
35675
|
+
* State property paths the provider deliberately does not read back from
|
|
35676
|
+
* AWS — see `readCurrentState` for the rationale.
|
|
35677
|
+
*/
|
|
35678
|
+
getDriftUnknownPaths(_resourceType) {
|
|
35679
|
+
return [
|
|
35680
|
+
"PolicyDetails",
|
|
35681
|
+
"CreateInterval",
|
|
35682
|
+
"RetainInterval",
|
|
35683
|
+
"CopyTags",
|
|
35684
|
+
"ExtendDeletion",
|
|
35685
|
+
"CrossRegionCopyTargets",
|
|
35686
|
+
"Exclusions",
|
|
35687
|
+
"DefaultPolicy"
|
|
35688
|
+
];
|
|
35689
|
+
}
|
|
35690
|
+
/**
|
|
35691
|
+
* Adopt an existing lifecycle policy into cdkd state.
|
|
35692
|
+
*
|
|
35693
|
+
* Lookup order:
|
|
35694
|
+
* 1. `--resource` override (`knownPhysicalId`) -> verify via
|
|
35695
|
+
* GetLifecyclePolicy. There is no template name property — the policy
|
|
35696
|
+
* id is service-generated — so no name fallback applies.
|
|
35697
|
+
* 2. Tag-based lookup: GetLifecyclePolicies returns every policy summary
|
|
35698
|
+
* WITH its tag map in a single unpaginated call, so the `aws:cdk:path`
|
|
35699
|
+
* match needs no per-policy follow-up.
|
|
35700
|
+
*/
|
|
35701
|
+
async import(input) {
|
|
35702
|
+
if (input.knownPhysicalId) try {
|
|
35703
|
+
const response = await this.getClient().send(new GetLifecyclePolicyCommand$1({ PolicyId: input.knownPhysicalId }));
|
|
35704
|
+
return response.Policy?.PolicyId ? {
|
|
35705
|
+
physicalId: input.knownPhysicalId,
|
|
35706
|
+
attributes: { Arn: response.Policy.PolicyArn ?? "" }
|
|
35707
|
+
} : null;
|
|
35708
|
+
} catch (err) {
|
|
35709
|
+
if (err instanceof ResourceNotFoundException$12) return null;
|
|
35710
|
+
throw err;
|
|
35711
|
+
}
|
|
35712
|
+
if (!input.cdkPath) return null;
|
|
35713
|
+
const list = await this.getClient().send(new GetLifecyclePoliciesCommand({}));
|
|
35714
|
+
for (const policy of list.Policies ?? []) {
|
|
35715
|
+
if (!policy.PolicyId) continue;
|
|
35716
|
+
if (policy.Tags?.["aws:cdk:path"] === input.cdkPath) return {
|
|
35717
|
+
physicalId: policy.PolicyId,
|
|
35718
|
+
attributes: {}
|
|
35719
|
+
};
|
|
35720
|
+
}
|
|
35721
|
+
return null;
|
|
35722
|
+
}
|
|
35723
|
+
};
|
|
35724
|
+
|
|
35165
35725
|
//#endregion
|
|
35166
35726
|
//#region src/provisioning/providers/s3-vectors-provider.ts
|
|
35167
35727
|
/**
|
|
@@ -35235,11 +35795,11 @@ var S3VectorsProvider = class {
|
|
|
35235
35795
|
}
|
|
35236
35796
|
if (!resourceArn) throw new ProvisioningError(`Could not resolve ARN for S3 VectorBucket ${logicalId} (${physicalId}); cannot apply tag update.`, resourceType, logicalId, physicalId);
|
|
35237
35797
|
try {
|
|
35238
|
-
if (Object.keys(toSet).length > 0) await this.getClient().send(new TagResourceCommand$
|
|
35798
|
+
if (Object.keys(toSet).length > 0) await this.getClient().send(new TagResourceCommand$17({
|
|
35239
35799
|
resourceArn,
|
|
35240
35800
|
tags: toSet
|
|
35241
35801
|
}));
|
|
35242
|
-
if (toRemove.length > 0) await this.getClient().send(new UntagResourceCommand$
|
|
35802
|
+
if (toRemove.length > 0) await this.getClient().send(new UntagResourceCommand$17({
|
|
35243
35803
|
resourceArn,
|
|
35244
35804
|
tagKeys: toRemove
|
|
35245
35805
|
}));
|
|
@@ -35367,7 +35927,7 @@ var S3VectorsProvider = class {
|
|
|
35367
35927
|
if (Object.keys(enc).length > 0) result["EncryptionConfiguration"] = enc;
|
|
35368
35928
|
}
|
|
35369
35929
|
if (bucket?.vectorBucketArn) try {
|
|
35370
|
-
result["Tags"] = normalizeAwsTagsToCfn((await this.getClient().send(new ListTagsForResourceCommand$
|
|
35930
|
+
result["Tags"] = normalizeAwsTagsToCfn((await this.getClient().send(new ListTagsForResourceCommand$18({ resourceArn: bucket.vectorBucketArn }))).tags);
|
|
35371
35931
|
} catch (err) {
|
|
35372
35932
|
this.logger.debug(`S3Vectors ListTagsForResource(${bucket.vectorBucketArn}) failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
35373
35933
|
result["Tags"] = [];
|
|
@@ -35403,7 +35963,7 @@ var S3VectorsProvider = class {
|
|
|
35403
35963
|
for (const bucket of list.vectorBuckets ?? []) {
|
|
35404
35964
|
if (!bucket.vectorBucketName || !bucket.vectorBucketArn) continue;
|
|
35405
35965
|
try {
|
|
35406
|
-
if ((await this.getClient().send(new ListTagsForResourceCommand$
|
|
35966
|
+
if ((await this.getClient().send(new ListTagsForResourceCommand$18({ resourceArn: bucket.vectorBucketArn }))).tags?.["aws:cdk:path"] === input.cdkPath) return {
|
|
35407
35967
|
physicalId: bucket.vectorBucketName,
|
|
35408
35968
|
attributes: {}
|
|
35409
35969
|
};
|
|
@@ -36013,7 +36573,7 @@ var S3TablesProvider = class {
|
|
|
36013
36573
|
attributes: {}
|
|
36014
36574
|
};
|
|
36015
36575
|
if (input.cdkPath) try {
|
|
36016
|
-
if ((await this.getClient().send(new ListTagsForResourceCommand$
|
|
36576
|
+
if ((await this.getClient().send(new ListTagsForResourceCommand$19({ resourceArn: bucket.arn }))).tags?.["aws:cdk:path"] === input.cdkPath) return {
|
|
36017
36577
|
physicalId: bucket.arn,
|
|
36018
36578
|
attributes: {}
|
|
36019
36579
|
};
|
|
@@ -36080,7 +36640,7 @@ var S3TablesProvider = class {
|
|
|
36080
36640
|
for (const table of tables.tables ?? []) {
|
|
36081
36641
|
if (!table.name || !table.tableARN) continue;
|
|
36082
36642
|
try {
|
|
36083
|
-
if ((await this.getClient().send(new ListTagsForResourceCommand$
|
|
36643
|
+
if ((await this.getClient().send(new ListTagsForResourceCommand$19({ resourceArn: table.tableARN }))).tags?.["aws:cdk:path"] === input.cdkPath) return {
|
|
36084
36644
|
physicalId: `${bucket.arn}|${namespaceName}|${table.name}`,
|
|
36085
36645
|
attributes: {}
|
|
36086
36646
|
};
|
|
@@ -36176,7 +36736,7 @@ var S3TablesProvider = class {
|
|
|
36176
36736
|
*/
|
|
36177
36737
|
async readTagsBestEffort(resourceArn) {
|
|
36178
36738
|
try {
|
|
36179
|
-
const tags = (await this.getClient().send(new ListTagsForResourceCommand$
|
|
36739
|
+
const tags = (await this.getClient().send(new ListTagsForResourceCommand$19({ resourceArn }))).tags ?? {};
|
|
36180
36740
|
const out = [];
|
|
36181
36741
|
for (const [Key, Value] of Object.entries(tags)) out.push({
|
|
36182
36742
|
Key,
|
|
@@ -36230,7 +36790,7 @@ var S3TablesProvider = class {
|
|
|
36230
36790
|
const resourceArn = await this.lookupTableArn(tableBucketARN, namespace, name);
|
|
36231
36791
|
if (!resourceArn) throw new ProvisioningError(`applyTableTagsDiff: GetTable returned no tableARN for ${physicalId} — table is gone or state is out-of-sync. Refusing to silently drop the tag update (run 'cdkd state orphan ${logicalId}' to clean up if the table was deleted out-of-band).`, resourceType, logicalId, physicalId);
|
|
36232
36792
|
if (removedKeys.length > 0) try {
|
|
36233
|
-
await this.getClient().send(new UntagResourceCommand$
|
|
36793
|
+
await this.getClient().send(new UntagResourceCommand$18({
|
|
36234
36794
|
resourceArn,
|
|
36235
36795
|
tagKeys: removedKeys
|
|
36236
36796
|
}));
|
|
@@ -36239,7 +36799,7 @@ var S3TablesProvider = class {
|
|
|
36239
36799
|
throw new ProvisioningError(`applyTableTagsDiff: UntagResource failed for ${resourceArn} (keys: ${removedKeys.join(", ")}): ${err instanceof Error ? err.message : String(err)}. State has NOT been updated so the next deploy will retry the tag-diff.`, resourceType, logicalId, physicalId, cause);
|
|
36240
36800
|
}
|
|
36241
36801
|
if (Object.keys(upserts).length > 0) try {
|
|
36242
|
-
await this.getClient().send(new TagResourceCommand$
|
|
36802
|
+
await this.getClient().send(new TagResourceCommand$18({
|
|
36243
36803
|
resourceArn,
|
|
36244
36804
|
tags: upserts
|
|
36245
36805
|
}));
|
|
@@ -36271,7 +36831,7 @@ var S3TablesProvider = class {
|
|
|
36271
36831
|
if (removedKeys.length === 0 && Object.keys(upserts).length === 0) return;
|
|
36272
36832
|
const resourceArn = physicalId;
|
|
36273
36833
|
if (removedKeys.length > 0) try {
|
|
36274
|
-
await this.getClient().send(new UntagResourceCommand$
|
|
36834
|
+
await this.getClient().send(new UntagResourceCommand$18({
|
|
36275
36835
|
resourceArn,
|
|
36276
36836
|
tagKeys: removedKeys
|
|
36277
36837
|
}));
|
|
@@ -36280,7 +36840,7 @@ var S3TablesProvider = class {
|
|
|
36280
36840
|
throw new ProvisioningError(`applyTableBucketTagsDiff: UntagResource failed for ${resourceArn} (keys: ${removedKeys.join(", ")}): ${err instanceof Error ? err.message : String(err)}. State has NOT been updated so the next deploy will retry the tag-diff.`, resourceType, logicalId, physicalId, cause);
|
|
36281
36841
|
}
|
|
36282
36842
|
if (Object.keys(upserts).length > 0) try {
|
|
36283
|
-
await this.getClient().send(new TagResourceCommand$
|
|
36843
|
+
await this.getClient().send(new TagResourceCommand$18({
|
|
36284
36844
|
resourceArn,
|
|
36285
36845
|
tags: upserts
|
|
36286
36846
|
}));
|
|
@@ -37927,6 +38487,8 @@ function registerAllProviders(registry) {
|
|
|
37927
38487
|
registry.register("AWS::KinesisFirehose::DeliveryStream", new FirehoseProvider());
|
|
37928
38488
|
registry.register("AWS::CloudTrail::Trail", new CloudTrailProvider());
|
|
37929
38489
|
registry.register("AWS::CodeBuild::Project", new CodeBuildProvider());
|
|
38490
|
+
registry.register("AWS::CodeCommit::Repository", new CodeCommitRepositoryProvider());
|
|
38491
|
+
registry.register("AWS::DLM::LifecyclePolicy", new DLMLifecyclePolicyProvider());
|
|
37930
38492
|
registry.register("AWS::S3Vectors::VectorBucket", new S3VectorsProvider());
|
|
37931
38493
|
registry.register("AWS::ECR::Repository", new ECRProvider());
|
|
37932
38494
|
registry.register("AWS::AutoScaling::AutoScalingGroup", new ASGProvider());
|
|
@@ -57199,7 +57761,7 @@ function reorderArgs(argv) {
|
|
|
57199
57761
|
async function main() {
|
|
57200
57762
|
installPipeCloseHandler();
|
|
57201
57763
|
const program = new Command();
|
|
57202
|
-
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.
|
|
57764
|
+
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.240.0");
|
|
57203
57765
|
program.addCommand(createBootstrapCommand());
|
|
57204
57766
|
program.addCommand(createSynthCommand());
|
|
57205
57767
|
program.addCommand(createListCommand());
|