cdk-real-drift 0.3.7 → 0.3.9
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/README.md +1 -1
- package/dist/cli.js +67 -24
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -300,7 +300,7 @@ Full design and rationale: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
|
|
|
300
300
|
| --------------------- | ------------------------------------------------------------- |
|
|
301
301
|
| `cdkrd check` | every stack the CDK app defines, each in its own `env.region` |
|
|
302
302
|
| `cdkrd check 'Dev*'` | glob, matched against the app's stack names |
|
|
303
|
-
| `cdkrd check MyStack` |
|
|
303
|
+
| `cdkrd check MyStack` | every same-named stack (a name can repeat across regions) |
|
|
304
304
|
|
|
305
305
|
cdkrd resolves your CDK app to discover which stacks exist and to label findings by
|
|
306
306
|
construct path. The app comes from `cdk.json` (when run in the project directory) or
|
package/dist/cli.js
CHANGED
|
@@ -873,6 +873,20 @@ function missingContextWarning(keys, opts = {}) {
|
|
|
873
873
|
//#endregion
|
|
874
874
|
//#region src/synth/synth.ts
|
|
875
875
|
const CONCRETE_REGION = /^[a-z]{2}(-[a-z]+)+-\d+$/;
|
|
876
|
+
/**
|
|
877
|
+
* Build the stderr message body (no `warning:` prefix — the caller adds it) for the case where
|
|
878
|
+
* `--app` points at a pre-synthesized cloud-assembly DIRECTORY (`cdk.out`) yet the user also
|
|
879
|
+
* passed `-c/--context`. There is no CDK app subprocess to feed context to — the assembly's
|
|
880
|
+
* templates were frozen at synth time — so the `-c` values are silently dropped. Returns `null`
|
|
881
|
+
* when it does NOT apply (a real CDK app command, or no context given), so the caller warns only
|
|
882
|
+
* on the ignored case (#956). Advisory only (a warning, not a refusal): the frozen assembly is
|
|
883
|
+
* still a valid drift source, the user is just misled into thinking their `-c` mattered.
|
|
884
|
+
*/
|
|
885
|
+
function contextIgnoredWarning(isDir, context) {
|
|
886
|
+
const keys = Object.keys(context);
|
|
887
|
+
if (!isDir || keys.length === 0) return null;
|
|
888
|
+
return `ignoring -c/--context (${keys.join(", ")}): --app points at a pre-synthesized cloud-assembly directory, whose context was baked in at synth time — there is no CDK app to re-run with new context. To apply new context, point --app at the CDK app itself (not its cdk.out).`;
|
|
889
|
+
}
|
|
876
890
|
async function synthApp(app, opts = {}) {
|
|
877
891
|
const { region, profile, context = {} } = opts;
|
|
878
892
|
const toolkit = new Toolkit({
|
|
@@ -885,8 +899,11 @@ async function synthApp(app, opts = {}) {
|
|
|
885
899
|
const p = resolve(app);
|
|
886
900
|
const isDir = existsSync(p) && statSync(p).isDirectory();
|
|
887
901
|
let source;
|
|
888
|
-
if (isDir)
|
|
889
|
-
|
|
902
|
+
if (isDir) {
|
|
903
|
+
const ignored = contextIgnoredWarning(isDir, context);
|
|
904
|
+
if (ignored) console.error(`warning: ${ignored}`);
|
|
905
|
+
source = await toolkit.fromAssemblyDirectory(p, { failOnMissingContext: false });
|
|
906
|
+
} else {
|
|
890
907
|
const hasOverrides = Object.keys(context).length > 0;
|
|
891
908
|
const env = {};
|
|
892
909
|
if (region) {
|
|
@@ -7067,7 +7084,7 @@ const readIamAccessKey = async ({ declared, physicalId, region }) => {
|
|
|
7067
7084
|
region,
|
|
7068
7085
|
...READ_RETRY
|
|
7069
7086
|
}).send(new ListAccessKeysCommand({ UserName: userName }))).AccessKeyMetadata ?? []).find((m) => m.AccessKeyId === physicalId);
|
|
7070
|
-
if (!meta)
|
|
7087
|
+
if (!meta) throw new ResourceGoneError(`AccessKey ${physicalId} absent from user ${userName}`);
|
|
7071
7088
|
return {
|
|
7072
7089
|
UserName: userName,
|
|
7073
7090
|
Status: meta.Status
|
|
@@ -8095,8 +8112,12 @@ const readAppSyncApiKey = async ({ physicalId, declared, region }) => {
|
|
|
8095
8112
|
if (keyId) k = keys.find((x) => x.id === keyId);
|
|
8096
8113
|
nextToken = r.nextToken;
|
|
8097
8114
|
} while (!k && nextToken);
|
|
8098
|
-
if (
|
|
8099
|
-
|
|
8115
|
+
if (keyId) {
|
|
8116
|
+
if (!k) throw new ResourceGoneError(`AppSync ApiKey ${keyId} absent from API ${apiId}`);
|
|
8117
|
+
} else {
|
|
8118
|
+
k = keys[0];
|
|
8119
|
+
if (!k) return void 0;
|
|
8120
|
+
}
|
|
8100
8121
|
const model = { ApiId: apiId };
|
|
8101
8122
|
if (k.description !== void 0 && k.description !== "") model.Description = k.description;
|
|
8102
8123
|
if (k.expires !== void 0) model.Expires = k.expires;
|
|
@@ -9000,7 +9021,16 @@ const CC_IDENTIFIER_ADAPTERS = {
|
|
|
9000
9021
|
const integrationId = declared.IntegrationId;
|
|
9001
9022
|
return typeof apiId === "string" && apiId.length > 0 && typeof integrationId === "string" && integrationId.length > 0 ? `${apiId}|${integrationId}|${pid}` : void 0;
|
|
9002
9023
|
},
|
|
9003
|
-
"AWS::GuardDuty::Filter": compositeWith("DetectorId")
|
|
9024
|
+
"AWS::GuardDuty::Filter": compositeWith("DetectorId"),
|
|
9025
|
+
"AWS::Events::Rule": (pid, declared, region, account) => {
|
|
9026
|
+
const bar = pid.lastIndexOf("|");
|
|
9027
|
+
if (bar < 0) return pid;
|
|
9028
|
+
const busName = pid.slice(0, bar);
|
|
9029
|
+
const ruleName = pid.slice(bar + 1);
|
|
9030
|
+
const busArn = declared.EventBusName;
|
|
9031
|
+
if (typeof busArn === "string" && busArn.includes(":event-bus/")) return `${busArn.replace(":event-bus/", ":rule/")}/${ruleName}`;
|
|
9032
|
+
if (region && account) return `arn:${region.startsWith("cn-") ? "aws-cn" : region.startsWith("us-gov-") ? "aws-us-gov" : "aws"}:events:${region}:${account}:rule/${busName}/${ruleName}`;
|
|
9033
|
+
}
|
|
9004
9034
|
};
|
|
9005
9035
|
function scalingPolicyComposite(pid, declared) {
|
|
9006
9036
|
if (pid.includes("|")) return pid;
|
|
@@ -9043,7 +9073,7 @@ async function readLive(cc, resource, region, accountId) {
|
|
|
9043
9073
|
return { skippedReason: `SDK override (${resourceType}): ${e.name}` };
|
|
9044
9074
|
}
|
|
9045
9075
|
try {
|
|
9046
|
-
const identifier = CC_IDENTIFIER_ADAPTERS[resourceType]?.(physicalId ?? "", declared) ?? physicalId ?? "";
|
|
9076
|
+
const identifier = CC_IDENTIFIER_ADAPTERS[resourceType]?.(physicalId ?? "", declared, region, accountId) ?? physicalId ?? "";
|
|
9047
9077
|
const g = await cc.send(new GetResourceCommand({
|
|
9048
9078
|
TypeName: resourceType,
|
|
9049
9079
|
Identifier: identifier
|
|
@@ -10382,10 +10412,11 @@ const writeDocDbCluster = async (ctx, ops) => {
|
|
|
10382
10412
|
let any = false;
|
|
10383
10413
|
for (const op of ops) {
|
|
10384
10414
|
const top = op.path.replace(/^\//, "").split("/")[0];
|
|
10385
|
-
if (top
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
}
|
|
10415
|
+
if (!top || !DOCDB_CLUSTER_MODIFY_PARAMS.has(top)) continue;
|
|
10416
|
+
if (desired[top] !== void 0) input[top] = desired[top];
|
|
10417
|
+
else if (top === "DeletionProtection") input.DeletionProtection = false;
|
|
10418
|
+
else throw new Error(`DocDB DBCluster ${top} cannot be cleared via ModifyDBCluster (its unset state is AWS-assigned/required, not expressible in a selective modify); update it manually`);
|
|
10419
|
+
any = true;
|
|
10389
10420
|
}
|
|
10390
10421
|
if (!any) return;
|
|
10391
10422
|
await new DocDBClient({ region: ctx.region }).send(new ModifyDBClusterCommand(input));
|
|
@@ -10407,10 +10438,11 @@ const writeDocDbInstance = async (ctx, ops) => {
|
|
|
10407
10438
|
let any = false;
|
|
10408
10439
|
for (const op of ops) {
|
|
10409
10440
|
const top = op.path.replace(/^\//, "").split("/")[0];
|
|
10410
|
-
if (top
|
|
10411
|
-
|
|
10412
|
-
|
|
10413
|
-
}
|
|
10441
|
+
if (!top || !DOCDB_INSTANCE_MODIFY_PARAMS.has(top)) continue;
|
|
10442
|
+
if (desired[top] !== void 0) input[top] = desired[top];
|
|
10443
|
+
else if (top === "EnablePerformanceInsights") input.EnablePerformanceInsights = false;
|
|
10444
|
+
else throw new Error(`DocDB DBInstance ${top} cannot be cleared via ModifyDBInstance (its unset state is AWS-assigned/required, not expressible in a selective modify); update it manually`);
|
|
10445
|
+
any = true;
|
|
10414
10446
|
}
|
|
10415
10447
|
if (!any) return;
|
|
10416
10448
|
await new DocDBClient({ region: ctx.region }).send(new ModifyDBInstanceCommand(input));
|
|
@@ -11053,12 +11085,23 @@ const writeEc2ClientVpnEndpoint = async (ctx, ops) => {
|
|
|
11053
11085
|
const input = { ClientVpnEndpointId: id };
|
|
11054
11086
|
let any = false;
|
|
11055
11087
|
const tops = new Set(ops.map((op) => op.path.replace(/^\//, "").split("/")[0] ?? ""));
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11088
|
+
const removed = (field) => ops.some((o) => o.op === "remove" && (o.path.replace(/^\//, "").split("/")[0] ?? "") === field);
|
|
11089
|
+
for (const top of tops) if (CLIENT_VPN_SCALAR_PARAMS.has(top)) {
|
|
11090
|
+
if (desired[top] !== void 0) {
|
|
11091
|
+
input[top] = desired[top];
|
|
11092
|
+
any = true;
|
|
11093
|
+
} else if (removed(top)) {
|
|
11094
|
+
if (top === "Description") input.Description = "";
|
|
11095
|
+
else if (top === "SplitTunnel") input.SplitTunnel = false;
|
|
11096
|
+
else if (top === "DisconnectOnSessionTimeout") input.DisconnectOnSessionTimeout = false;
|
|
11097
|
+
else throw new Error(`EC2 ClientVpnEndpoint ${top} cannot be cleared via ModifyClientVpnEndpoint (its unset state is not expressible in a selective modify); update it manually`);
|
|
11098
|
+
any = true;
|
|
11099
|
+
}
|
|
11100
|
+
} else if (top === "ConnectionLogOptions") {
|
|
11101
|
+
if (desired.ConnectionLogOptions !== void 0) {
|
|
11102
|
+
input.ConnectionLogOptions = desired.ConnectionLogOptions;
|
|
11103
|
+
any = true;
|
|
11104
|
+
} else if (removed("ConnectionLogOptions")) throw new Error("EC2 ClientVpnEndpoint ConnectionLogOptions cannot be cleared via ModifyClientVpnEndpoint (its unset state is not expressible in a selective modify); update it manually");
|
|
11062
11105
|
} else if (top === "DnsServers") {
|
|
11063
11106
|
const list = desired.DnsServers;
|
|
11064
11107
|
input.DnsServers = Array.isArray(list) && list.length > 0 ? {
|
|
@@ -11073,7 +11116,7 @@ const writeEc2ClientVpnEndpoint = async (ctx, ops) => {
|
|
|
11073
11116
|
input.SecurityGroupIds = list;
|
|
11074
11117
|
input.VpcId = vpcId;
|
|
11075
11118
|
any = true;
|
|
11076
|
-
}
|
|
11119
|
+
} else if (removed("SecurityGroupIds")) throw new Error("EC2 ClientVpnEndpoint SecurityGroupIds cannot be cleared via ModifyClientVpnEndpoint (an endpoint cannot revert to no security group in a selective modify); update it manually");
|
|
11077
11120
|
}
|
|
11078
11121
|
if (!any) return;
|
|
11079
11122
|
await new EC2Client({ region: ctx.region }).send(new ModifyClientVpnEndpointCommand(input));
|
|
@@ -13068,7 +13111,7 @@ async function runRecord(args) {
|
|
|
13068
13111
|
emitJsonArray(jsonReports);
|
|
13069
13112
|
return worst;
|
|
13070
13113
|
}
|
|
13071
|
-
if (
|
|
13114
|
+
if (wroteAny) console.log("commit the baseline file(s) so drift is detected against them going forward.");
|
|
13072
13115
|
return worst;
|
|
13073
13116
|
}
|
|
13074
13117
|
|
|
@@ -13182,7 +13225,7 @@ async function runIgnore(args) {
|
|
|
13182
13225
|
emitJsonArray(jsonReports);
|
|
13183
13226
|
return worst;
|
|
13184
13227
|
}
|
|
13185
|
-
if (
|
|
13228
|
+
if (wroteAny) console.log("commit .cdkrd/ignore.yaml so the ignore rules apply for everyone going forward.");
|
|
13186
13229
|
return worst;
|
|
13187
13230
|
}
|
|
13188
13231
|
|