cdk-real-drift 0.2.4 → 0.2.5
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 +28 -7
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2678,6 +2678,19 @@ const UNORDERED_OBJECT_ARRAY_PROPS = {
|
|
|
2678
2678
|
"AWS::WAFv2::LoggingConfiguration": new Set(["RedactedFields"]),
|
|
2679
2679
|
"AWS::EC2::PrefixList": new Set(["Entries"])
|
|
2680
2680
|
};
|
|
2681
|
+
const UNORDERED_OBJECT_ARRAY_IDENTITY = {
|
|
2682
|
+
"AWS::Cognito::UserPoolResourceServer": { Scopes: "ScopeName" },
|
|
2683
|
+
"AWS::SecretsManager::Secret": { ReplicaRegions: "Region" },
|
|
2684
|
+
"AWS::ElastiCache::CacheCluster": { LogDeliveryConfigurations: "LogType" },
|
|
2685
|
+
"AWS::ElastiCache::ReplicationGroup": { LogDeliveryConfigurations: "LogType" },
|
|
2686
|
+
"AWS::AutoScaling::AutoScalingGroup": { LifecycleHookSpecificationList: "LifecycleHookName" },
|
|
2687
|
+
"AWS::Redshift::ClusterParameterGroup": { Parameters: "ParameterName" },
|
|
2688
|
+
"AWS::ElasticLoadBalancingV2::ListenerRule": { Conditions: "Field" },
|
|
2689
|
+
"AWS::EC2::PrefixList": { Entries: "Cidr" },
|
|
2690
|
+
"AWS::IAM::Role": { Policies: "PolicyName" },
|
|
2691
|
+
"AWS::IAM::User": { Policies: "PolicyName" },
|
|
2692
|
+
"AWS::IAM::Group": { Policies: "PolicyName" }
|
|
2693
|
+
};
|
|
2681
2694
|
const UNORDERED_NESTED_OBJECT_ARRAY_PATHS = {
|
|
2682
2695
|
"AWS::CloudFront::CachePolicy": new Set(["CachePolicyConfig.ParametersInCacheKeyAndForwardedToOrigin.HeadersConfig.Headers"]),
|
|
2683
2696
|
"AWS::CloudFront::Distribution": new Set(["DistributionConfig.Aliases"]),
|
|
@@ -2729,11 +2742,15 @@ function canonicalJson(v) {
|
|
|
2729
2742
|
}
|
|
2730
2743
|
return JSON.stringify(v) ?? "null";
|
|
2731
2744
|
}
|
|
2732
|
-
function sortUnorderedObjectArray(v) {
|
|
2745
|
+
function sortUnorderedObjectArray(v, identityField) {
|
|
2733
2746
|
if (!Array.isArray(v)) return v;
|
|
2747
|
+
const keyOf = (e) => {
|
|
2748
|
+
const id = identityField && e !== null && typeof e === "object" && !Array.isArray(e) ? e[identityField] : void 0;
|
|
2749
|
+
return `${id === void 0 ? "" : `${String(id)}`}${canonicalJson(e)}`;
|
|
2750
|
+
};
|
|
2734
2751
|
return [...v].sort((a, b) => {
|
|
2735
|
-
const ka =
|
|
2736
|
-
const kb =
|
|
2752
|
+
const ka = keyOf(a);
|
|
2753
|
+
const kb = keyOf(b);
|
|
2737
2754
|
return ka < kb ? -1 : ka > kb ? 1 : 0;
|
|
2738
2755
|
});
|
|
2739
2756
|
}
|
|
@@ -3967,6 +3984,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
3967
3984
|
const nestedSubPaths = [...new Set([...nestedUnordered ?? [], ...schema.unorderedObjectArrayPaths ?? []].filter((p) => p.startsWith(`${k}.`)).map((p) => p.slice(k.length + 1)))];
|
|
3968
3985
|
let declaredVal = v;
|
|
3969
3986
|
let liveVal = live[k];
|
|
3987
|
+
let declaredRemapSource;
|
|
3970
3988
|
if (subsetSpec && Array.isArray(v) && Array.isArray(live[k])) {
|
|
3971
3989
|
const { idField, normalizeId } = subsetSpec;
|
|
3972
3990
|
const idOf = (e) => {
|
|
@@ -4014,8 +4032,11 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
4014
4032
|
declaredVal = declaredSorted;
|
|
4015
4033
|
liveVal = liveAligned;
|
|
4016
4034
|
} else if (unorderedObjArray) {
|
|
4017
|
-
|
|
4018
|
-
|
|
4035
|
+
const declaredNestedSorted = nestedSubPaths.length > 0 ? sortNestedObjectArrays(v, nestedSubPaths) : v;
|
|
4036
|
+
const idField = UNORDERED_OBJECT_ARRAY_IDENTITY[resourceType]?.[k];
|
|
4037
|
+
declaredVal = sortUnorderedObjectArray(declaredNestedSorted, idField);
|
|
4038
|
+
liveVal = sortUnorderedObjectArray(nestedSubPaths.length > 0 ? sortNestedObjectArrays(live[k], nestedSubPaths) : live[k], idField);
|
|
4039
|
+
if (Array.isArray(declaredNestedSorted)) declaredRemapSource = declaredNestedSorted;
|
|
4019
4040
|
} else if (nestedSubPaths.length > 0) {
|
|
4020
4041
|
declaredVal = sortNestedObjectArrays(v, nestedSubPaths);
|
|
4021
4042
|
liveVal = sortNestedObjectArrays(live[k], nestedSubPaths);
|
|
@@ -4091,8 +4112,8 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
4091
4112
|
if (INTELLIGENT_TIERING_PATHS[resourceType]?.has(d.path) && isIntelligentTieringMatch(d.stateValue, d.awsValue)) continue;
|
|
4092
4113
|
if ((UNORDERED_ARRAY_PROPS[resourceType]?.has(d.path) || UNORDERED_ARRAY_PROPS[resourceType]?.has(d.path.replace(/\.\d+(?=\.|$)/g, ".*")) || schema.unorderedScalarPaths?.includes(d.path)) && isEqualUnorderedScalarSet(d.stateValue, d.awsValue)) continue;
|
|
4093
4114
|
if (isTrivialEmpty(d.stateValue) && d.path in knownDef && deepEqual(d.awsValue, knownDef[d.path])) continue;
|
|
4094
|
-
const unorderedExtra = unorderedObjArray && Array.isArray(declaredVal) &&
|
|
4095
|
-
path: remapSortedIndexToDeclared(d.path, k, declaredVal,
|
|
4115
|
+
const unorderedExtra = unorderedObjArray && Array.isArray(declaredVal) && declaredRemapSource ? {
|
|
4116
|
+
path: remapSortedIndexToDeclared(d.path, k, declaredVal, declaredRemapSource),
|
|
4096
4117
|
wholeArrayRevert: {
|
|
4097
4118
|
path: k,
|
|
4098
4119
|
value: v
|