cdk-real-drift 0.22.6 → 0.23.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/README.md +4 -0
- package/dist/cli.js +87 -3
- package/dist/cli.js.map +1 -1
- package/package.json +4 -10
package/README.md
CHANGED
|
@@ -1193,6 +1193,10 @@ place, since Cloud Control has no handler for the type),
|
|
|
1193
1193
|
`AWS::Config::ConfigurationRecorder` — a whole-recorder upsert re-supplying the
|
|
1194
1194
|
declared RecordingGroup / RecordingMode / RoleARN, since Cloud Control cannot
|
|
1195
1195
|
write the type),
|
|
1196
|
+
`budgets:UpdateBudget` (reverts an `AWS::Budgets::Budget` — a whole-`NewBudget`
|
|
1197
|
+
overwrite reconstructed from the desired values plus the live projection, since
|
|
1198
|
+
Cloud Control cannot write the type; a computed `BudgetLimit` is dropped for an
|
|
1199
|
+
auto-adjusting budget so revert keeps it auto-adjusting),
|
|
1196
1200
|
`ecs:UpdateService` (reverts an `AWS::ECS::Service` `ServiceConnectConfiguration` /
|
|
1197
1201
|
`VolumeConfigurations` drift — the whole writeOnly prop is re-supplied, since Cloud
|
|
1198
1202
|
Control cannot sub-path patch it),
|
package/dist/cli.js
CHANGED
|
@@ -36,7 +36,7 @@ import { DeleteResourcePolicyCommand, GetResourcePolicyCommand, SecretsManagerCl
|
|
|
36
36
|
import { GetTopicAttributesCommand, ListSubscriptionsByTopicCommand, SNSClient, SetTopicAttributesCommand } from "@aws-sdk/client-sns";
|
|
37
37
|
import { GetQueueAttributesCommand, SQSClient, SetQueueAttributesCommand } from "@aws-sdk/client-sqs";
|
|
38
38
|
import { ACMClient, DescribeCertificateCommand, ListTagsForCertificateCommand } from "@aws-sdk/client-acm";
|
|
39
|
-
import { BudgetsClient, DescribeBudgetCommand } from "@aws-sdk/client-budgets";
|
|
39
|
+
import { BudgetsClient, DescribeBudgetCommand, UpdateBudgetCommand } from "@aws-sdk/client-budgets";
|
|
40
40
|
import { DescribeConfigurationSettingsCommand, ElasticBeanstalkClient, UpdateApplicationCommand, UpdateApplicationResourceLifecycleCommand, UpdateEnvironmentCommand } from "@aws-sdk/client-elastic-beanstalk";
|
|
41
41
|
import { CognitoSyncClient, GetCognitoEventsCommand, SetCognitoEventsCommand } from "@aws-sdk/client-cognito-sync";
|
|
42
42
|
import { BatchGetProjectsCommand, BatchGetReportGroupsCommand, CodeBuildClient, UpdateProjectCommand, UpdateReportGroupCommand } from "@aws-sdk/client-codebuild";
|
|
@@ -1925,6 +1925,8 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
|
|
|
1925
1925
|
const dmsStorageDefault = typeof dmsClass === "string" && opts.accountDefaults?.dmsAllocatedStorageDefaults?.[dmsClass] !== void 0 ? { dmsAllocatedStorageDefaults: { [dmsClass]: opts.accountDefaults.dmsAllocatedStorageDefaults[dmsClass] } } : void 0;
|
|
1926
1926
|
const cvpnVpcMap = opts.siblingClientVpnEndpointVpcs;
|
|
1927
1927
|
const cvpnVpcKey = resource.resourceType !== "AWS::EC2::ClientVpnEndpoint" || cvpnVpcMap === void 0 ? void 0 : resource.logicalId in cvpnVpcMap ? resource.logicalId : resource.physicalId !== void 0 && resource.physicalId in cvpnVpcMap ? resource.physicalId : void 0;
|
|
1928
|
+
const cfCdMap = opts.siblingCloudFrontCdPolicyIds;
|
|
1929
|
+
const cfCdKey = resource.resourceType !== "AWS::CloudFront::Distribution" || cfCdMap === void 0 ? void 0 : resource.logicalId in cfCdMap ? resource.logicalId : resource.physicalId !== void 0 && resource.physicalId in cfCdMap ? resource.physicalId : void 0;
|
|
1928
1930
|
return sanitizeAccountId({
|
|
1929
1931
|
corpusVersion: 1,
|
|
1930
1932
|
resource: {
|
|
@@ -1963,7 +1965,8 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
|
|
|
1963
1965
|
...rdsOptCatalog && resource.physicalId ? { rdsOptionSettingDefaults: { [resource.physicalId]: rdsOptCatalog } } : {},
|
|
1964
1966
|
...gaListenerPort ? { siblingListenerPorts: gaListenerPort } : {},
|
|
1965
1967
|
...dmsStorageDefault ? { accountDefaults: dmsStorageDefault } : {},
|
|
1966
|
-
...cvpnVpcKey !== void 0 && cvpnVpcMap !== void 0 ? { siblingClientVpnEndpointVpcs: { [cvpnVpcKey]: cvpnVpcMap[cvpnVpcKey] ?? null } } : {}
|
|
1968
|
+
...cvpnVpcKey !== void 0 && cvpnVpcMap !== void 0 ? { siblingClientVpnEndpointVpcs: { [cvpnVpcKey]: cvpnVpcMap[cvpnVpcKey] ?? null } } : {},
|
|
1969
|
+
...cfCdKey !== void 0 && cfCdMap !== void 0 ? { siblingCloudFrontCdPolicyIds: { [cfCdKey]: cfCdMap[cfCdKey] ?? null } } : {}
|
|
1967
1970
|
},
|
|
1968
1971
|
expected: findings
|
|
1969
1972
|
}, opts.accountId);
|
|
@@ -5981,6 +5984,7 @@ const MEANINGFUL_WHEN_OFF_NESTED = {
|
|
|
5981
5984
|
"WorkGroupConfiguration.PublishCloudWatchMetricsEnabled": () => true
|
|
5982
5985
|
},
|
|
5983
5986
|
"AWS::EKS::Cluster": { "ResourcesVpcConfig.EndpointPublicAccess": () => true },
|
|
5987
|
+
"AWS::Budgets::Budget": { "Budget.CostTypes": () => true },
|
|
5984
5988
|
"AWS::ECS::Service": { "DeploymentConfiguration.DeploymentCircuitBreaker.ResetOnHealthyTask": ({ declared, live }) => {
|
|
5985
5989
|
const enabled = (v) => typeof v === "object" && v !== null && v["DeploymentCircuitBreaker"]?.["Enable"] === true;
|
|
5986
5990
|
return enabled(declared["DeploymentConfiguration"]) || enabled(live["DeploymentConfiguration"]);
|
|
@@ -6382,6 +6386,27 @@ function glueIcebergManagedParamsAtDefault(resourceType, schemaPath, value, decl
|
|
|
6382
6386
|
if (!Object.keys(params).every((k) => managed.has(k))) return false;
|
|
6383
6387
|
return params.table_type === "ICEBERG";
|
|
6384
6388
|
}
|
|
6389
|
+
function cloudFrontCdPolicySynonymAtDefault(resourceType, schemaPath, value, declared) {
|
|
6390
|
+
if (resourceType !== "AWS::CloudFront::ContinuousDeploymentPolicy") return false;
|
|
6391
|
+
const cfg = declared.ContinuousDeploymentPolicyConfig;
|
|
6392
|
+
if (!isNestedObject(cfg)) return false;
|
|
6393
|
+
const c = cfg;
|
|
6394
|
+
const traffic = isNestedObject(c.TrafficConfig) ? c.TrafficConfig : void 0;
|
|
6395
|
+
switch (schemaPath) {
|
|
6396
|
+
case "ContinuousDeploymentPolicyConfig.Type": return traffic !== void 0 && deepEqual(value, traffic.Type);
|
|
6397
|
+
case "ContinuousDeploymentPolicyConfig.SingleWeightPolicyConfig": return traffic !== void 0 && deepEqual(value, traffic.SingleWeightConfig);
|
|
6398
|
+
case "ContinuousDeploymentPolicyConfig.SingleHeaderPolicyConfig": return traffic !== void 0 && deepEqual(value, traffic.SingleHeaderConfig);
|
|
6399
|
+
case "ContinuousDeploymentPolicyConfig.TrafficConfig": {
|
|
6400
|
+
if (traffic !== void 0 || !isNestedObject(value)) return false;
|
|
6401
|
+
if (c.Type === void 0) return false;
|
|
6402
|
+
const derived = { Type: c.Type };
|
|
6403
|
+
if (c.SingleWeightPolicyConfig !== void 0) derived.SingleWeightConfig = c.SingleWeightPolicyConfig;
|
|
6404
|
+
if (c.SingleHeaderPolicyConfig !== void 0) derived.SingleHeaderConfig = c.SingleHeaderPolicyConfig;
|
|
6405
|
+
return deepEqual(value, derived);
|
|
6406
|
+
}
|
|
6407
|
+
default: return false;
|
|
6408
|
+
}
|
|
6409
|
+
}
|
|
6385
6410
|
const CLB_DEFAULT_SSL_POLICY_NAME = "ELBSecurityPolicy-2016-08";
|
|
6386
6411
|
function clbDefaultSslPoliciesAtDefault(resourceType, key, value) {
|
|
6387
6412
|
if (resourceType !== "AWS::ElasticLoadBalancing::LoadBalancer" || key !== "Policies") return false;
|
|
@@ -7305,7 +7330,11 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
7305
7330
|
const parentKey = (path.split(".").pop() ?? "").replace(/\[.*$/, "");
|
|
7306
7331
|
if (!isObjectForm || /tags$/i.test(parentKey)) return;
|
|
7307
7332
|
}
|
|
7308
|
-
const tier = schemaPath in schema.defaultPaths && matchesKnownDefault(value, schema.defaultPaths[schemaPath]) || schemaPath in knownDefPaths && matchesKnownDefault(value, knownDefPaths[schemaPath]) || (KNOWN_DEFAULT_ONE_OF_PATHS[resourceType]?.[schemaPath]?.some((d) => matchesKnownDefault(value, d)) ?? false) || VALUE_INDEPENDENT_DEFAULT_NESTED_PATHS[resourceType]?.has(schemaPath) && !(schemaPath in knownDefPaths) || dynamoGsiWarmThroughputAtDefault(resourceType, path, value, live, declared) || resourceType === "AWS::Events::EventBusPolicy" && schemaPath === "Statement.*.Sid" && typeof value === "string" && value === declared["StatementId"] || configRecordingStrategyAtDefault(resourceType, schemaPath, value, live) ||
|
|
7333
|
+
const tier = schemaPath in schema.defaultPaths && matchesKnownDefault(value, schema.defaultPaths[schemaPath]) || schemaPath in knownDefPaths && matchesKnownDefault(value, knownDefPaths[schemaPath]) || (KNOWN_DEFAULT_ONE_OF_PATHS[resourceType]?.[schemaPath]?.some((d) => matchesKnownDefault(value, d)) ?? false) || VALUE_INDEPENDENT_DEFAULT_NESTED_PATHS[resourceType]?.has(schemaPath) && !(schemaPath in knownDefPaths) || dynamoGsiWarmThroughputAtDefault(resourceType, path, value, live, declared) || resourceType === "AWS::Events::EventBusPolicy" && schemaPath === "Statement.*.Sid" && typeof value === "string" && value === declared["StatementId"] || configRecordingStrategyAtDefault(resourceType, schemaPath, value, live) || cloudFrontCdPolicySynonymAtDefault(resourceType, schemaPath, value, declared) || resourceType === "AWS::CloudFront::Distribution" && schemaPath === "DistributionConfig.ContinuousDeploymentPolicyId" && typeof value === "string" && (() => {
|
|
7334
|
+
const m = opts.siblingCloudFrontCdPolicyIds;
|
|
7335
|
+
const derived = m === void 0 ? void 0 : logicalId in m ? m[logicalId] : physicalId !== void 0 && physicalId in m ? m[physicalId] : void 0;
|
|
7336
|
+
return derived !== void 0 && (derived === null || derived === value);
|
|
7337
|
+
})() || glueIcebergManagedParamsAtDefault(resourceType, schemaPath, value, declared) ? "atDefault" : generatedPaths.includes(schemaPath) && isPhysicalIdSegment(value, physicalId) || generatedNestedPaths?.has(schemaPath) && !(schemaPath in knownDefPaths) && (!(schemaPath in (MANAGED_KEY_ALIAS_PATHS[resourceType] ?? {})) || shouldFoldManagedServiceKey(resourceType, schemaPath, value, opts.kmsAliasTargets)) ? "generated" : "undeclared";
|
|
7309
7338
|
const freeFormKey = tier === "undeclared" && underFreeFormMap(schemaPath);
|
|
7310
7339
|
findings.push({
|
|
7311
7340
|
tier,
|
|
@@ -14897,6 +14926,42 @@ function buildClientVpnEndpointSiblingVpcs(desired) {
|
|
|
14897
14926
|
}
|
|
14898
14927
|
return out;
|
|
14899
14928
|
}
|
|
14929
|
+
function buildCloudFrontStagingDistCdPolicyIds(desired, liveByLogical) {
|
|
14930
|
+
const refLogicalId = (ref) => {
|
|
14931
|
+
if (ref && typeof ref === "object") {
|
|
14932
|
+
if ("Ref" in ref && typeof ref.Ref === "string") return ref.Ref;
|
|
14933
|
+
if ("Fn::GetAtt" in ref) {
|
|
14934
|
+
const g = ref["Fn::GetAtt"];
|
|
14935
|
+
if (Array.isArray(g) && typeof g[0] === "string") return g[0];
|
|
14936
|
+
}
|
|
14937
|
+
}
|
|
14938
|
+
};
|
|
14939
|
+
const distIdentities = /* @__PURE__ */ new Map();
|
|
14940
|
+
const distByDomain = /* @__PURE__ */ new Map();
|
|
14941
|
+
for (const r of desired.resources) {
|
|
14942
|
+
if (r.resourceType !== "AWS::CloudFront::Distribution") continue;
|
|
14943
|
+
const ids = [r.logicalId];
|
|
14944
|
+
if (r.physicalId) ids.push(r.physicalId);
|
|
14945
|
+
distIdentities.set(r.logicalId, ids);
|
|
14946
|
+
const domain = liveByLogical?.get(r.logicalId)?.["DomainName"];
|
|
14947
|
+
if (typeof domain === "string" && domain) distByDomain.set(domain.toLowerCase(), r.logicalId);
|
|
14948
|
+
}
|
|
14949
|
+
const out = {};
|
|
14950
|
+
for (const r of desired.resources) {
|
|
14951
|
+
if (r.resourceType !== "AWS::CloudFront::ContinuousDeploymentPolicy") continue;
|
|
14952
|
+
const cfg = r.declared?.["ContinuousDeploymentPolicyConfig"];
|
|
14953
|
+
const dns = cfg !== null && typeof cfg === "object" && !Array.isArray(cfg) ? cfg["StagingDistributionDnsNames"] : void 0;
|
|
14954
|
+
if (!Array.isArray(dns)) continue;
|
|
14955
|
+
const policyId = r.physicalId ?? null;
|
|
14956
|
+
for (const el of dns) {
|
|
14957
|
+
const distLogical = refLogicalId(el) ?? (typeof el === "string" ? distByDomain.get(el.toLowerCase()) : void 0);
|
|
14958
|
+
if (distLogical === void 0) continue;
|
|
14959
|
+
for (const key of distIdentities.get(distLogical) ?? []) if (key in out && out[key] !== policyId) out[key] = null;
|
|
14960
|
+
else out[key] = policyId;
|
|
14961
|
+
}
|
|
14962
|
+
}
|
|
14963
|
+
return out;
|
|
14964
|
+
}
|
|
14900
14965
|
function buildSiblingSubnetCidrBlocks(desired) {
|
|
14901
14966
|
const subnetIdentities = /* @__PURE__ */ new Map();
|
|
14902
14967
|
for (const r of desired.resources) {
|
|
@@ -15326,6 +15391,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
15326
15391
|
clusterEchoModel: buildClusterEchoModels(desired),
|
|
15327
15392
|
scalableTargetBands: buildScalableTargetBands(desired),
|
|
15328
15393
|
siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
|
|
15394
|
+
siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, liveModelMap(reads)),
|
|
15329
15395
|
rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
|
|
15330
15396
|
};
|
|
15331
15397
|
const corpusDir = process.env[CORPUS_DIR_ENV];
|
|
@@ -15403,6 +15469,7 @@ async function regatherTouched(gathered, touched, region) {
|
|
|
15403
15469
|
clusterEchoModel: buildClusterEchoModels(desired),
|
|
15404
15470
|
scalableTargetBands: buildScalableTargetBands(desired),
|
|
15405
15471
|
siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
|
|
15472
|
+
siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, liveModelMap(reads)),
|
|
15406
15473
|
rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
|
|
15407
15474
|
};
|
|
15408
15475
|
const fresh = [];
|
|
@@ -19049,7 +19116,24 @@ const writeApiGatewayRestApiPolicy = async (ctx) => {
|
|
|
19049
19116
|
}]
|
|
19050
19117
|
}));
|
|
19051
19118
|
};
|
|
19119
|
+
const writeBudget = async (ctx, ops) => {
|
|
19120
|
+
const budget = (await desiredModel("AWS::Budgets::Budget", ctx, ops)).Budget;
|
|
19121
|
+
if (!budget || !str(budget.BudgetName) || !str(budget.BudgetType) || !str(budget.TimeUnit)) throw new Error("cannot resolve Budget identity (BudgetName/BudgetType/TimeUnit) for revert");
|
|
19122
|
+
if (!str(ctx.accountId)) throw new Error("cannot resolve AccountId for Budget revert");
|
|
19123
|
+
const newBudget = budget.AutoAdjustData ? {
|
|
19124
|
+
...budget,
|
|
19125
|
+
BudgetLimit: void 0
|
|
19126
|
+
} : budget;
|
|
19127
|
+
await new BudgetsClient({
|
|
19128
|
+
region: ctx.region,
|
|
19129
|
+
...CLIENT_TIMEOUTS
|
|
19130
|
+
}).send(new UpdateBudgetCommand({
|
|
19131
|
+
AccountId: ctx.accountId,
|
|
19132
|
+
NewBudget: newBudget
|
|
19133
|
+
}));
|
|
19134
|
+
};
|
|
19052
19135
|
const SDK_WRITERS = {
|
|
19136
|
+
"AWS::Budgets::Budget": writeBudget,
|
|
19053
19137
|
"AWS::ApiGatewayV2::Stage": writeApiGatewayV2Stage,
|
|
19054
19138
|
"AWS::ElasticBeanstalk::Application": writeElasticBeanstalkApplication,
|
|
19055
19139
|
"AWS::ElasticBeanstalk::Environment": writeElasticBeanstalkEnvironment,
|