cdk-real-drift 0.12.61 → 0.12.63
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 +131 -13
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5942,6 +5942,86 @@ function remapSortedIndexToDeclared(path, arrayKey, sortedDeclared, rawDeclared)
|
|
|
5942
5942
|
const rawIdx = rawDeclared.findIndex((e) => deepEqual(e, el));
|
|
5943
5943
|
return rawIdx < 0 ? path : `${arrayKey}.${rawIdx}${m[2]}`;
|
|
5944
5944
|
}
|
|
5945
|
+
const S3_NOTIF_FILTER_RULE_NAMES = {
|
|
5946
|
+
prefix: "prefix",
|
|
5947
|
+
suffix: "suffix",
|
|
5948
|
+
Prefix: "prefix",
|
|
5949
|
+
Suffix: "suffix"
|
|
5950
|
+
};
|
|
5951
|
+
function canonS3NotifFilter(filter) {
|
|
5952
|
+
if (!filter || typeof filter !== "object") return filter;
|
|
5953
|
+
const f = filter;
|
|
5954
|
+
const inner = f.S3Key ?? f.Key;
|
|
5955
|
+
if (!inner || typeof inner !== "object") return filter;
|
|
5956
|
+
const rulesRaw = inner.Rules ?? inner.FilterRules;
|
|
5957
|
+
return { S3Key: { Rules: Array.isArray(rulesRaw) ? sortUnorderedObjectArray(rulesRaw.map((r) => {
|
|
5958
|
+
if (!r || typeof r !== "object") return r;
|
|
5959
|
+
const rule = r;
|
|
5960
|
+
const name = rule.Name;
|
|
5961
|
+
return {
|
|
5962
|
+
...rule,
|
|
5963
|
+
Name: typeof name === "string" ? S3_NOTIF_FILTER_RULE_NAMES[name] ?? name : name
|
|
5964
|
+
};
|
|
5965
|
+
})) : rulesRaw } };
|
|
5966
|
+
}
|
|
5967
|
+
function translateBucketNotificationConfigs(configs, arnKey, targetKey) {
|
|
5968
|
+
if (!Array.isArray(configs)) return [];
|
|
5969
|
+
const out = [];
|
|
5970
|
+
for (const c of configs) {
|
|
5971
|
+
if (!c || typeof c !== "object") {
|
|
5972
|
+
out.push(c);
|
|
5973
|
+
continue;
|
|
5974
|
+
}
|
|
5975
|
+
const { Events, Filter, [arnKey]: arn, ...rest } = c;
|
|
5976
|
+
const base = { ...rest };
|
|
5977
|
+
if (arn !== void 0) base[targetKey] = arn;
|
|
5978
|
+
if (Filter !== void 0) base.Filter = canonS3NotifFilter(Filter);
|
|
5979
|
+
const events = Array.isArray(Events) ? Events : Events !== void 0 ? [Events] : void 0;
|
|
5980
|
+
if (events && events.length > 0) for (const ev of events) out.push({
|
|
5981
|
+
...base,
|
|
5982
|
+
Event: ev
|
|
5983
|
+
});
|
|
5984
|
+
else out.push(base);
|
|
5985
|
+
}
|
|
5986
|
+
return out;
|
|
5987
|
+
}
|
|
5988
|
+
function canonS3NotifBucketConfig(config) {
|
|
5989
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) return config;
|
|
5990
|
+
const c = config;
|
|
5991
|
+
const out = { ...c };
|
|
5992
|
+
for (const key of [
|
|
5993
|
+
"LambdaConfigurations",
|
|
5994
|
+
"QueueConfigurations",
|
|
5995
|
+
"TopicConfigurations"
|
|
5996
|
+
]) {
|
|
5997
|
+
const arr = c[key];
|
|
5998
|
+
if (!Array.isArray(arr)) continue;
|
|
5999
|
+
out[key] = sortUnorderedObjectArray(arr.map((entry) => {
|
|
6000
|
+
if (!entry || typeof entry !== "object") return entry;
|
|
6001
|
+
const e = entry;
|
|
6002
|
+
return "Filter" in e ? {
|
|
6003
|
+
...e,
|
|
6004
|
+
Filter: canonS3NotifFilter(e.Filter)
|
|
6005
|
+
} : e;
|
|
6006
|
+
}));
|
|
6007
|
+
}
|
|
6008
|
+
return out;
|
|
6009
|
+
}
|
|
6010
|
+
function translateDeclaredBucketNotification(declaredConfig) {
|
|
6011
|
+
const out = {};
|
|
6012
|
+
if ("EventBridgeConfiguration" in declaredConfig) out.EventBridgeConfiguration = declaredConfig.EventBridgeConfiguration;
|
|
6013
|
+
const lambda = translateBucketNotificationConfigs(declaredConfig.LambdaFunctionConfigurations ?? declaredConfig.LambdaConfigurations, "LambdaFunctionArn", "Function");
|
|
6014
|
+
if (lambda.length > 0) out.LambdaConfigurations = lambda;
|
|
6015
|
+
const queue = translateBucketNotificationConfigs(declaredConfig.QueueConfigurations, "QueueArn", "Queue");
|
|
6016
|
+
if (queue.length > 0) out.QueueConfigurations = queue;
|
|
6017
|
+
const topic = translateBucketNotificationConfigs(declaredConfig.TopicConfigurations, "TopicArn", "Topic");
|
|
6018
|
+
if (topic.length > 0) out.TopicConfigurations = topic;
|
|
6019
|
+
for (const [k, v] of Object.entries(declaredConfig)) {
|
|
6020
|
+
if (k === "EventBridgeConfiguration" || k === "LambdaFunctionConfigurations" || k === "LambdaConfigurations" || k === "QueueConfigurations" || k === "TopicConfigurations") continue;
|
|
6021
|
+
out[k] = v;
|
|
6022
|
+
}
|
|
6023
|
+
return out;
|
|
6024
|
+
}
|
|
5945
6025
|
function expandExecuteApiResources(policy, arnPrefix) {
|
|
5946
6026
|
if (!policy || typeof policy !== "object" || Array.isArray(policy)) return policy;
|
|
5947
6027
|
const p = policy;
|
|
@@ -6131,7 +6211,9 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6131
6211
|
const selfDeclared = declaresTarget(declared.InstanceId) || declaresTarget(declared.NetworkInterfaceId);
|
|
6132
6212
|
if (explained || selfDeclared) delete live.NetworkInterfaceId;
|
|
6133
6213
|
}
|
|
6134
|
-
if (resourceType === "AWS::S3::Bucket" && physicalId && opts.bucketNotificationManaged?.has(physicalId) && !("NotificationConfiguration" in declared))
|
|
6214
|
+
if (resourceType === "AWS::S3::Bucket" && physicalId && opts.bucketNotificationManaged?.has(physicalId) && !("NotificationConfiguration" in declared)) {
|
|
6215
|
+
if (deepEqual(canonicalizeForCompare(canonS3NotifBucketConfig(translateDeclaredBucketNotification(opts.bucketNotificationConfigs?.[physicalId] ?? {})), resourceType), canonicalizeForCompare(canonS3NotifBucketConfig(live.NotificationConfiguration), resourceType))) delete live.NotificationConfiguration;
|
|
6216
|
+
}
|
|
6135
6217
|
const echoSpec = CLUSTER_ECHO_CHILD[resourceType];
|
|
6136
6218
|
const echoModel = echoSpec && physicalId ? opts.clusterEchoModel?.[physicalId] : void 0;
|
|
6137
6219
|
if (echoSpec && echoModel) for (const k of Object.keys(live)) {
|
|
@@ -9687,6 +9769,24 @@ const readEc2Eip = async ({ physicalId, region }) => {
|
|
|
9687
9769
|
if (tags && tags.length > 0) model.Tags = tags;
|
|
9688
9770
|
return model;
|
|
9689
9771
|
};
|
|
9772
|
+
const resolveEc2EipCcIdentifier = async (physicalId, region) => {
|
|
9773
|
+
const id = str$1(physicalId);
|
|
9774
|
+
if (!id || !region) return void 0;
|
|
9775
|
+
try {
|
|
9776
|
+
const c = new EC2Client({
|
|
9777
|
+
region,
|
|
9778
|
+
...READ_RETRY
|
|
9779
|
+
});
|
|
9780
|
+
const input = id.startsWith("eipalloc-") ? { AllocationIds: [id] } : { PublicIps: [id] };
|
|
9781
|
+
const addr = (await c.send(new DescribeAddressesCommand(input))).Addresses?.[0];
|
|
9782
|
+
const publicIp = str$1(addr?.PublicIp);
|
|
9783
|
+
const allocationId = str$1(addr?.AllocationId);
|
|
9784
|
+
if (!publicIp || !allocationId) return void 0;
|
|
9785
|
+
return `${publicIp}|${allocationId}`;
|
|
9786
|
+
} catch {
|
|
9787
|
+
return;
|
|
9788
|
+
}
|
|
9789
|
+
};
|
|
9690
9790
|
const dimSetEqual = (a, b) => {
|
|
9691
9791
|
const norm = (v) => JSON.stringify((Array.isArray(v) ? v : []).map((d) => [str$1(d.Name) ?? "", str$1(d.Value) ?? ""]).sort((x, y) => x[0] === y[0] ? x[1].localeCompare(y[1]) : x[0].localeCompare(y[0])));
|
|
9692
9792
|
return norm(a) === norm(b);
|
|
@@ -11994,7 +12094,8 @@ const CC_IDENTIFIER_ADAPTERS = {
|
|
|
11994
12094
|
const { partition } = partitionForRegion(region);
|
|
11995
12095
|
return `arn:${partition}:events:${region}:${account}:rule/${busName}/${ruleName}`;
|
|
11996
12096
|
}
|
|
11997
|
-
}
|
|
12097
|
+
},
|
|
12098
|
+
"AWS::EC2::EIP": (physicalId, _declared, region) => resolveEc2EipCcIdentifier(physicalId, region ?? "")
|
|
11998
12099
|
};
|
|
11999
12100
|
function scalingPolicyComposite(pid, declared) {
|
|
12000
12101
|
if (pid.includes("|")) return pid;
|
|
@@ -12047,7 +12148,7 @@ async function readLive(cc, resource, region, accountId) {
|
|
|
12047
12148
|
return { skippedReason: `SDK override (${resourceType}): ${e.name}` };
|
|
12048
12149
|
}
|
|
12049
12150
|
try {
|
|
12050
|
-
const identifier = CC_IDENTIFIER_ADAPTERS[resourceType]?.(physicalId ?? "", declared, region, accountId) ?? physicalId ?? "";
|
|
12151
|
+
const identifier = await CC_IDENTIFIER_ADAPTERS[resourceType]?.(physicalId ?? "", declared, region, accountId) ?? physicalId ?? "";
|
|
12051
12152
|
const g = await cc.send(new GetResourceCommand({
|
|
12052
12153
|
TypeName: resourceType,
|
|
12053
12154
|
Identifier: identifier
|
|
@@ -12280,22 +12381,33 @@ function buildSiblingEventBusPolicies(desired) {
|
|
|
12280
12381
|
return map;
|
|
12281
12382
|
}
|
|
12282
12383
|
const S3_NOTIFICATIONS_CR_TYPE = "Custom::S3BucketNotifications";
|
|
12283
|
-
function
|
|
12384
|
+
function resolveBucketNotificationCrs(desired) {
|
|
12284
12385
|
const byLogicalId = /* @__PURE__ */ new Map();
|
|
12285
12386
|
for (const r of desired.resources) if (r.physicalId) byLogicalId.set(r.logicalId, r.physicalId);
|
|
12286
|
-
const
|
|
12387
|
+
const out = [];
|
|
12287
12388
|
for (const r of desired.resources) {
|
|
12288
12389
|
if (r.resourceType !== S3_NOTIFICATIONS_CR_TYPE) continue;
|
|
12289
12390
|
const decl = r.declared;
|
|
12290
12391
|
if (!decl || typeof decl !== "object") continue;
|
|
12291
|
-
const
|
|
12292
|
-
|
|
12392
|
+
const d = decl;
|
|
12393
|
+
const bucketName = d.BucketName;
|
|
12394
|
+
const rawConfig = d.NotificationConfiguration;
|
|
12395
|
+
const config = rawConfig && typeof rawConfig === "object" && !Array.isArray(rawConfig) ? rawConfig : {};
|
|
12396
|
+
if (typeof bucketName === "string" && bucketName) out.push([bucketName, config]);
|
|
12293
12397
|
else if (bucketName && typeof bucketName === "object" && "Ref" in bucketName) {
|
|
12294
12398
|
const phys = byLogicalId.get(bucketName.Ref);
|
|
12295
|
-
if (phys)
|
|
12399
|
+
if (phys) out.push([phys, config]);
|
|
12296
12400
|
}
|
|
12297
12401
|
}
|
|
12298
|
-
return
|
|
12402
|
+
return out;
|
|
12403
|
+
}
|
|
12404
|
+
function buildBucketNotificationManaged(desired) {
|
|
12405
|
+
return new Set(resolveBucketNotificationCrs(desired).map(([phys]) => phys));
|
|
12406
|
+
}
|
|
12407
|
+
function buildBucketNotificationConfigs(desired) {
|
|
12408
|
+
const out = {};
|
|
12409
|
+
for (const [phys, config] of resolveBucketNotificationCrs(desired)) out[phys] = config;
|
|
12410
|
+
return out;
|
|
12299
12411
|
}
|
|
12300
12412
|
const MANAGED_POLICY_TYPE = "AWS::IAM::ManagedPolicy";
|
|
12301
12413
|
const MANAGED_POLICY_ATTACH_SIDES = [
|
|
@@ -12691,6 +12803,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
12691
12803
|
siblingEipAssociations: buildSiblingEipAssociations(desired),
|
|
12692
12804
|
siblingTargetGroupRegistrars: buildSiblingTargetGroupRegistrars(desired),
|
|
12693
12805
|
bucketNotificationManaged: buildBucketNotificationManaged(desired),
|
|
12806
|
+
bucketNotificationConfigs: buildBucketNotificationConfigs(desired),
|
|
12694
12807
|
clusterEchoModel: buildClusterEchoModels(desired),
|
|
12695
12808
|
rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
|
|
12696
12809
|
};
|
|
@@ -12761,6 +12874,7 @@ async function regatherTouched(gathered, touched, region) {
|
|
|
12761
12874
|
siblingEipAssociations: buildSiblingEipAssociations(desired),
|
|
12762
12875
|
siblingTargetGroupRegistrars: buildSiblingTargetGroupRegistrars(desired),
|
|
12763
12876
|
bucketNotificationManaged: buildBucketNotificationManaged(desired),
|
|
12877
|
+
bucketNotificationConfigs: buildBucketNotificationConfigs(desired),
|
|
12764
12878
|
clusterEchoModel: buildClusterEchoModels(desired),
|
|
12765
12879
|
rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
|
|
12766
12880
|
};
|
|
@@ -16152,7 +16266,11 @@ const SYNTHETIC_READ_SIGNAL_PATHS = {
|
|
|
16152
16266
|
"AWS::Lambda::Function": ["CodeSha256"],
|
|
16153
16267
|
"AWS::Glue::Job": ["ScriptSha256"]
|
|
16154
16268
|
};
|
|
16155
|
-
const CC_REVERTABLE_DESPITE_READ_OVERRIDE = new Set([
|
|
16269
|
+
const CC_REVERTABLE_DESPITE_READ_OVERRIDE = new Set([
|
|
16270
|
+
"AWS::Scheduler::Schedule",
|
|
16271
|
+
"AWS::Cognito::IdentityPool",
|
|
16272
|
+
"AWS::EC2::EIP"
|
|
16273
|
+
]);
|
|
16156
16274
|
const REVERT_SET_DEFAULT_PATHS = new Set([
|
|
16157
16275
|
"AWS::IAM::Role\0MaxSessionDuration",
|
|
16158
16276
|
"AWS::IAM::Role\0Description",
|
|
@@ -16346,7 +16464,7 @@ function isUnderCreateOnly(findingPath, createOnlyPaths) {
|
|
|
16346
16464
|
}
|
|
16347
16465
|
return false;
|
|
16348
16466
|
}
|
|
16349
|
-
const CC_DELETE_UNSUPPORTED_ADDED_TYPES = new Set(["AWS::EC2::NetworkAclEntry"]);
|
|
16467
|
+
const CC_DELETE_UNSUPPORTED_ADDED_TYPES = new Set(["AWS::EC2::NetworkAclEntry", "AWS::Route53::RecordSet"]);
|
|
16350
16468
|
function buildRevertPlan(findings, baseline, opts = {}) {
|
|
16351
16469
|
const itemsByLogical = /* @__PURE__ */ new Map();
|
|
16352
16470
|
const notRevertable = [];
|
|
@@ -17776,7 +17894,7 @@ async function revertStack(p) {
|
|
|
17776
17894
|
try {
|
|
17777
17895
|
const writer = resolveSdkWriter(item.resourceType, item.ops);
|
|
17778
17896
|
if (!writer) throw new Error(`no SDK writer for ${item.resourceType}`);
|
|
17779
|
-
const identifier = CC_IDENTIFIER_ADAPTERS[item.resourceType]?.(item.physicalId, res?.declared ?? {}, region, gathered.desired.accountId) ?? item.physicalId;
|
|
17897
|
+
const identifier = await CC_IDENTIFIER_ADAPTERS[item.resourceType]?.(item.physicalId, res?.declared ?? {}, region, gathered.desired.accountId) ?? item.physicalId;
|
|
17780
17898
|
await writer({
|
|
17781
17899
|
physicalId: item.physicalId,
|
|
17782
17900
|
identifier,
|
|
@@ -17795,7 +17913,7 @@ async function revertStack(p) {
|
|
|
17795
17913
|
}, buildRetryOpts(item.displayId));
|
|
17796
17914
|
} else {
|
|
17797
17915
|
const res = resByLogical.get(item.logicalId);
|
|
17798
|
-
r = await applyRevertItem(cc, item, CC_IDENTIFIER_ADAPTERS[item.resourceType]?.(item.physicalId, res?.declared ?? {}, region, gathered.desired.accountId) ?? item.physicalId, buildRetryOpts(item.displayId));
|
|
17916
|
+
r = await applyRevertItem(cc, item, await CC_IDENTIFIER_ADAPTERS[item.resourceType]?.(item.physicalId, res?.declared ?? {}, region, gathered.desired.accountId) ?? item.physicalId, buildRetryOpts(item.displayId));
|
|
17799
17917
|
}
|
|
17800
17918
|
applied.push({
|
|
17801
17919
|
logicalId: item.logicalId,
|