cdk-real-drift 0.12.52 → 0.12.54
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 +14 -4
- package/dist/cli.js +70 -2
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -267,8 +267,10 @@ of an undeclared property, and is reconciled the same way against your baseline:
|
|
|
267
267
|
`cdk drift` / CFn drift detection compare only template-declared resources, so an
|
|
268
268
|
out-of-band addition is invisible to them. Decide it like any finding: `record`
|
|
269
269
|
snapshots its full live model and watches it, `ignore` accepts it, or `revert`
|
|
270
|
-
**deletes** it (Cloud Control `DeleteResource
|
|
271
|
-
|
|
270
|
+
**deletes** it (Cloud Control `DeleteResource` — or a type-specific SDK delete
|
|
271
|
+
where Cloud Control does not support the type's DELETE action, e.g. an AppSync
|
|
272
|
+
api key — behind the usual confirm / `--dry-run` / picker; an unrecorded one
|
|
273
|
+
needs `--remove-unrecorded`).
|
|
272
274
|
|
|
273
275
|
<details>
|
|
274
276
|
<summary>Covered parent types (the <code>CHILD_ENUMERATORS</code> registry, growing per type)</summary>
|
|
@@ -487,6 +489,12 @@ before deploying. As a pipeline gate:
|
|
|
487
489
|
`--pre-deploy` reports **declared** drift only (the undeclared tier is defined
|
|
488
490
|
against the _deployed_ template) and never touches the baseline.
|
|
489
491
|
|
|
492
|
+
One caveat on template **parameters**: for an existing parameter a plain
|
|
493
|
+
`cdk deploy` keeps the deployed value (`UsePreviousValue`), so drift previewed
|
|
494
|
+
from a **changed local `Default`** is applied only if you pass
|
|
495
|
+
`--parameters <key>=<value>` / `--no-previous-parameters` — `check` prints a
|
|
496
|
+
stderr note naming each such parameter and both values.
|
|
497
|
+
|
|
490
498
|
### Ignoring externally-managed properties
|
|
491
499
|
|
|
492
500
|
Some properties are _legitimately_ rewritten by another system, such as Application
|
|
@@ -968,7 +976,7 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
968
976
|
`es:ListDomainNames`, `es:DescribeDomains` — a caller lacking these degrades
|
|
969
977
|
fail-safe (the service client is treated as corroborated, never falsely flagged)
|
|
970
978
|
- `AWS::AppSync::GraphQLApi`: `appsync:ListDataSources`, `appsync:ListResolvers`,
|
|
971
|
-
`appsync:ListFunctions`, `appsync:ListTypes`
|
|
979
|
+
`appsync:ListFunctions`, `appsync:ListTypes`, `appsync:ListApiKeys`
|
|
972
980
|
- `AWS::Logs::LogGroup`: `logs:DescribeSubscriptionFilters` (plus
|
|
973
981
|
`logs:DescribeMetricFilters`, already listed above)
|
|
974
982
|
- `AWS::ElasticLoadBalancingV2::LoadBalancer` + `::Listener`:
|
|
@@ -1002,7 +1010,9 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
1002
1010
|
|
|
1003
1011
|
`cloudcontrol:UpdateResource` (which resolves to each type's own update
|
|
1004
1012
|
permissions), `cloudcontrol:DeleteResource` (to delete an out-of-band `added`
|
|
1005
|
-
resource
|
|
1013
|
+
resource; a type Cloud Control cannot delete goes through its own SDK action
|
|
1014
|
+
instead — `appsync:DeleteApiKey` for an out-of-band `AWS::AppSync::ApiKey`), and
|
|
1015
|
+
`cloudcontrol:GetResourceRequestStatus` (to poll the async Cloud
|
|
1006
1016
|
Control request to completion). Plus, for the SDK-written types:
|
|
1007
1017
|
`s3:PutBucketPolicy` /
|
|
1008
1018
|
`s3:DeleteBucketPolicy`, `sns:SetTopicAttributes`, `sqs:SetQueueAttributes`,
|
package/dist/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ import jsonata from "jsonata";
|
|
|
16
16
|
import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
|
|
17
17
|
import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, GetStagesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
|
|
18
18
|
import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
|
|
19
|
-
import { AppSyncClient, ListApiKeysCommand, ListDataSourcesCommand, ListFunctionsCommand, ListResolversCommand, ListTypesCommand } from "@aws-sdk/client-appsync";
|
|
19
|
+
import { AppSyncClient, DeleteApiKeyCommand, ListApiKeysCommand, ListDataSourcesCommand, ListFunctionsCommand, ListResolversCommand, ListTypesCommand } from "@aws-sdk/client-appsync";
|
|
20
20
|
import { ApiGatewayV2Client, DeleteAccessLogSettingsCommand, DeleteRouteSettingsCommand, GetAuthorizersCommand as GetAuthorizersCommand$1, GetIntegrationsCommand, GetRoutesCommand, GetStagesCommand as GetStagesCommand$1, UpdateStageCommand } from "@aws-sdk/client-apigatewayv2";
|
|
21
21
|
import { CloudWatchLogsClient, DescribeMetricFiltersCommand, DescribeSubscriptionFiltersCommand, PutBearerTokenAuthenticationCommand, PutMetricFilterCommand } from "@aws-sdk/client-cloudwatch-logs";
|
|
22
22
|
import { CognitoIdentityProviderClient, ListGroupsCommand, ListIdentityProvidersCommand, ListResourceServersCommand, ListUserPoolClientsCommand } from "@aws-sdk/client-cognito-identity-provider";
|
|
@@ -4466,6 +4466,29 @@ function unpreviewableParamInfo(template, stackParams, stackName) {
|
|
|
4466
4466
|
const more = unpreviewable.length > shown.length ? `, …(+${unpreviewable.length - shown.length} more)` : "";
|
|
4467
4467
|
return `warning: ${stackName}: ${unpreviewable.length} local parameter(s) have NO value under --pre-deploy (new/renamed, no Default, absent from the deployed stack) — every declared property that Refs them resolves UNRESOLVED and was NOT compared (cannot preview): ${shown.join(", ")}${more}`;
|
|
4468
4468
|
}
|
|
4469
|
+
function changedDefaultParamInfo(template, stackParams, stackName) {
|
|
4470
|
+
const paramDefs = template.Parameters ?? {};
|
|
4471
|
+
const normalize = (k, v) => {
|
|
4472
|
+
const t = paramDefs[k]?.Type ?? "";
|
|
4473
|
+
if (t !== "CommaDelimitedList" && !t.startsWith("List<")) return v;
|
|
4474
|
+
return v.split(",").map((s) => s.trim()).join(",");
|
|
4475
|
+
};
|
|
4476
|
+
const changed = Object.entries(paramDefs).filter(([k, def]) => {
|
|
4477
|
+
if (def?.NoEcho === true || def?.NoEcho === "true") return false;
|
|
4478
|
+
if ((def?.Type ?? "").includes("::Parameter::Value<")) return false;
|
|
4479
|
+
if (!def || !("Default" in def)) return false;
|
|
4480
|
+
if (!(k in stackParams)) return false;
|
|
4481
|
+
return normalize(k, String(def.Default)) !== normalize(k, stackParams[k] ?? "");
|
|
4482
|
+
}).map(([k]) => k);
|
|
4483
|
+
if (changed.length === 0) return null;
|
|
4484
|
+
const referenced = collectReferencedNames(template.Resources ?? {});
|
|
4485
|
+
collectReferencedNames(template.Conditions ?? {}, referenced);
|
|
4486
|
+
const diverged = changed.filter((k) => referenced.has(k)).sort();
|
|
4487
|
+
if (diverged.length === 0) return null;
|
|
4488
|
+
const shown = diverged.slice(0, 10).map((k) => `${k} (local Default ${JSON.stringify(String(paramDefs[k]?.Default))}, deployed ${JSON.stringify(stackParams[k])})`);
|
|
4489
|
+
const more = diverged.length > shown.length ? `, …(+${diverged.length - shown.length} more)` : "";
|
|
4490
|
+
return `warning: ${stackName}: ${diverged.length} local parameter(s) changed their Default vs the deployed value — the preview resolves them from the NEW local Default, but a plain \`cdk deploy\` KEEPS the deployed value (UsePreviousValue) unless \`--parameters <key>=<value>\` / \`--no-previous-parameters\` is passed: ${shown.join(", ")}${more}`;
|
|
4491
|
+
}
|
|
4469
4492
|
function partitionForRegion(region) {
|
|
4470
4493
|
if (region.startsWith("us-gov-")) return {
|
|
4471
4494
|
partition: "aws-us-gov",
|
|
@@ -4667,6 +4690,8 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
|
|
|
4667
4690
|
if (deletedInfo) console.error(deletedInfo);
|
|
4668
4691
|
const noValueInfo = unpreviewableParamInfo(template, stackParams, stackName);
|
|
4669
4692
|
if (noValueInfo) console.error(noValueInfo);
|
|
4693
|
+
const changedDefaultInfo = changedDefaultParamInfo(template, stackParams, stackName);
|
|
4694
|
+
if (changedDefaultInfo) console.error(changedDefaultInfo);
|
|
4670
4695
|
}
|
|
4671
4696
|
const templateResourcesForTypeCheck = template.Resources ?? {};
|
|
4672
4697
|
const typeChanged = new Set(typeChangedResources(templateResourcesForTypeCheck, deployedTypeOf));
|
|
@@ -15993,6 +16018,19 @@ function resolveSdkWriter(resourceType, ops) {
|
|
|
15993
16018
|
const nested = SDK_NESTED_WRITERS[resourceType];
|
|
15994
16019
|
if (nested && ops[0] && nested.match(pointerToDotted(ops[0].path))) return nested.writer;
|
|
15995
16020
|
}
|
|
16021
|
+
const deleteAppSyncApiKey = async (ctx) => {
|
|
16022
|
+
const parent = ctx.parentPhysicalId;
|
|
16023
|
+
if (!parent) throw new Error("cannot resolve the parent GraphQLApi id for the AppSync ApiKey delete");
|
|
16024
|
+
const apiId = parent.includes("/") ? parent.slice(parent.lastIndexOf("/") + 1) : parent;
|
|
16025
|
+
await new AppSyncClient({
|
|
16026
|
+
region: ctx.region,
|
|
16027
|
+
...CLIENT_TIMEOUTS
|
|
16028
|
+
}).send(new DeleteApiKeyCommand({
|
|
16029
|
+
apiId,
|
|
16030
|
+
id: ctx.physicalId
|
|
16031
|
+
}));
|
|
16032
|
+
};
|
|
16033
|
+
const SDK_DELETERS = { "AWS::AppSync::ApiKey": deleteAppSyncApiKey };
|
|
15996
16034
|
|
|
15997
16035
|
//#endregion
|
|
15998
16036
|
//#region src/revert/plan.ts
|
|
@@ -16807,6 +16845,9 @@ async function applyRevertDelete(cc, item, identifier = item.physicalId, retry =
|
|
|
16807
16845
|
};
|
|
16808
16846
|
}
|
|
16809
16847
|
};
|
|
16848
|
+
return retryDeleteDeferringDependencies(oneDelete, retry);
|
|
16849
|
+
}
|
|
16850
|
+
async function retryDeleteDeferringDependencies(oneDelete, retry) {
|
|
16810
16851
|
let deferredDepError;
|
|
16811
16852
|
const guardedDelete = async () => {
|
|
16812
16853
|
const r = await oneDelete();
|
|
@@ -16826,6 +16867,21 @@ async function applyRevertDelete(cc, item, identifier = item.physicalId, retry =
|
|
|
16826
16867
|
};
|
|
16827
16868
|
return r;
|
|
16828
16869
|
}
|
|
16870
|
+
async function applyRevertDeleteSdk(doDelete, retry = {}) {
|
|
16871
|
+
const oneDelete = async () => {
|
|
16872
|
+
try {
|
|
16873
|
+
await doDelete();
|
|
16874
|
+
return { ok: true };
|
|
16875
|
+
} catch (e) {
|
|
16876
|
+
if (isAlreadyGone(e)) return { ok: true };
|
|
16877
|
+
return {
|
|
16878
|
+
ok: false,
|
|
16879
|
+
error: errorText(e)
|
|
16880
|
+
};
|
|
16881
|
+
}
|
|
16882
|
+
};
|
|
16883
|
+
return retryDeleteDeferringDependencies(oneDelete, retry);
|
|
16884
|
+
}
|
|
16829
16885
|
|
|
16830
16886
|
//#endregion
|
|
16831
16887
|
//#region src/commands/stack-actions.ts
|
|
@@ -17630,7 +17686,19 @@ async function revertStack(p) {
|
|
|
17630
17686
|
streamResultLine(item.logicalId);
|
|
17631
17687
|
}
|
|
17632
17688
|
const deleteDeadlineMs = waitMs !== void 0 ? clock() + waitMs : void 0;
|
|
17633
|
-
const deleteOutcomes = await applyRevertDeletes(deleteItems, (item) =>
|
|
17689
|
+
const deleteOutcomes = await applyRevertDeletes(deleteItems, (item) => {
|
|
17690
|
+
const sdkDeleter = SDK_DELETERS[item.resourceType];
|
|
17691
|
+
if (sdkDeleter) {
|
|
17692
|
+
const parentLogicalId = item.logicalId.split("/", 1)[0] ?? item.logicalId;
|
|
17693
|
+
const parentPhysicalId = resByLogical.get(parentLogicalId)?.physicalId;
|
|
17694
|
+
return applyRevertDeleteSdk(() => sdkDeleter({
|
|
17695
|
+
physicalId: item.physicalId,
|
|
17696
|
+
parentPhysicalId,
|
|
17697
|
+
region
|
|
17698
|
+
}), buildRetryOpts(item.displayId, deleteDeadlineMs));
|
|
17699
|
+
}
|
|
17700
|
+
return applyRevertDelete(cc, item, item.physicalId, buildRetryOpts(item.displayId, deleteDeadlineMs));
|
|
17701
|
+
});
|
|
17634
17702
|
for (const { item, result: r } of deleteOutcomes) {
|
|
17635
17703
|
if (!r.ok) failedDeleteIds.add(item.logicalId);
|
|
17636
17704
|
applied.push({
|