cdk-real-drift 0.9.8 → 0.9.10
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 +2 -1
- package/dist/cli.js +137 -7
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -283,7 +283,8 @@ snapshots its full live model and watches it, `ignore` accepts it, or `revert`
|
|
|
283
283
|
- **AppSync**: data sources, resolvers, functions
|
|
284
284
|
- **CloudWatch Logs**: metric filters, subscription filters
|
|
285
285
|
- **ELBv2**: listeners, listener rules
|
|
286
|
-
- **EC2**: VPC subnets, VPC endpoints, route
|
|
286
|
+
- **EC2**: VPC subnets, VPC endpoints, VPC route tables, VPC network ACLs, route
|
|
287
|
+
table routes
|
|
287
288
|
- **ECS**: cluster services
|
|
288
289
|
- **KMS**: key aliases
|
|
289
290
|
- **AppConfig**: application environments, configuration profiles
|
package/dist/cli.js
CHANGED
|
@@ -5508,6 +5508,40 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
5508
5508
|
StorageType: storageDefault
|
|
5509
5509
|
};
|
|
5510
5510
|
}
|
|
5511
|
+
if (resourceType === "AWS::CE::AnomalySubscription") {
|
|
5512
|
+
const threshold = declared["Threshold"];
|
|
5513
|
+
if (typeof threshold === "number" && Number.isFinite(threshold)) {
|
|
5514
|
+
const decimal = Number.isInteger(threshold) ? `${threshold}.0` : String(threshold);
|
|
5515
|
+
knownDef = {
|
|
5516
|
+
...knownDef,
|
|
5517
|
+
ThresholdExpression: JSON.stringify({ Dimensions: {
|
|
5518
|
+
Key: "ANOMALY_TOTAL_IMPACT_ABSOLUTE",
|
|
5519
|
+
MatchOptions: ["GREATER_THAN_OR_EQUAL"],
|
|
5520
|
+
Values: [decimal]
|
|
5521
|
+
} })
|
|
5522
|
+
};
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5525
|
+
if (resourceType === "AWS::ElastiCache::ReplicationGroup" && declared["TransitEncryptionEnabled"] === true) knownDef = {
|
|
5526
|
+
...knownDef,
|
|
5527
|
+
TransitEncryptionMode: "required"
|
|
5528
|
+
};
|
|
5529
|
+
if (resourceType === "AWS::EC2::TransitGatewayRoute") {
|
|
5530
|
+
const rtb = declared["TransitGatewayRouteTableId"];
|
|
5531
|
+
const cidr = declared["DestinationCidrBlock"];
|
|
5532
|
+
if (typeof rtb === "string" && typeof cidr === "string") knownDef = {
|
|
5533
|
+
...knownDef,
|
|
5534
|
+
Id: `${rtb}_${cidr}`
|
|
5535
|
+
};
|
|
5536
|
+
}
|
|
5537
|
+
if (resourceType === "AWS::EC2::TransitGatewayRouteTableAssociation") {
|
|
5538
|
+
const attach = declared["TransitGatewayAttachmentId"];
|
|
5539
|
+
const rtb = declared["TransitGatewayRouteTableId"];
|
|
5540
|
+
if (typeof attach === "string" && typeof rtb === "string") knownDef = {
|
|
5541
|
+
...knownDef,
|
|
5542
|
+
Id: `${attach}_${rtb}`
|
|
5543
|
+
};
|
|
5544
|
+
}
|
|
5511
5545
|
if (resourceType === "AWS::Lambda::EventSourceMapping") {
|
|
5512
5546
|
const arn = declared["EventSourceArn"];
|
|
5513
5547
|
const service = typeof arn === "string" ? arn.split(":")[2] : void 0;
|
|
@@ -6088,6 +6122,19 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6088
6122
|
});
|
|
6089
6123
|
continue;
|
|
6090
6124
|
}
|
|
6125
|
+
if (resourceType === "AWS::ElastiCache::ReplicationGroup" && k === "SnapshottingClusterId" && typeof v === "string") {
|
|
6126
|
+
const rgId = declared["ReplicationGroupId"] ?? physicalId;
|
|
6127
|
+
if (typeof rgId === "string" && new RegExp(`^${rgId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}-\\d{3}$`).test(v)) {
|
|
6128
|
+
findings.push({
|
|
6129
|
+
tier: "atDefault",
|
|
6130
|
+
logicalId,
|
|
6131
|
+
resourceType,
|
|
6132
|
+
path: k,
|
|
6133
|
+
actual: v
|
|
6134
|
+
});
|
|
6135
|
+
continue;
|
|
6136
|
+
}
|
|
6137
|
+
}
|
|
6091
6138
|
if (k in genDef && deepEqual(v, genDef[k])) {
|
|
6092
6139
|
findings.push({
|
|
6093
6140
|
tier: "generated",
|
|
@@ -7599,6 +7646,34 @@ function diffVpcEndpointChildren(input) {
|
|
|
7599
7646
|
}
|
|
7600
7647
|
return added;
|
|
7601
7648
|
}
|
|
7649
|
+
function diffVpcRouteTableChildren(input) {
|
|
7650
|
+
const declared = new Set(input.declaredRouteTableIds);
|
|
7651
|
+
const added = [];
|
|
7652
|
+
for (const rt of input.liveRouteTables) {
|
|
7653
|
+
if (declared.has(rt.id)) continue;
|
|
7654
|
+
added.push({
|
|
7655
|
+
resourceType: "AWS::EC2::RouteTable",
|
|
7656
|
+
identifier: rt.id,
|
|
7657
|
+
label: rt.label ?? rt.id,
|
|
7658
|
+
live: { RouteTableId: rt.id }
|
|
7659
|
+
});
|
|
7660
|
+
}
|
|
7661
|
+
return added;
|
|
7662
|
+
}
|
|
7663
|
+
function diffVpcNaclChildren(input) {
|
|
7664
|
+
const declared = new Set(input.declaredNaclIds);
|
|
7665
|
+
const added = [];
|
|
7666
|
+
for (const n of input.liveNacls) {
|
|
7667
|
+
if (declared.has(n.id)) continue;
|
|
7668
|
+
added.push({
|
|
7669
|
+
resourceType: "AWS::EC2::NetworkAcl",
|
|
7670
|
+
identifier: n.id,
|
|
7671
|
+
label: n.label ?? n.id,
|
|
7672
|
+
live: { Id: n.id }
|
|
7673
|
+
});
|
|
7674
|
+
}
|
|
7675
|
+
return added;
|
|
7676
|
+
}
|
|
7602
7677
|
async function pageSubnets(client, vpcId) {
|
|
7603
7678
|
const out = [];
|
|
7604
7679
|
let next;
|
|
@@ -7631,16 +7706,52 @@ async function pageVpcEndpoints(client, vpcId) {
|
|
|
7631
7706
|
} while (next);
|
|
7632
7707
|
return out;
|
|
7633
7708
|
}
|
|
7709
|
+
async function pageVpcRouteTables(client, vpcId) {
|
|
7710
|
+
const out = [];
|
|
7711
|
+
let next;
|
|
7712
|
+
do {
|
|
7713
|
+
const res = await client.send(new DescribeRouteTablesCommand({
|
|
7714
|
+
Filters: [{
|
|
7715
|
+
Name: "vpc-id",
|
|
7716
|
+
Values: [vpcId]
|
|
7717
|
+
}],
|
|
7718
|
+
NextToken: next
|
|
7719
|
+
}));
|
|
7720
|
+
out.push(...res.RouteTables ?? []);
|
|
7721
|
+
next = res.NextToken;
|
|
7722
|
+
} while (next);
|
|
7723
|
+
return out;
|
|
7724
|
+
}
|
|
7725
|
+
async function pageNetworkAcls(client, vpcId) {
|
|
7726
|
+
const out = [];
|
|
7727
|
+
let next;
|
|
7728
|
+
do {
|
|
7729
|
+
const res = await client.send(new DescribeNetworkAclsCommand({
|
|
7730
|
+
Filters: [{
|
|
7731
|
+
Name: "vpc-id",
|
|
7732
|
+
Values: [vpcId]
|
|
7733
|
+
}],
|
|
7734
|
+
NextToken: next
|
|
7735
|
+
}));
|
|
7736
|
+
out.push(...res.NetworkAcls ?? []);
|
|
7737
|
+
next = res.NextToken;
|
|
7738
|
+
} while (next);
|
|
7739
|
+
return out;
|
|
7740
|
+
}
|
|
7634
7741
|
async function enumerateVpcChildren(ctx) {
|
|
7635
7742
|
const { parent, desired, region } = ctx;
|
|
7636
7743
|
const vpcId = parent.physicalId;
|
|
7637
7744
|
if (!vpcId) return [];
|
|
7638
7745
|
const declaredSubnetIds = [];
|
|
7639
7746
|
const declaredEndpointIds = [];
|
|
7747
|
+
const declaredRouteTableIds = [];
|
|
7748
|
+
const declaredNaclIds = [];
|
|
7640
7749
|
for (const r of desired.resources) {
|
|
7641
7750
|
if (!parentRefMatches(r.declared.VpcId, vpcId) || !r.physicalId) continue;
|
|
7642
7751
|
if (r.resourceType === "AWS::EC2::Subnet") declaredSubnetIds.push(r.physicalId);
|
|
7643
7752
|
else if (r.resourceType === "AWS::EC2::VPCEndpoint") declaredEndpointIds.push(r.physicalId);
|
|
7753
|
+
else if (r.resourceType === "AWS::EC2::RouteTable") declaredRouteTableIds.push(r.physicalId);
|
|
7754
|
+
else if (r.resourceType === "AWS::EC2::NetworkAcl") declaredNaclIds.push(r.physicalId);
|
|
7644
7755
|
}
|
|
7645
7756
|
const client = new EC2Client({
|
|
7646
7757
|
region,
|
|
@@ -7654,13 +7765,32 @@ async function enumerateVpcChildren(ctx) {
|
|
|
7654
7765
|
id: e.VpcEndpointId,
|
|
7655
7766
|
label: e.ServiceName ?? e.VpcEndpointId
|
|
7656
7767
|
}));
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
})
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7768
|
+
const liveRouteTables = (await pageVpcRouteTables(client, vpcId)).filter((rt) => typeof rt.RouteTableId === "string").filter((rt) => !(rt.Associations ?? []).some((a) => a.Main === true)).map((rt) => ({
|
|
7769
|
+
id: rt.RouteTableId,
|
|
7770
|
+
label: rt.RouteTableId
|
|
7771
|
+
}));
|
|
7772
|
+
const liveNacls = (await pageNetworkAcls(client, vpcId)).filter((n) => typeof n.NetworkAclId === "string").filter((n) => n.IsDefault !== true).map((n) => ({
|
|
7773
|
+
id: n.NetworkAclId,
|
|
7774
|
+
label: n.NetworkAclId
|
|
7775
|
+
}));
|
|
7776
|
+
return [
|
|
7777
|
+
...diffVpcChildren({
|
|
7778
|
+
declaredSubnetIds,
|
|
7779
|
+
liveSubnets
|
|
7780
|
+
}),
|
|
7781
|
+
...diffVpcEndpointChildren({
|
|
7782
|
+
declaredEndpointIds,
|
|
7783
|
+
liveEndpoints
|
|
7784
|
+
}),
|
|
7785
|
+
...diffVpcRouteTableChildren({
|
|
7786
|
+
declaredRouteTableIds,
|
|
7787
|
+
liveRouteTables
|
|
7788
|
+
}),
|
|
7789
|
+
...diffVpcNaclChildren({
|
|
7790
|
+
declaredNaclIds,
|
|
7791
|
+
liveNacls
|
|
7792
|
+
})
|
|
7793
|
+
];
|
|
7664
7794
|
}
|
|
7665
7795
|
function diffRouteTableChildren(input) {
|
|
7666
7796
|
const { routeTableId, declaredCidrs, liveRoutes, hasUnresolvedDeclaredRoute } = input;
|