@go-to-k/cdkd 0.91.0 → 0.91.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +307 -263
- package/dist/cli.js.map +3 -3
- package/dist/go-to-k-cdkd-0.91.2.tgz +0 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/go-to-k-cdkd-0.91.0.tgz +0 -0
package/dist/cli.js
CHANGED
|
@@ -21504,6 +21504,28 @@ var TemplateParser = class {
|
|
|
21504
21504
|
}
|
|
21505
21505
|
return;
|
|
21506
21506
|
}
|
|
21507
|
+
if ("Fn::Join" in obj) {
|
|
21508
|
+
const joinValue = obj["Fn::Join"];
|
|
21509
|
+
if (Array.isArray(joinValue) && joinValue.length >= 2) {
|
|
21510
|
+
this.extractRefsFromValue(joinValue[1], dependencies);
|
|
21511
|
+
}
|
|
21512
|
+
return;
|
|
21513
|
+
}
|
|
21514
|
+
if ("Fn::Select" in obj) {
|
|
21515
|
+
const selectValue = obj["Fn::Select"];
|
|
21516
|
+
if (Array.isArray(selectValue) && selectValue.length >= 2) {
|
|
21517
|
+
this.extractRefsFromValue(selectValue[0], dependencies);
|
|
21518
|
+
this.extractRefsFromValue(selectValue[1], dependencies);
|
|
21519
|
+
}
|
|
21520
|
+
return;
|
|
21521
|
+
}
|
|
21522
|
+
if ("Fn::Split" in obj) {
|
|
21523
|
+
const splitValue = obj["Fn::Split"];
|
|
21524
|
+
if (Array.isArray(splitValue) && splitValue.length >= 2) {
|
|
21525
|
+
this.extractRefsFromValue(splitValue[1], dependencies);
|
|
21526
|
+
}
|
|
21527
|
+
return;
|
|
21528
|
+
}
|
|
21507
21529
|
Object.values(obj).forEach((v) => this.extractRefsFromValue(v, dependencies));
|
|
21508
21530
|
}
|
|
21509
21531
|
/**
|
|
@@ -70146,6 +70168,268 @@ async function loadStateForStack(stackName, synthRegion, opts) {
|
|
|
70146
70168
|
// src/local/lambda-resolver.ts
|
|
70147
70169
|
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
70148
70170
|
import { dirname, isAbsolute, resolve as resolve4 } from "node:path";
|
|
70171
|
+
|
|
70172
|
+
// src/local/intrinsic-image.ts
|
|
70173
|
+
function tryResolveImageFnJoin(raw, resources, context) {
|
|
70174
|
+
if (!raw || typeof raw !== "object")
|
|
70175
|
+
return { kind: "not-applicable" };
|
|
70176
|
+
const obj = raw;
|
|
70177
|
+
const arg = obj["Fn::Join"];
|
|
70178
|
+
if (arg === void 0)
|
|
70179
|
+
return { kind: "not-applicable" };
|
|
70180
|
+
if (!Array.isArray(arg) || arg.length !== 2 || !Array.isArray(arg[1])) {
|
|
70181
|
+
return { kind: "unsupported-join", reason: "Fn::Join must be [delimiter, [elements]]" };
|
|
70182
|
+
}
|
|
70183
|
+
const [delimiter, elements] = arg;
|
|
70184
|
+
if (typeof delimiter !== "string") {
|
|
70185
|
+
return {
|
|
70186
|
+
kind: "unsupported-join",
|
|
70187
|
+
reason: `Fn::Join delimiter must be a string, got ${typeof delimiter}`
|
|
70188
|
+
};
|
|
70189
|
+
}
|
|
70190
|
+
const repoLogicalId = findEcrRepositoryRefInTree(elements, resources);
|
|
70191
|
+
const stateResources = context?.stateResources;
|
|
70192
|
+
if (repoLogicalId && !stateResources) {
|
|
70193
|
+
return { kind: "needs-state", repoLogicalId };
|
|
70194
|
+
}
|
|
70195
|
+
const parts = [];
|
|
70196
|
+
for (const element of elements) {
|
|
70197
|
+
const r = resolveImageIntrinsic(element, resources, context);
|
|
70198
|
+
if (r === void 0) {
|
|
70199
|
+
if (!repoLogicalId)
|
|
70200
|
+
return { kind: "not-applicable" };
|
|
70201
|
+
return {
|
|
70202
|
+
kind: "unsupported-join",
|
|
70203
|
+
reason: "one or more Fn::Join elements could not be resolved"
|
|
70204
|
+
};
|
|
70205
|
+
}
|
|
70206
|
+
parts.push(r);
|
|
70207
|
+
}
|
|
70208
|
+
return { kind: "resolved", uri: parts.join(delimiter) };
|
|
70209
|
+
}
|
|
70210
|
+
function findEcrRepositoryRefInTree(node, resources) {
|
|
70211
|
+
if (node === null || node === void 0)
|
|
70212
|
+
return void 0;
|
|
70213
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "boolean") {
|
|
70214
|
+
return void 0;
|
|
70215
|
+
}
|
|
70216
|
+
if (Array.isArray(node)) {
|
|
70217
|
+
for (const item of node) {
|
|
70218
|
+
const hit = findEcrRepositoryRefInTree(item, resources);
|
|
70219
|
+
if (hit)
|
|
70220
|
+
return hit;
|
|
70221
|
+
}
|
|
70222
|
+
return void 0;
|
|
70223
|
+
}
|
|
70224
|
+
if (typeof node !== "object")
|
|
70225
|
+
return void 0;
|
|
70226
|
+
const obj = node;
|
|
70227
|
+
if (typeof obj["Ref"] === "string") {
|
|
70228
|
+
const target = obj["Ref"];
|
|
70229
|
+
if (resources[target]?.Type === "AWS::ECR::Repository")
|
|
70230
|
+
return target;
|
|
70231
|
+
return void 0;
|
|
70232
|
+
}
|
|
70233
|
+
const getAtt = obj["Fn::GetAtt"];
|
|
70234
|
+
if (getAtt !== void 0) {
|
|
70235
|
+
let lid;
|
|
70236
|
+
if (Array.isArray(getAtt) && typeof getAtt[0] === "string")
|
|
70237
|
+
lid = getAtt[0];
|
|
70238
|
+
else if (typeof getAtt === "string")
|
|
70239
|
+
lid = getAtt.split(".")[0];
|
|
70240
|
+
if (lid && resources[lid]?.Type === "AWS::ECR::Repository")
|
|
70241
|
+
return lid;
|
|
70242
|
+
return void 0;
|
|
70243
|
+
}
|
|
70244
|
+
for (const value of Object.values(obj)) {
|
|
70245
|
+
const hit = findEcrRepositoryRefInTree(value, resources);
|
|
70246
|
+
if (hit)
|
|
70247
|
+
return hit;
|
|
70248
|
+
}
|
|
70249
|
+
return void 0;
|
|
70250
|
+
}
|
|
70251
|
+
function resolveImageIntrinsic(node, resources, context) {
|
|
70252
|
+
const v = resolveImageIntrinsicAny(node, resources, context);
|
|
70253
|
+
if (typeof v === "string")
|
|
70254
|
+
return v;
|
|
70255
|
+
if (typeof v === "number" || typeof v === "boolean")
|
|
70256
|
+
return String(v);
|
|
70257
|
+
return void 0;
|
|
70258
|
+
}
|
|
70259
|
+
function resolveImageIntrinsicAny(node, resources, context) {
|
|
70260
|
+
if (node === null || node === void 0)
|
|
70261
|
+
return void 0;
|
|
70262
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "boolean") {
|
|
70263
|
+
return node;
|
|
70264
|
+
}
|
|
70265
|
+
if (Array.isArray(node)) {
|
|
70266
|
+
return void 0;
|
|
70267
|
+
}
|
|
70268
|
+
if (typeof node !== "object")
|
|
70269
|
+
return void 0;
|
|
70270
|
+
const obj = node;
|
|
70271
|
+
const keys = Object.keys(obj);
|
|
70272
|
+
if (keys.length !== 1)
|
|
70273
|
+
return void 0;
|
|
70274
|
+
const intrinsic = keys[0];
|
|
70275
|
+
const arg = obj[intrinsic];
|
|
70276
|
+
if (intrinsic === "Ref") {
|
|
70277
|
+
if (typeof arg !== "string")
|
|
70278
|
+
return void 0;
|
|
70279
|
+
if (arg.startsWith("AWS::")) {
|
|
70280
|
+
const p = context?.pseudoParameters;
|
|
70281
|
+
if (!p)
|
|
70282
|
+
return void 0;
|
|
70283
|
+
if (arg === "AWS::URLSuffix")
|
|
70284
|
+
return p.urlSuffix;
|
|
70285
|
+
if (arg === "AWS::Partition")
|
|
70286
|
+
return p.partition;
|
|
70287
|
+
if (arg === "AWS::Region")
|
|
70288
|
+
return p.region;
|
|
70289
|
+
if (arg === "AWS::AccountId")
|
|
70290
|
+
return p.accountId;
|
|
70291
|
+
return void 0;
|
|
70292
|
+
}
|
|
70293
|
+
const refResource = resources[arg];
|
|
70294
|
+
if (refResource?.Type !== "AWS::ECR::Repository")
|
|
70295
|
+
return void 0;
|
|
70296
|
+
const stateEntry = context?.stateResources?.[arg];
|
|
70297
|
+
if (!stateEntry)
|
|
70298
|
+
return void 0;
|
|
70299
|
+
return stateEntry.physicalId;
|
|
70300
|
+
}
|
|
70301
|
+
if (intrinsic === "Fn::GetAtt") {
|
|
70302
|
+
let logicalId;
|
|
70303
|
+
let attr;
|
|
70304
|
+
if (Array.isArray(arg) && arg.length === 2 && typeof arg[0] === "string" && typeof arg[1] === "string") {
|
|
70305
|
+
logicalId = arg[0];
|
|
70306
|
+
attr = arg[1];
|
|
70307
|
+
} else if (typeof arg === "string") {
|
|
70308
|
+
const dot = arg.indexOf(".");
|
|
70309
|
+
if (dot > 0 && dot < arg.length - 1) {
|
|
70310
|
+
logicalId = arg.slice(0, dot);
|
|
70311
|
+
attr = arg.slice(dot + 1);
|
|
70312
|
+
}
|
|
70313
|
+
}
|
|
70314
|
+
if (!logicalId || !attr)
|
|
70315
|
+
return void 0;
|
|
70316
|
+
if (resources[logicalId]?.Type !== "AWS::ECR::Repository")
|
|
70317
|
+
return void 0;
|
|
70318
|
+
const cached = context?.stateResources?.[logicalId]?.attributes?.[attr];
|
|
70319
|
+
if (typeof cached === "string" && cached.length > 0)
|
|
70320
|
+
return cached;
|
|
70321
|
+
return void 0;
|
|
70322
|
+
}
|
|
70323
|
+
if (intrinsic === "Fn::Split") {
|
|
70324
|
+
if (!Array.isArray(arg) || arg.length !== 2)
|
|
70325
|
+
return void 0;
|
|
70326
|
+
const argArr = arg;
|
|
70327
|
+
const delim = argArr[0];
|
|
70328
|
+
if (typeof delim !== "string")
|
|
70329
|
+
return void 0;
|
|
70330
|
+
const src = resolveImageIntrinsicAny(argArr[1], resources, context);
|
|
70331
|
+
if (typeof src !== "string")
|
|
70332
|
+
return void 0;
|
|
70333
|
+
return src.split(delim);
|
|
70334
|
+
}
|
|
70335
|
+
if (intrinsic === "Fn::Select") {
|
|
70336
|
+
if (!Array.isArray(arg) || arg.length !== 2)
|
|
70337
|
+
return void 0;
|
|
70338
|
+
const argArr = arg;
|
|
70339
|
+
const rawIndex = argArr[0];
|
|
70340
|
+
let index;
|
|
70341
|
+
if (typeof rawIndex === "number") {
|
|
70342
|
+
index = rawIndex;
|
|
70343
|
+
} else if (typeof rawIndex === "string" && /^-?\d+$/.test(rawIndex)) {
|
|
70344
|
+
index = Number.parseInt(rawIndex, 10);
|
|
70345
|
+
}
|
|
70346
|
+
if (index === void 0 || !Number.isFinite(index))
|
|
70347
|
+
return void 0;
|
|
70348
|
+
const list = resolveImageIntrinsicAny(argArr[1], resources, context);
|
|
70349
|
+
if (Array.isArray(list)) {
|
|
70350
|
+
if (index < 0 || index >= list.length)
|
|
70351
|
+
return void 0;
|
|
70352
|
+
const picked = list[index];
|
|
70353
|
+
if (typeof picked === "string")
|
|
70354
|
+
return picked;
|
|
70355
|
+
return void 0;
|
|
70356
|
+
}
|
|
70357
|
+
if (Array.isArray(argArr[1])) {
|
|
70358
|
+
const listLiteral = argArr[1];
|
|
70359
|
+
if (index < 0 || index >= listLiteral.length)
|
|
70360
|
+
return void 0;
|
|
70361
|
+
return resolveImageIntrinsic(listLiteral[index], resources, context);
|
|
70362
|
+
}
|
|
70363
|
+
return void 0;
|
|
70364
|
+
}
|
|
70365
|
+
if (intrinsic === "Fn::Join") {
|
|
70366
|
+
if (!Array.isArray(arg) || arg.length !== 2)
|
|
70367
|
+
return void 0;
|
|
70368
|
+
const [delim, parts] = arg;
|
|
70369
|
+
if (typeof delim !== "string" || !Array.isArray(parts))
|
|
70370
|
+
return void 0;
|
|
70371
|
+
const resolved = [];
|
|
70372
|
+
for (const part of parts) {
|
|
70373
|
+
const r = resolveImageIntrinsic(part, resources, context);
|
|
70374
|
+
if (r === void 0)
|
|
70375
|
+
return void 0;
|
|
70376
|
+
resolved.push(r);
|
|
70377
|
+
}
|
|
70378
|
+
return resolved.join(delim);
|
|
70379
|
+
}
|
|
70380
|
+
if (intrinsic === "Fn::Sub") {
|
|
70381
|
+
let template;
|
|
70382
|
+
if (typeof arg === "string")
|
|
70383
|
+
template = arg;
|
|
70384
|
+
else if (Array.isArray(arg) && typeof arg[0] === "string")
|
|
70385
|
+
template = arg[0];
|
|
70386
|
+
if (template === void 0)
|
|
70387
|
+
return void 0;
|
|
70388
|
+
const out = substituteImagePlaceholders(template, resources, context);
|
|
70389
|
+
if (out.includes("${"))
|
|
70390
|
+
return void 0;
|
|
70391
|
+
return out;
|
|
70392
|
+
}
|
|
70393
|
+
return void 0;
|
|
70394
|
+
}
|
|
70395
|
+
function substituteImagePlaceholders(flat, resources, context) {
|
|
70396
|
+
if (!flat.includes("${"))
|
|
70397
|
+
return flat;
|
|
70398
|
+
return flat.replace(/\$\{([^}]+)\}/g, (full, key) => {
|
|
70399
|
+
if (context?.pseudoParameters) {
|
|
70400
|
+
if (key === "AWS::AccountId" && context.pseudoParameters.accountId) {
|
|
70401
|
+
return context.pseudoParameters.accountId;
|
|
70402
|
+
}
|
|
70403
|
+
if (key === "AWS::Region" && context.pseudoParameters.region) {
|
|
70404
|
+
return context.pseudoParameters.region;
|
|
70405
|
+
}
|
|
70406
|
+
if (key === "AWS::Partition" && context.pseudoParameters.partition) {
|
|
70407
|
+
return context.pseudoParameters.partition;
|
|
70408
|
+
}
|
|
70409
|
+
if (key === "AWS::URLSuffix" && context.pseudoParameters.urlSuffix) {
|
|
70410
|
+
return context.pseudoParameters.urlSuffix;
|
|
70411
|
+
}
|
|
70412
|
+
}
|
|
70413
|
+
if (context?.stateResources) {
|
|
70414
|
+
const dot = key.indexOf(".");
|
|
70415
|
+
const logicalId = dot === -1 ? key : key.slice(0, dot);
|
|
70416
|
+
const refResource = resources[logicalId];
|
|
70417
|
+
const stateEntry = context.stateResources[logicalId];
|
|
70418
|
+
if (refResource?.Type === "AWS::ECR::Repository" && stateEntry) {
|
|
70419
|
+
if (dot === -1) {
|
|
70420
|
+
return stateEntry.physicalId;
|
|
70421
|
+
}
|
|
70422
|
+
const attr = key.slice(dot + 1);
|
|
70423
|
+
const cached = stateEntry.attributes?.[attr];
|
|
70424
|
+
if (typeof cached === "string")
|
|
70425
|
+
return cached;
|
|
70426
|
+
}
|
|
70427
|
+
}
|
|
70428
|
+
return full;
|
|
70429
|
+
});
|
|
70430
|
+
}
|
|
70431
|
+
|
|
70432
|
+
// src/local/lambda-resolver.ts
|
|
70149
70433
|
var LocalInvokeResolutionError = class _LocalInvokeResolutionError extends Error {
|
|
70150
70434
|
constructor(message) {
|
|
70151
70435
|
super(message);
|
|
@@ -70217,7 +70501,7 @@ function resolveLambdaTarget(target, stacks) {
|
|
|
70217
70501
|
`Resource '${logicalId}' in ${stack.stackName} is ${resource.Type}, not a Lambda function. cdkd local invoke only works on AWS::Lambda::Function resources in v1.`
|
|
70218
70502
|
);
|
|
70219
70503
|
}
|
|
70220
|
-
return extractLambdaProperties(stack, logicalId, resource);
|
|
70504
|
+
return extractLambdaProperties(stack, logicalId, resource, resources);
|
|
70221
70505
|
}
|
|
70222
70506
|
function pickStack(parsed, stacks) {
|
|
70223
70507
|
if (parsed.stackPattern === null) {
|
|
@@ -70240,12 +70524,12 @@ function pickStack(parsed, stacks) {
|
|
|
70240
70524
|
}
|
|
70241
70525
|
return matched[0];
|
|
70242
70526
|
}
|
|
70243
|
-
function extractLambdaProperties(stack, logicalId, resource) {
|
|
70527
|
+
function extractLambdaProperties(stack, logicalId, resource, resources) {
|
|
70244
70528
|
const props = resource.Properties ?? {};
|
|
70245
70529
|
const memoryMb = typeof props["MemorySize"] === "number" ? props["MemorySize"] : 128;
|
|
70246
70530
|
const timeoutSec = typeof props["Timeout"] === "number" ? props["Timeout"] : 3;
|
|
70247
70531
|
const code = props["Code"] ?? {};
|
|
70248
|
-
const imageUri = extractImageUri(code["ImageUri"]);
|
|
70532
|
+
const imageUri = extractImageUri(code["ImageUri"], logicalId, stack.stackName, resources);
|
|
70249
70533
|
if (imageUri !== void 0) {
|
|
70250
70534
|
return extractImageLambdaProperties({
|
|
70251
70535
|
stack,
|
|
@@ -70287,7 +70571,7 @@ function extractLambdaProperties(stack, logicalId, resource) {
|
|
|
70287
70571
|
...inlineCode !== void 0 && { inlineCode }
|
|
70288
70572
|
};
|
|
70289
70573
|
}
|
|
70290
|
-
function extractImageUri(value) {
|
|
70574
|
+
function extractImageUri(value, logicalId, stackName, resources) {
|
|
70291
70575
|
if (typeof value === "string" && value.length > 0)
|
|
70292
70576
|
return value;
|
|
70293
70577
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -70297,6 +70581,24 @@ function extractImageUri(value) {
|
|
|
70297
70581
|
return sub;
|
|
70298
70582
|
if (Array.isArray(sub) && typeof sub[0] === "string")
|
|
70299
70583
|
return sub[0];
|
|
70584
|
+
if ("Fn::Join" in obj) {
|
|
70585
|
+
const joinResolved = tryResolveImageFnJoin(value, resources, void 0);
|
|
70586
|
+
if (joinResolved.kind === "resolved")
|
|
70587
|
+
return joinResolved.uri;
|
|
70588
|
+
if (joinResolved.kind === "needs-state") {
|
|
70589
|
+
throw new LocalInvokeResolutionError(
|
|
70590
|
+
`Lambda '${logicalId}' in ${stackName} references same-stack ECR repository '${joinResolved.repoLogicalId}' via Fn::Join. cdkd local invoke cannot resolve the repository URI without state \u2014 deploy the stack first (so cdkd records the repository physical id), rebuild via lambda.DockerImageCode.fromImageAsset, or pin a public image.`
|
|
70591
|
+
);
|
|
70592
|
+
}
|
|
70593
|
+
if (joinResolved.kind === "unsupported-join") {
|
|
70594
|
+
throw new LocalInvokeResolutionError(
|
|
70595
|
+
`Lambda '${logicalId}' in ${stackName} has an unsupported Fn::Join Code.ImageUri shape: ${joinResolved.reason}. cdkd local invoke recognizes the canonical CDK 2.x lambda.DockerImageCode.fromEcr Fn::Join shape (delimiter "" with nested Fn::Select/Fn::Split over an ECR Repository Arn GetAtt + Ref to the repo).`
|
|
70596
|
+
);
|
|
70597
|
+
}
|
|
70598
|
+
throw new LocalInvokeResolutionError(
|
|
70599
|
+
`Lambda '${logicalId}' in ${stackName} has an Fn::Join Code.ImageUri that cdkd local invoke cannot resolve. The shape likely references AWS pseudo parameters (e.g. \${AWS::URLSuffix}) for an imported ECR repository. Workarounds: rebuild via lambda.DockerImageCode.fromImageAsset, or pin a fully-literal public image URI.`
|
|
70600
|
+
);
|
|
70601
|
+
}
|
|
70300
70602
|
}
|
|
70301
70603
|
return void 0;
|
|
70302
70604
|
}
|
|
@@ -77268,42 +77570,6 @@ function classifyResolvedImage(uri) {
|
|
|
77268
77570
|
}
|
|
77269
77571
|
return { kind: "public", uri };
|
|
77270
77572
|
}
|
|
77271
|
-
function substituteImagePlaceholders(flat, resources, context) {
|
|
77272
|
-
if (!flat.includes("${"))
|
|
77273
|
-
return flat;
|
|
77274
|
-
return flat.replace(/\$\{([^}]+)\}/g, (full, key) => {
|
|
77275
|
-
if (context?.pseudoParameters) {
|
|
77276
|
-
if (key === "AWS::AccountId" && context.pseudoParameters.accountId) {
|
|
77277
|
-
return context.pseudoParameters.accountId;
|
|
77278
|
-
}
|
|
77279
|
-
if (key === "AWS::Region" && context.pseudoParameters.region) {
|
|
77280
|
-
return context.pseudoParameters.region;
|
|
77281
|
-
}
|
|
77282
|
-
if (key === "AWS::Partition" && context.pseudoParameters.partition) {
|
|
77283
|
-
return context.pseudoParameters.partition;
|
|
77284
|
-
}
|
|
77285
|
-
if (key === "AWS::URLSuffix" && context.pseudoParameters.urlSuffix) {
|
|
77286
|
-
return context.pseudoParameters.urlSuffix;
|
|
77287
|
-
}
|
|
77288
|
-
}
|
|
77289
|
-
if (context?.stateResources) {
|
|
77290
|
-
const dot = key.indexOf(".");
|
|
77291
|
-
const logicalId = dot === -1 ? key : key.slice(0, dot);
|
|
77292
|
-
const refResource = resources[logicalId];
|
|
77293
|
-
const stateEntry = context.stateResources[logicalId];
|
|
77294
|
-
if (refResource?.Type === "AWS::ECR::Repository" && stateEntry) {
|
|
77295
|
-
if (dot === -1) {
|
|
77296
|
-
return stateEntry.physicalId;
|
|
77297
|
-
}
|
|
77298
|
-
const attr = key.slice(dot + 1);
|
|
77299
|
-
const cached = stateEntry.attributes?.[attr];
|
|
77300
|
-
if (typeof cached === "string")
|
|
77301
|
-
return cached;
|
|
77302
|
-
}
|
|
77303
|
-
}
|
|
77304
|
-
return full;
|
|
77305
|
-
});
|
|
77306
|
-
}
|
|
77307
77573
|
function tryResolveImageGetAtt(raw, resources, context) {
|
|
77308
77574
|
if (!raw || typeof raw !== "object")
|
|
77309
77575
|
return void 0;
|
|
@@ -77355,228 +77621,6 @@ function extractImageString(value) {
|
|
|
77355
77621
|
}
|
|
77356
77622
|
return void 0;
|
|
77357
77623
|
}
|
|
77358
|
-
function tryResolveImageFnJoin(raw, resources, context) {
|
|
77359
|
-
if (!raw || typeof raw !== "object")
|
|
77360
|
-
return { kind: "not-applicable" };
|
|
77361
|
-
const obj = raw;
|
|
77362
|
-
const arg = obj["Fn::Join"];
|
|
77363
|
-
if (arg === void 0)
|
|
77364
|
-
return { kind: "not-applicable" };
|
|
77365
|
-
if (!Array.isArray(arg) || arg.length !== 2 || !Array.isArray(arg[1])) {
|
|
77366
|
-
return { kind: "unsupported-join", reason: "Fn::Join must be [delimiter, [elements]]" };
|
|
77367
|
-
}
|
|
77368
|
-
const [delimiter, elements] = arg;
|
|
77369
|
-
if (typeof delimiter !== "string") {
|
|
77370
|
-
return {
|
|
77371
|
-
kind: "unsupported-join",
|
|
77372
|
-
reason: `Fn::Join delimiter must be a string, got ${typeof delimiter}`
|
|
77373
|
-
};
|
|
77374
|
-
}
|
|
77375
|
-
const repoLogicalId = findEcrRepositoryRefInTree(elements, resources);
|
|
77376
|
-
const stateResources = context?.stateResources;
|
|
77377
|
-
if (repoLogicalId && !stateResources) {
|
|
77378
|
-
return { kind: "needs-state", repoLogicalId };
|
|
77379
|
-
}
|
|
77380
|
-
const parts = [];
|
|
77381
|
-
for (const element of elements) {
|
|
77382
|
-
const r = resolveImageIntrinsic(element, resources, context);
|
|
77383
|
-
if (r === void 0) {
|
|
77384
|
-
if (!repoLogicalId)
|
|
77385
|
-
return { kind: "not-applicable" };
|
|
77386
|
-
return {
|
|
77387
|
-
kind: "unsupported-join",
|
|
77388
|
-
reason: "one or more Fn::Join elements could not be resolved"
|
|
77389
|
-
};
|
|
77390
|
-
}
|
|
77391
|
-
parts.push(r);
|
|
77392
|
-
}
|
|
77393
|
-
return { kind: "resolved", uri: parts.join(delimiter) };
|
|
77394
|
-
}
|
|
77395
|
-
function findEcrRepositoryRefInTree(node, resources) {
|
|
77396
|
-
if (node === null || node === void 0)
|
|
77397
|
-
return void 0;
|
|
77398
|
-
if (typeof node === "string" || typeof node === "number" || typeof node === "boolean") {
|
|
77399
|
-
return void 0;
|
|
77400
|
-
}
|
|
77401
|
-
if (Array.isArray(node)) {
|
|
77402
|
-
for (const item of node) {
|
|
77403
|
-
const hit = findEcrRepositoryRefInTree(item, resources);
|
|
77404
|
-
if (hit)
|
|
77405
|
-
return hit;
|
|
77406
|
-
}
|
|
77407
|
-
return void 0;
|
|
77408
|
-
}
|
|
77409
|
-
if (typeof node !== "object")
|
|
77410
|
-
return void 0;
|
|
77411
|
-
const obj = node;
|
|
77412
|
-
if (typeof obj["Ref"] === "string") {
|
|
77413
|
-
const target = obj["Ref"];
|
|
77414
|
-
if (resources[target]?.Type === "AWS::ECR::Repository")
|
|
77415
|
-
return target;
|
|
77416
|
-
return void 0;
|
|
77417
|
-
}
|
|
77418
|
-
const getAtt = obj["Fn::GetAtt"];
|
|
77419
|
-
if (getAtt !== void 0) {
|
|
77420
|
-
let lid;
|
|
77421
|
-
if (Array.isArray(getAtt) && typeof getAtt[0] === "string")
|
|
77422
|
-
lid = getAtt[0];
|
|
77423
|
-
else if (typeof getAtt === "string")
|
|
77424
|
-
lid = getAtt.split(".")[0];
|
|
77425
|
-
if (lid && resources[lid]?.Type === "AWS::ECR::Repository")
|
|
77426
|
-
return lid;
|
|
77427
|
-
return void 0;
|
|
77428
|
-
}
|
|
77429
|
-
for (const value of Object.values(obj)) {
|
|
77430
|
-
const hit = findEcrRepositoryRefInTree(value, resources);
|
|
77431
|
-
if (hit)
|
|
77432
|
-
return hit;
|
|
77433
|
-
}
|
|
77434
|
-
return void 0;
|
|
77435
|
-
}
|
|
77436
|
-
function resolveImageIntrinsic(node, resources, context) {
|
|
77437
|
-
const v = resolveImageIntrinsicAny(node, resources, context);
|
|
77438
|
-
if (typeof v === "string")
|
|
77439
|
-
return v;
|
|
77440
|
-
if (typeof v === "number" || typeof v === "boolean")
|
|
77441
|
-
return String(v);
|
|
77442
|
-
return void 0;
|
|
77443
|
-
}
|
|
77444
|
-
function resolveImageIntrinsicAny(node, resources, context) {
|
|
77445
|
-
if (node === null || node === void 0)
|
|
77446
|
-
return void 0;
|
|
77447
|
-
if (typeof node === "string" || typeof node === "number" || typeof node === "boolean") {
|
|
77448
|
-
return node;
|
|
77449
|
-
}
|
|
77450
|
-
if (Array.isArray(node)) {
|
|
77451
|
-
return void 0;
|
|
77452
|
-
}
|
|
77453
|
-
if (typeof node !== "object")
|
|
77454
|
-
return void 0;
|
|
77455
|
-
const obj = node;
|
|
77456
|
-
const keys = Object.keys(obj);
|
|
77457
|
-
if (keys.length !== 1)
|
|
77458
|
-
return void 0;
|
|
77459
|
-
const intrinsic = keys[0];
|
|
77460
|
-
const arg = obj[intrinsic];
|
|
77461
|
-
if (intrinsic === "Ref") {
|
|
77462
|
-
if (typeof arg !== "string")
|
|
77463
|
-
return void 0;
|
|
77464
|
-
if (arg.startsWith("AWS::")) {
|
|
77465
|
-
const p = context?.pseudoParameters;
|
|
77466
|
-
if (!p)
|
|
77467
|
-
return void 0;
|
|
77468
|
-
if (arg === "AWS::URLSuffix")
|
|
77469
|
-
return p.urlSuffix;
|
|
77470
|
-
if (arg === "AWS::Partition")
|
|
77471
|
-
return p.partition;
|
|
77472
|
-
if (arg === "AWS::Region")
|
|
77473
|
-
return p.region;
|
|
77474
|
-
if (arg === "AWS::AccountId")
|
|
77475
|
-
return p.accountId;
|
|
77476
|
-
return void 0;
|
|
77477
|
-
}
|
|
77478
|
-
const refResource = resources[arg];
|
|
77479
|
-
if (refResource?.Type !== "AWS::ECR::Repository")
|
|
77480
|
-
return void 0;
|
|
77481
|
-
const stateEntry = context?.stateResources?.[arg];
|
|
77482
|
-
if (!stateEntry)
|
|
77483
|
-
return void 0;
|
|
77484
|
-
return stateEntry.physicalId;
|
|
77485
|
-
}
|
|
77486
|
-
if (intrinsic === "Fn::GetAtt") {
|
|
77487
|
-
let logicalId;
|
|
77488
|
-
let attr;
|
|
77489
|
-
if (Array.isArray(arg) && arg.length === 2 && typeof arg[0] === "string" && typeof arg[1] === "string") {
|
|
77490
|
-
logicalId = arg[0];
|
|
77491
|
-
attr = arg[1];
|
|
77492
|
-
} else if (typeof arg === "string") {
|
|
77493
|
-
const dot = arg.indexOf(".");
|
|
77494
|
-
if (dot > 0 && dot < arg.length - 1) {
|
|
77495
|
-
logicalId = arg.slice(0, dot);
|
|
77496
|
-
attr = arg.slice(dot + 1);
|
|
77497
|
-
}
|
|
77498
|
-
}
|
|
77499
|
-
if (!logicalId || !attr)
|
|
77500
|
-
return void 0;
|
|
77501
|
-
if (resources[logicalId]?.Type !== "AWS::ECR::Repository")
|
|
77502
|
-
return void 0;
|
|
77503
|
-
const cached = context?.stateResources?.[logicalId]?.attributes?.[attr];
|
|
77504
|
-
if (typeof cached === "string" && cached.length > 0)
|
|
77505
|
-
return cached;
|
|
77506
|
-
return void 0;
|
|
77507
|
-
}
|
|
77508
|
-
if (intrinsic === "Fn::Split") {
|
|
77509
|
-
if (!Array.isArray(arg) || arg.length !== 2)
|
|
77510
|
-
return void 0;
|
|
77511
|
-
const argArr = arg;
|
|
77512
|
-
const delim = argArr[0];
|
|
77513
|
-
if (typeof delim !== "string")
|
|
77514
|
-
return void 0;
|
|
77515
|
-
const src = resolveImageIntrinsicAny(argArr[1], resources, context);
|
|
77516
|
-
if (typeof src !== "string")
|
|
77517
|
-
return void 0;
|
|
77518
|
-
return src.split(delim);
|
|
77519
|
-
}
|
|
77520
|
-
if (intrinsic === "Fn::Select") {
|
|
77521
|
-
if (!Array.isArray(arg) || arg.length !== 2)
|
|
77522
|
-
return void 0;
|
|
77523
|
-
const argArr = arg;
|
|
77524
|
-
const rawIndex = argArr[0];
|
|
77525
|
-
let index;
|
|
77526
|
-
if (typeof rawIndex === "number") {
|
|
77527
|
-
index = rawIndex;
|
|
77528
|
-
} else if (typeof rawIndex === "string" && /^-?\d+$/.test(rawIndex)) {
|
|
77529
|
-
index = Number.parseInt(rawIndex, 10);
|
|
77530
|
-
}
|
|
77531
|
-
if (index === void 0 || !Number.isFinite(index))
|
|
77532
|
-
return void 0;
|
|
77533
|
-
const list = resolveImageIntrinsicAny(argArr[1], resources, context);
|
|
77534
|
-
if (Array.isArray(list)) {
|
|
77535
|
-
if (index < 0 || index >= list.length)
|
|
77536
|
-
return void 0;
|
|
77537
|
-
const picked = list[index];
|
|
77538
|
-
if (typeof picked === "string")
|
|
77539
|
-
return picked;
|
|
77540
|
-
return void 0;
|
|
77541
|
-
}
|
|
77542
|
-
if (Array.isArray(argArr[1])) {
|
|
77543
|
-
const listLiteral = argArr[1];
|
|
77544
|
-
if (index < 0 || index >= listLiteral.length)
|
|
77545
|
-
return void 0;
|
|
77546
|
-
return resolveImageIntrinsic(listLiteral[index], resources, context);
|
|
77547
|
-
}
|
|
77548
|
-
return void 0;
|
|
77549
|
-
}
|
|
77550
|
-
if (intrinsic === "Fn::Join") {
|
|
77551
|
-
if (!Array.isArray(arg) || arg.length !== 2)
|
|
77552
|
-
return void 0;
|
|
77553
|
-
const [delim, parts] = arg;
|
|
77554
|
-
if (typeof delim !== "string" || !Array.isArray(parts))
|
|
77555
|
-
return void 0;
|
|
77556
|
-
const resolved = [];
|
|
77557
|
-
for (const part of parts) {
|
|
77558
|
-
const r = resolveImageIntrinsic(part, resources, context);
|
|
77559
|
-
if (r === void 0)
|
|
77560
|
-
return void 0;
|
|
77561
|
-
resolved.push(r);
|
|
77562
|
-
}
|
|
77563
|
-
return resolved.join(delim);
|
|
77564
|
-
}
|
|
77565
|
-
if (intrinsic === "Fn::Sub") {
|
|
77566
|
-
let template;
|
|
77567
|
-
if (typeof arg === "string")
|
|
77568
|
-
template = arg;
|
|
77569
|
-
else if (Array.isArray(arg) && typeof arg[0] === "string")
|
|
77570
|
-
template = arg[0];
|
|
77571
|
-
if (template === void 0)
|
|
77572
|
-
return void 0;
|
|
77573
|
-
const out = substituteImagePlaceholders(template, resources, context);
|
|
77574
|
-
if (out.includes("${"))
|
|
77575
|
-
return void 0;
|
|
77576
|
-
return out;
|
|
77577
|
-
}
|
|
77578
|
-
return void 0;
|
|
77579
|
-
}
|
|
77580
77624
|
function parseVolume(raw, idx, taskLogicalId) {
|
|
77581
77625
|
if (!raw || typeof raw !== "object") {
|
|
77582
77626
|
throw new EcsTaskResolutionError(`Task '${taskLogicalId}' Volumes[${idx}] is not an object.`);
|
|
@@ -80264,7 +80308,7 @@ function reorderArgs(argv) {
|
|
|
80264
80308
|
}
|
|
80265
80309
|
async function main() {
|
|
80266
80310
|
const program = new Command18();
|
|
80267
|
-
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.91.
|
|
80311
|
+
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.91.2");
|
|
80268
80312
|
program.addCommand(createBootstrapCommand());
|
|
80269
80313
|
program.addCommand(createSynthCommand());
|
|
80270
80314
|
program.addCommand(createListCommand());
|