cdk-real-drift 0.2.59 → 0.2.61
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 +217 -158
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1572,7 +1572,8 @@ const KNOWN_DEFAULTS = {
|
|
|
1572
1572
|
"AWS::RDS::DBProxy": {
|
|
1573
1573
|
TargetConnectionNetworkType: "IPV4",
|
|
1574
1574
|
DefaultAuthScheme: "NONE",
|
|
1575
|
-
EndpointNetworkType: "IPV4"
|
|
1575
|
+
EndpointNetworkType: "IPV4",
|
|
1576
|
+
IdleClientTimeout: 1800
|
|
1576
1577
|
},
|
|
1577
1578
|
"AWS::RDS::DBInstance": {
|
|
1578
1579
|
AutoMinorVersionUpgrade: true,
|
|
@@ -1594,7 +1595,8 @@ const KNOWN_DEFAULTS = {
|
|
|
1594
1595
|
AutoMinorVersionUpgrade: true,
|
|
1595
1596
|
DatabaseInsightsMode: "standard",
|
|
1596
1597
|
NetworkType: "IPV4",
|
|
1597
|
-
EngineMode: "provisioned"
|
|
1598
|
+
EngineMode: "provisioned",
|
|
1599
|
+
BackupRetentionPeriod: 1
|
|
1598
1600
|
},
|
|
1599
1601
|
"AWS::Neptune::DBInstance": { AutoMinorVersionUpgrade: true },
|
|
1600
1602
|
"AWS::Neptune::DBCluster": {
|
|
@@ -3250,7 +3252,10 @@ function parseCfnTemplate(text) {
|
|
|
3250
3252
|
const body = text.charCodeAt(0) === 65279 ? text.slice(1) : text;
|
|
3251
3253
|
let parsed;
|
|
3252
3254
|
if (format === "json") parsed = JSON.parse(body);
|
|
3253
|
-
else parsed = parse(body, {
|
|
3255
|
+
else parsed = parse(body, {
|
|
3256
|
+
version: "1.1",
|
|
3257
|
+
customTags: CUSTOM_TAGS
|
|
3258
|
+
});
|
|
3254
3259
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("Template root is not an object.");
|
|
3255
3260
|
return parsed;
|
|
3256
3261
|
}
|
|
@@ -8346,152 +8351,6 @@ const SDK_SUPPLEMENTS = {
|
|
|
8346
8351
|
"AWS::RedshiftServerless::Workgroup": supplementRedshiftServerlessWorkgroup
|
|
8347
8352
|
};
|
|
8348
8353
|
|
|
8349
|
-
//#endregion
|
|
8350
|
-
//#region src/read/router.ts
|
|
8351
|
-
const CC_IDENTIFIER_ADAPTERS = {
|
|
8352
|
-
"AWS::AppSync::GraphQLApi": (pid) => pid.startsWith("arn:") ? pid.split("/").pop() : pid,
|
|
8353
|
-
"AWS::Batch::JobDefinition": (pid) => {
|
|
8354
|
-
return (pid.startsWith("arn:") ? pid.split("/").pop() ?? pid : pid).replace(/:\d+$/, "");
|
|
8355
|
-
},
|
|
8356
|
-
"AWS::ECR::RepositoryCreationTemplate": (pid) => pid.replace(/\/$/, ""),
|
|
8357
|
-
"AWS::Cognito::UserPoolClient": compositeWith("UserPoolId"),
|
|
8358
|
-
"AWS::Cognito::UserPoolGroup": compositeWith("UserPoolId"),
|
|
8359
|
-
"AWS::Cognito::UserPoolIdentityProvider": compositeWith("UserPoolId"),
|
|
8360
|
-
"AWS::Cognito::UserPoolUser": compositeWith("UserPoolId"),
|
|
8361
|
-
"AWS::ApiGatewayV2::Stage": compositeWith("ApiId"),
|
|
8362
|
-
"AWS::ApiGatewayV2::Route": compositeWith("ApiId"),
|
|
8363
|
-
"AWS::ApiGatewayV2::Integration": compositeWith("ApiId"),
|
|
8364
|
-
"AWS::ApiGatewayV2::Authorizer": (pid, declared) => {
|
|
8365
|
-
if (pid.includes("|")) return pid;
|
|
8366
|
-
const apiId = declared.ApiId;
|
|
8367
|
-
return typeof apiId === "string" && apiId.length > 0 ? `${pid}|${apiId}` : void 0;
|
|
8368
|
-
},
|
|
8369
|
-
"AWS::AppConfig::Environment": compositeWith("ApplicationId"),
|
|
8370
|
-
"AWS::AppConfig::ConfigurationProfile": compositeWith("ApplicationId"),
|
|
8371
|
-
"AWS::AppConfig::HostedConfigurationVersion": (pid, declared) => {
|
|
8372
|
-
if (pid.includes("|")) return pid;
|
|
8373
|
-
const appId = declared.ApplicationId;
|
|
8374
|
-
const profileId = declared.ConfigurationProfileId;
|
|
8375
|
-
return typeof appId === "string" && appId.length > 0 && typeof profileId === "string" && profileId.length > 0 ? `${appId}|${profileId}|${pid}` : void 0;
|
|
8376
|
-
},
|
|
8377
|
-
"AWS::AppConfig::Deployment": (pid, declared) => {
|
|
8378
|
-
if (pid.includes("|")) return pid;
|
|
8379
|
-
const appId = declared.ApplicationId;
|
|
8380
|
-
const envId = declared.EnvironmentId;
|
|
8381
|
-
return typeof appId === "string" && appId.length > 0 && typeof envId === "string" && envId.length > 0 ? `${appId}|${envId}|${pid}` : void 0;
|
|
8382
|
-
},
|
|
8383
|
-
"AWS::ApiGateway::Model": compositeWith("RestApiId"),
|
|
8384
|
-
"AWS::ApiGateway::RequestValidator": compositeWith("RestApiId"),
|
|
8385
|
-
"AWS::ApiGateway::Resource": compositeWith("RestApiId"),
|
|
8386
|
-
"AWS::ApiGateway::Stage": compositeWith("RestApiId"),
|
|
8387
|
-
"AWS::ApiGateway::Authorizer": compositeWith("RestApiId"),
|
|
8388
|
-
"AWS::Cognito::UserPoolDomain": compositeWith("UserPoolId"),
|
|
8389
|
-
"AWS::Cognito::UserPoolResourceServer": compositeWith("UserPoolId"),
|
|
8390
|
-
"AWS::AutoScaling::LifecycleHook": compositeWith("AutoScalingGroupName"),
|
|
8391
|
-
"AWS::CodeDeploy::DeploymentGroup": compositeWith("ApplicationName"),
|
|
8392
|
-
"AWS::ElasticBeanstalk::ConfigurationTemplate": compositeWith("ApplicationName"),
|
|
8393
|
-
"AWS::ElasticBeanstalk::ApplicationVersion": compositeWith("ApplicationName"),
|
|
8394
|
-
"AWS::AutoScaling::ScheduledAction": (pid, declared) => {
|
|
8395
|
-
if (pid.includes("|")) return pid;
|
|
8396
|
-
const asg = declared.AutoScalingGroupName;
|
|
8397
|
-
return typeof asg === "string" && asg.length > 0 ? `${pid}|${asg}` : void 0;
|
|
8398
|
-
},
|
|
8399
|
-
"AWS::ApiGateway::Deployment": (pid, declared) => {
|
|
8400
|
-
if (pid.includes("|")) return pid;
|
|
8401
|
-
const restApiId = declared.RestApiId;
|
|
8402
|
-
return typeof restApiId === "string" && restApiId.length > 0 ? `${pid}|${restApiId}` : void 0;
|
|
8403
|
-
},
|
|
8404
|
-
"AWS::ApiGateway::DocumentationPart": (pid, declared) => {
|
|
8405
|
-
if (pid.includes("|")) return pid;
|
|
8406
|
-
const restApiId = declared.RestApiId;
|
|
8407
|
-
return typeof restApiId === "string" && restApiId.length > 0 ? `${pid}|${restApiId}` : void 0;
|
|
8408
|
-
},
|
|
8409
|
-
"AWS::ApplicationAutoScaling::ScalingPolicy": scalingPolicyComposite,
|
|
8410
|
-
"AWS::ECS::Service": (pid, declared) => {
|
|
8411
|
-
if (pid.includes("|")) return pid;
|
|
8412
|
-
const cluster = declared.Cluster;
|
|
8413
|
-
return typeof cluster === "string" && cluster.length > 0 ? `${pid}|${cluster}` : void 0;
|
|
8414
|
-
},
|
|
8415
|
-
"AWS::Logs::SubscriptionFilter": (pid, declared) => {
|
|
8416
|
-
if (pid.includes("|")) return pid;
|
|
8417
|
-
const lg = declared.LogGroupName;
|
|
8418
|
-
return typeof lg === "string" && lg.length > 0 ? `${pid}|${lg}` : void 0;
|
|
8419
|
-
},
|
|
8420
|
-
"AWS::Logs::LogStream": compositeWith("LogGroupName"),
|
|
8421
|
-
"AWS::SSM::MaintenanceWindowTarget": compositeWith("WindowId"),
|
|
8422
|
-
"AWS::SSM::MaintenanceWindowTask": compositeWith("WindowId"),
|
|
8423
|
-
"AWS::EC2::TransitGatewayRouteTablePropagation": (pid, declared) => {
|
|
8424
|
-
if (pid.includes("|")) return pid;
|
|
8425
|
-
const rtb = declared.TransitGatewayRouteTableId;
|
|
8426
|
-
const att = declared.TransitGatewayAttachmentId;
|
|
8427
|
-
return typeof rtb === "string" && rtb.length > 0 && typeof att === "string" && att.length > 0 ? `${rtb}|${att}` : void 0;
|
|
8428
|
-
},
|
|
8429
|
-
"AWS::EC2::VPCCidrBlock": (pid, declared) => {
|
|
8430
|
-
if (pid.includes("|")) return pid;
|
|
8431
|
-
const vpcId = declared.VpcId;
|
|
8432
|
-
return typeof vpcId === "string" && vpcId.length > 0 ? `${pid}|${vpcId}` : void 0;
|
|
8433
|
-
},
|
|
8434
|
-
"AWS::ApiGatewayV2::RouteResponse": (pid, declared) => {
|
|
8435
|
-
if (pid.includes("|")) return pid;
|
|
8436
|
-
const apiId = declared.ApiId;
|
|
8437
|
-
const routeId = declared.RouteId;
|
|
8438
|
-
return typeof apiId === "string" && apiId.length > 0 && typeof routeId === "string" && routeId.length > 0 ? `${apiId}|${routeId}|${pid}` : void 0;
|
|
8439
|
-
}
|
|
8440
|
-
};
|
|
8441
|
-
function scalingPolicyComposite(pid, declared) {
|
|
8442
|
-
if (pid.includes("|")) return pid;
|
|
8443
|
-
const targetId = declared.ScalingTargetId;
|
|
8444
|
-
if (typeof targetId !== "string") return void 0;
|
|
8445
|
-
const dimension = targetId.split("|")[1];
|
|
8446
|
-
return dimension ? `${pid}|${dimension}` : void 0;
|
|
8447
|
-
}
|
|
8448
|
-
function compositeWith(parentKey) {
|
|
8449
|
-
return (pid, declared) => {
|
|
8450
|
-
if (pid.includes("|")) return pid;
|
|
8451
|
-
const parent = declared[parentKey];
|
|
8452
|
-
return typeof parent === "string" && parent.length > 0 ? `${parent}|${pid}` : void 0;
|
|
8453
|
-
};
|
|
8454
|
-
}
|
|
8455
|
-
async function readLive(cc, resource, region, accountId) {
|
|
8456
|
-
const { resourceType, physicalId, declared } = resource;
|
|
8457
|
-
if (resourceType.startsWith("Custom::") || resourceType === "AWS::CloudFormation::CustomResource") return { skippedReason: "custom resource — no cloud-side model to read" };
|
|
8458
|
-
const override = SDK_OVERRIDES[resourceType];
|
|
8459
|
-
if (override) try {
|
|
8460
|
-
const live = await override({
|
|
8461
|
-
physicalId: physicalId ?? "",
|
|
8462
|
-
declared,
|
|
8463
|
-
region,
|
|
8464
|
-
accountId
|
|
8465
|
-
});
|
|
8466
|
-
return live ? { live } : { skippedReason: "SDK override: target not resolvable from template" };
|
|
8467
|
-
} catch (e) {
|
|
8468
|
-
if (isResourceNotFoundError(e)) return { deleted: true };
|
|
8469
|
-
return { skippedReason: `SDK override (${resourceType}): ${e.name}` };
|
|
8470
|
-
}
|
|
8471
|
-
try {
|
|
8472
|
-
const identifier = CC_IDENTIFIER_ADAPTERS[resourceType]?.(physicalId ?? "", declared) ?? physicalId ?? "";
|
|
8473
|
-
const g = await cc.send(new GetResourceCommand({
|
|
8474
|
-
TypeName: resourceType,
|
|
8475
|
-
Identifier: identifier
|
|
8476
|
-
}));
|
|
8477
|
-
const live = JSON.parse(g.ResourceDescription?.Properties ?? "{}");
|
|
8478
|
-
const supplement = SDK_SUPPLEMENTS[resourceType];
|
|
8479
|
-
if (supplement) try {
|
|
8480
|
-
const extra = await supplement({
|
|
8481
|
-
physicalId: physicalId ?? "",
|
|
8482
|
-
declared,
|
|
8483
|
-
region,
|
|
8484
|
-
accountId
|
|
8485
|
-
});
|
|
8486
|
-
if (extra) Object.assign(live, extra);
|
|
8487
|
-
} catch {}
|
|
8488
|
-
return { live };
|
|
8489
|
-
} catch (e) {
|
|
8490
|
-
if (isResourceNotFoundError(e)) return { deleted: true };
|
|
8491
|
-
return { skippedReason: `CC API: ${e.name}` };
|
|
8492
|
-
}
|
|
8493
|
-
}
|
|
8494
|
-
|
|
8495
8354
|
//#endregion
|
|
8496
8355
|
//#region src/schema/schema-strip.ts
|
|
8497
8356
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -8711,6 +8570,165 @@ function parseSchema(schemaJson) {
|
|
|
8711
8570
|
};
|
|
8712
8571
|
}
|
|
8713
8572
|
|
|
8573
|
+
//#endregion
|
|
8574
|
+
//#region src/read/router.ts
|
|
8575
|
+
const CC_IDENTIFIER_ADAPTERS = {
|
|
8576
|
+
"AWS::AppSync::GraphQLApi": (pid) => pid.startsWith("arn:") ? pid.split("/").pop() : pid,
|
|
8577
|
+
"AWS::Batch::JobDefinition": (pid) => {
|
|
8578
|
+
return (pid.startsWith("arn:") ? pid.split("/").pop() ?? pid : pid).replace(/:\d+$/, "");
|
|
8579
|
+
},
|
|
8580
|
+
"AWS::ECR::RepositoryCreationTemplate": (pid) => pid.replace(/\/$/, ""),
|
|
8581
|
+
"AWS::Cognito::UserPoolClient": compositeWith("UserPoolId"),
|
|
8582
|
+
"AWS::Cognito::UserPoolGroup": compositeWith("UserPoolId"),
|
|
8583
|
+
"AWS::Cognito::UserPoolIdentityProvider": compositeWith("UserPoolId"),
|
|
8584
|
+
"AWS::Cognito::UserPoolUser": compositeWith("UserPoolId"),
|
|
8585
|
+
"AWS::ApiGatewayV2::Stage": compositeWith("ApiId"),
|
|
8586
|
+
"AWS::ApiGatewayV2::Route": compositeWith("ApiId"),
|
|
8587
|
+
"AWS::ApiGatewayV2::Integration": compositeWith("ApiId"),
|
|
8588
|
+
"AWS::ApiGatewayV2::Authorizer": (pid, declared) => {
|
|
8589
|
+
if (pid.includes("|")) return pid;
|
|
8590
|
+
const apiId = declared.ApiId;
|
|
8591
|
+
return typeof apiId === "string" && apiId.length > 0 ? `${pid}|${apiId}` : void 0;
|
|
8592
|
+
},
|
|
8593
|
+
"AWS::AppConfig::Environment": compositeWith("ApplicationId"),
|
|
8594
|
+
"AWS::AppConfig::ConfigurationProfile": compositeWith("ApplicationId"),
|
|
8595
|
+
"AWS::AppConfig::HostedConfigurationVersion": (pid, declared) => {
|
|
8596
|
+
if (pid.includes("|")) return pid;
|
|
8597
|
+
const appId = declared.ApplicationId;
|
|
8598
|
+
const profileId = declared.ConfigurationProfileId;
|
|
8599
|
+
return typeof appId === "string" && appId.length > 0 && typeof profileId === "string" && profileId.length > 0 ? `${appId}|${profileId}|${pid}` : void 0;
|
|
8600
|
+
},
|
|
8601
|
+
"AWS::AppConfig::Deployment": (pid, declared) => {
|
|
8602
|
+
if (pid.includes("|")) return pid;
|
|
8603
|
+
const appId = declared.ApplicationId;
|
|
8604
|
+
const envId = declared.EnvironmentId;
|
|
8605
|
+
return typeof appId === "string" && appId.length > 0 && typeof envId === "string" && envId.length > 0 ? `${appId}|${envId}|${pid}` : void 0;
|
|
8606
|
+
},
|
|
8607
|
+
"AWS::ApiGateway::Model": compositeWith("RestApiId"),
|
|
8608
|
+
"AWS::ApiGateway::RequestValidator": compositeWith("RestApiId"),
|
|
8609
|
+
"AWS::ApiGateway::Resource": compositeWith("RestApiId"),
|
|
8610
|
+
"AWS::ApiGateway::Stage": compositeWith("RestApiId"),
|
|
8611
|
+
"AWS::ApiGateway::Authorizer": compositeWith("RestApiId"),
|
|
8612
|
+
"AWS::Cognito::UserPoolDomain": compositeWith("UserPoolId"),
|
|
8613
|
+
"AWS::Cognito::UserPoolResourceServer": compositeWith("UserPoolId"),
|
|
8614
|
+
"AWS::AutoScaling::LifecycleHook": compositeWith("AutoScalingGroupName"),
|
|
8615
|
+
"AWS::CodeDeploy::DeploymentGroup": compositeWith("ApplicationName"),
|
|
8616
|
+
"AWS::ElasticBeanstalk::ConfigurationTemplate": compositeWith("ApplicationName"),
|
|
8617
|
+
"AWS::ElasticBeanstalk::ApplicationVersion": compositeWith("ApplicationName"),
|
|
8618
|
+
"AWS::AutoScaling::ScheduledAction": (pid, declared) => {
|
|
8619
|
+
if (pid.includes("|")) return pid;
|
|
8620
|
+
const asg = declared.AutoScalingGroupName;
|
|
8621
|
+
return typeof asg === "string" && asg.length > 0 ? `${pid}|${asg}` : void 0;
|
|
8622
|
+
},
|
|
8623
|
+
"AWS::ApiGateway::Deployment": (pid, declared) => {
|
|
8624
|
+
if (pid.includes("|")) return pid;
|
|
8625
|
+
const restApiId = declared.RestApiId;
|
|
8626
|
+
return typeof restApiId === "string" && restApiId.length > 0 ? `${pid}|${restApiId}` : void 0;
|
|
8627
|
+
},
|
|
8628
|
+
"AWS::ApiGateway::DocumentationPart": (pid, declared) => {
|
|
8629
|
+
if (pid.includes("|")) return pid;
|
|
8630
|
+
const restApiId = declared.RestApiId;
|
|
8631
|
+
return typeof restApiId === "string" && restApiId.length > 0 ? `${pid}|${restApiId}` : void 0;
|
|
8632
|
+
},
|
|
8633
|
+
"AWS::ApplicationAutoScaling::ScalingPolicy": scalingPolicyComposite,
|
|
8634
|
+
"AWS::ECS::Service": (pid, declared) => {
|
|
8635
|
+
if (pid.includes("|")) return pid;
|
|
8636
|
+
const cluster = declared.Cluster;
|
|
8637
|
+
return typeof cluster === "string" && cluster.length > 0 ? `${pid}|${cluster}` : void 0;
|
|
8638
|
+
},
|
|
8639
|
+
"AWS::Logs::SubscriptionFilter": (pid, declared) => {
|
|
8640
|
+
if (pid.includes("|")) return pid;
|
|
8641
|
+
const lg = declared.LogGroupName;
|
|
8642
|
+
return typeof lg === "string" && lg.length > 0 ? `${pid}|${lg}` : void 0;
|
|
8643
|
+
},
|
|
8644
|
+
"AWS::Logs::LogStream": compositeWith("LogGroupName"),
|
|
8645
|
+
"AWS::SSM::MaintenanceWindowTarget": compositeWith("WindowId"),
|
|
8646
|
+
"AWS::SSM::MaintenanceWindowTask": compositeWith("WindowId"),
|
|
8647
|
+
"AWS::EC2::TransitGatewayRouteTablePropagation": (pid, declared) => {
|
|
8648
|
+
if (pid.includes("|")) return pid;
|
|
8649
|
+
const rtb = declared.TransitGatewayRouteTableId;
|
|
8650
|
+
const att = declared.TransitGatewayAttachmentId;
|
|
8651
|
+
return typeof rtb === "string" && rtb.length > 0 && typeof att === "string" && att.length > 0 ? `${rtb}|${att}` : void 0;
|
|
8652
|
+
},
|
|
8653
|
+
"AWS::EC2::VPCCidrBlock": (pid, declared) => {
|
|
8654
|
+
if (pid.includes("|")) return pid;
|
|
8655
|
+
const vpcId = declared.VpcId;
|
|
8656
|
+
return typeof vpcId === "string" && vpcId.length > 0 ? `${pid}|${vpcId}` : void 0;
|
|
8657
|
+
},
|
|
8658
|
+
"AWS::ApiGatewayV2::RouteResponse": (pid, declared) => {
|
|
8659
|
+
if (pid.includes("|")) return pid;
|
|
8660
|
+
const apiId = declared.ApiId;
|
|
8661
|
+
const routeId = declared.RouteId;
|
|
8662
|
+
return typeof apiId === "string" && apiId.length > 0 && typeof routeId === "string" && routeId.length > 0 ? `${apiId}|${routeId}|${pid}` : void 0;
|
|
8663
|
+
}
|
|
8664
|
+
};
|
|
8665
|
+
function scalingPolicyComposite(pid, declared) {
|
|
8666
|
+
if (pid.includes("|")) return pid;
|
|
8667
|
+
const targetId = declared.ScalingTargetId;
|
|
8668
|
+
if (typeof targetId !== "string") return void 0;
|
|
8669
|
+
const dimension = targetId.split("|")[1];
|
|
8670
|
+
return dimension ? `${pid}|${dimension}` : void 0;
|
|
8671
|
+
}
|
|
8672
|
+
function compositeWith(parentKey) {
|
|
8673
|
+
return (pid, declared) => {
|
|
8674
|
+
if (pid.includes("|")) return pid;
|
|
8675
|
+
const parent = declared[parentKey];
|
|
8676
|
+
return typeof parent === "string" && parent.length > 0 ? `${parent}|${pid}` : void 0;
|
|
8677
|
+
};
|
|
8678
|
+
}
|
|
8679
|
+
function restoreSupplementReadGaps(resourceType, declared, live, error) {
|
|
8680
|
+
const exempt = OVERRIDE_READABLE_WRITEONLY[resourceType];
|
|
8681
|
+
const restored = [];
|
|
8682
|
+
for (const path of exempt ?? []) if (path in declared && !(path in live)) {
|
|
8683
|
+
live[path] = declared[path];
|
|
8684
|
+
restored.push(path);
|
|
8685
|
+
}
|
|
8686
|
+
const call = error?.name || "unknown error";
|
|
8687
|
+
const gap = restored.length ? ` — treating ${restored.join(", ")} as an unverifiable read-gap (declared value assumed unchanged; grant the missing read permission to detect out-of-band drift on it)` : "";
|
|
8688
|
+
process.stderr.write(`[cdkrd] warning: supplement read for ${resourceType} failed (${call})${gap}\n`);
|
|
8689
|
+
}
|
|
8690
|
+
async function readLive(cc, resource, region, accountId) {
|
|
8691
|
+
const { resourceType, physicalId, declared } = resource;
|
|
8692
|
+
if (resourceType.startsWith("Custom::") || resourceType === "AWS::CloudFormation::CustomResource") return { skippedReason: "custom resource — no cloud-side model to read" };
|
|
8693
|
+
const override = SDK_OVERRIDES[resourceType];
|
|
8694
|
+
if (override) try {
|
|
8695
|
+
const live = await override({
|
|
8696
|
+
physicalId: physicalId ?? "",
|
|
8697
|
+
declared,
|
|
8698
|
+
region,
|
|
8699
|
+
accountId
|
|
8700
|
+
});
|
|
8701
|
+
return live ? { live } : { skippedReason: "SDK override: target not resolvable from template" };
|
|
8702
|
+
} catch (e) {
|
|
8703
|
+
if (isResourceNotFoundError(e)) return { deleted: true };
|
|
8704
|
+
return { skippedReason: `SDK override (${resourceType}): ${e.name}` };
|
|
8705
|
+
}
|
|
8706
|
+
try {
|
|
8707
|
+
const identifier = CC_IDENTIFIER_ADAPTERS[resourceType]?.(physicalId ?? "", declared) ?? physicalId ?? "";
|
|
8708
|
+
const g = await cc.send(new GetResourceCommand({
|
|
8709
|
+
TypeName: resourceType,
|
|
8710
|
+
Identifier: identifier
|
|
8711
|
+
}));
|
|
8712
|
+
const live = JSON.parse(g.ResourceDescription?.Properties ?? "{}");
|
|
8713
|
+
const supplement = SDK_SUPPLEMENTS[resourceType];
|
|
8714
|
+
if (supplement) try {
|
|
8715
|
+
const extra = await supplement({
|
|
8716
|
+
physicalId: physicalId ?? "",
|
|
8717
|
+
declared,
|
|
8718
|
+
region,
|
|
8719
|
+
accountId
|
|
8720
|
+
});
|
|
8721
|
+
if (extra) Object.assign(live, extra);
|
|
8722
|
+
} catch (e) {
|
|
8723
|
+
restoreSupplementReadGaps(resourceType, declared, live, e);
|
|
8724
|
+
}
|
|
8725
|
+
return { live };
|
|
8726
|
+
} catch (e) {
|
|
8727
|
+
if (isResourceNotFoundError(e)) return { deleted: true };
|
|
8728
|
+
return { skippedReason: `CC API: ${e.name}` };
|
|
8729
|
+
}
|
|
8730
|
+
}
|
|
8731
|
+
|
|
8714
8732
|
//#endregion
|
|
8715
8733
|
//#region src/commands/gather.ts
|
|
8716
8734
|
function liveModelMap(reads) {
|
|
@@ -9189,9 +9207,14 @@ async function writeBaselineFile(b) {
|
|
|
9189
9207
|
/**
|
|
9190
9208
|
* Which resources the record snapshot covered COMPLETELY (R62): every undeclared
|
|
9191
9209
|
* finding of the resource is in `recorded` (zero undeclared findings = trivially
|
|
9192
|
-
* complete), and the resource was actually observed — a `skipped` (unread)
|
|
9193
|
-
* `deleted`
|
|
9194
|
-
*
|
|
9210
|
+
* complete), and the resource was actually observed — a `skipped` (unread),
|
|
9211
|
+
* `deleted`, or `readGap` (part of its live model UNREAD) resource cannot be
|
|
9212
|
+
* snapshot. A `readGap` finding means some of the resource's live state could not
|
|
9213
|
+
* be read this run (#795), so undeclared values hidden behind that gap were NOT
|
|
9214
|
+
* captured — the resource must not claim completeness, else a later cdkrd that
|
|
9215
|
+
* closes the read gap would surface those newly-visible values as false "appeared
|
|
9216
|
+
* since record" drift. Ignored-tier values do not block completeness: they were
|
|
9217
|
+
* visible and deliberately ruled out.
|
|
9195
9218
|
* Monotonic via `previousComplete`: once complete, a resource stays complete
|
|
9196
9219
|
* (declining to record an appeared-since-record value keeps it drift, instead of
|
|
9197
9220
|
* demoting it back to unrecorded) — pruned to ids still in the template.
|
|
@@ -9200,7 +9223,7 @@ function computeCompleteResources(allLogicalIds, findings, recorded, previousCom
|
|
|
9200
9223
|
const recordedKeys = new Set(recorded.map(recordedKey));
|
|
9201
9224
|
const blocked = /* @__PURE__ */ new Set();
|
|
9202
9225
|
for (const f of findings) {
|
|
9203
|
-
if (f.tier === "skipped" || f.tier === "deleted") blocked.add(f.logicalId);
|
|
9226
|
+
if (f.tier === "skipped" || f.tier === "deleted" || f.tier === "readGap") blocked.add(f.logicalId);
|
|
9204
9227
|
if (f.tier === "undeclared" && !recordedKeys.has(recordedKey(f))) blocked.add(f.logicalId);
|
|
9205
9228
|
}
|
|
9206
9229
|
const all = new Set(allLogicalIds);
|
|
@@ -11847,6 +11870,31 @@ async function applyRevertItem(cc, item, identifier = item.physicalId, retry = {
|
|
|
11847
11870
|
}
|
|
11848
11871
|
}, retry);
|
|
11849
11872
|
}
|
|
11873
|
+
async function applyRevertDeletes(deleteItems, applyOne) {
|
|
11874
|
+
const results = /* @__PURE__ */ new Map();
|
|
11875
|
+
let pending = deleteItems.map((item, index) => ({
|
|
11876
|
+
item,
|
|
11877
|
+
index
|
|
11878
|
+
}));
|
|
11879
|
+
const maxPasses = Math.max(1, deleteItems.length);
|
|
11880
|
+
for (let pass = 0; pass < maxPasses && pending.length > 0; pass++) {
|
|
11881
|
+
const stillFailed = [];
|
|
11882
|
+
for (const p of pending) {
|
|
11883
|
+
const r = await applyOne(p.item);
|
|
11884
|
+
results.set(p.index, r);
|
|
11885
|
+
if (!r.ok) stillFailed.push(p);
|
|
11886
|
+
}
|
|
11887
|
+
if (stillFailed.length === pending.length) break;
|
|
11888
|
+
pending = stillFailed;
|
|
11889
|
+
}
|
|
11890
|
+
return deleteItems.map((item, index) => ({
|
|
11891
|
+
item,
|
|
11892
|
+
result: results.get(index) ?? {
|
|
11893
|
+
ok: false,
|
|
11894
|
+
error: "delete not attempted"
|
|
11895
|
+
}
|
|
11896
|
+
}));
|
|
11897
|
+
}
|
|
11850
11898
|
async function applyRevertDelete(cc, item, identifier = item.physicalId, retry = {}) {
|
|
11851
11899
|
return retryTransient(async () => {
|
|
11852
11900
|
try {
|
|
@@ -12367,12 +12415,11 @@ async function revertStack(p) {
|
|
|
12367
12415
|
console.log(style.note(` ↻ ${displayId}: ${reason} — retry ${attempt} (next in ${secs}s)…`));
|
|
12368
12416
|
}
|
|
12369
12417
|
});
|
|
12418
|
+
const deleteItems = plan.items.filter((i) => i.kind === "delete");
|
|
12370
12419
|
for (const item of plan.items) {
|
|
12420
|
+
if (item.kind === "delete") continue;
|
|
12371
12421
|
let r;
|
|
12372
|
-
if (item.kind === "
|
|
12373
|
-
r = await applyRevertDelete(cc, item, item.physicalId, buildRetryOpts(item.displayId));
|
|
12374
|
-
if (!r.ok) failedDeleteIds.add(item.logicalId);
|
|
12375
|
-
} else if (item.kind === "sdk") {
|
|
12422
|
+
if (item.kind === "sdk") {
|
|
12376
12423
|
const res = byLogical.get(item.logicalId);
|
|
12377
12424
|
r = await retryTransient(async () => {
|
|
12378
12425
|
try {
|
|
@@ -12419,7 +12466,19 @@ async function revertStack(p) {
|
|
|
12419
12466
|
...r.hint !== void 0 && { hint: r.hint }
|
|
12420
12467
|
});
|
|
12421
12468
|
if (!r.ok) worst = Math.max(worst, 2);
|
|
12422
|
-
if (!r.ok
|
|
12469
|
+
if (!r.ok) failedUpdateIds.add(item.logicalId);
|
|
12470
|
+
}
|
|
12471
|
+
const deleteOutcomes = await applyRevertDeletes(deleteItems, (item) => applyRevertDelete(cc, item, item.physicalId, buildRetryOpts(item.displayId)));
|
|
12472
|
+
for (const { item, result: r } of deleteOutcomes) {
|
|
12473
|
+
if (!r.ok) failedDeleteIds.add(item.logicalId);
|
|
12474
|
+
applied.push({
|
|
12475
|
+
logicalId: item.logicalId,
|
|
12476
|
+
displayId: item.displayId,
|
|
12477
|
+
ok: r.ok,
|
|
12478
|
+
...r.error !== void 0 && { error: r.error },
|
|
12479
|
+
...r.hint !== void 0 && { hint: r.hint }
|
|
12480
|
+
});
|
|
12481
|
+
if (!r.ok) worst = Math.max(worst, 2);
|
|
12423
12482
|
}
|
|
12424
12483
|
for (const s of summarizeRevertResults(applied)) if (s.ok) console.log(style.ok(` reverted: ${s.displayId}`));
|
|
12425
12484
|
else {
|