cdk-real-drift 0.12.97 → 0.12.98
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 +7 -3
- package/dist/cli.js +43 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -288,8 +288,10 @@ needs `--remove-unrecorded`).
|
|
|
288
288
|
- **AppSync**: data sources, resolvers, functions
|
|
289
289
|
- **CloudWatch Logs**: metric filters, subscription filters
|
|
290
290
|
- **ELBv2**: listeners, listener rules
|
|
291
|
-
- **EC2**: VPC subnets, VPC endpoints, VPC route tables, VPC network ACLs,
|
|
292
|
-
|
|
291
|
+
- **EC2**: VPC subnets, VPC endpoints, VPC route tables, VPC network ACLs, VPC
|
|
292
|
+
security groups (an out-of-band `create-security-group` — a rogue firewall in a
|
|
293
|
+
declared VPC; the VPC default SG and AWS-service-created SGs, e.g. an EKS cluster
|
|
294
|
+
SG, are folded so only a user-created group surfaces), route table routes
|
|
293
295
|
- **ECS**: cluster services
|
|
294
296
|
- **KMS**: key aliases, key grants (an out-of-band `kms create-grant` on a key —
|
|
295
297
|
grants are not a CloudFormation type, so cdkrd surfaces them as a synthetic
|
|
@@ -1020,7 +1022,9 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
1020
1022
|
- `AWS::EC2::VPC` + `AWS::EC2::RouteTable`: `ec2:DescribeSubnets`,
|
|
1021
1023
|
`ec2:DescribeRouteTables` (plus `ec2:DescribeInternetGateways` and
|
|
1022
1024
|
`ec2:DescribeVpcs` for the VPC's out-of-band IGW attachment and secondary
|
|
1023
|
-
CIDR sub-resources
|
|
1025
|
+
CIDR sub-resources, and `ec2:DescribeSecurityGroups` for a VPC's out-of-band
|
|
1026
|
+
security groups — a rogue `AWS::EC2::SecurityGroup`; the default SG and
|
|
1027
|
+
AWS-service-created SGs are folded)
|
|
1024
1028
|
- `AWS::EC2::NetworkAcl`: `ec2:DescribeNetworkAcls` (enumerates a declared
|
|
1025
1029
|
NACL's out-of-band entries — a rogue `AWS::EC2::NetworkAclEntry`)
|
|
1026
1030
|
- `AWS::ECS::Cluster`: `ecs:ListServices` (distinct from the
|
package/dist/cli.js
CHANGED
|
@@ -9544,6 +9544,39 @@ function diffVpcCidrBlockChildren(input) {
|
|
|
9544
9544
|
}
|
|
9545
9545
|
return added;
|
|
9546
9546
|
}
|
|
9547
|
+
function isAwsManagedSecurityGroup(tags) {
|
|
9548
|
+
return (tags ?? []).some((t) => typeof t.Key === "string" && (t.Key.startsWith("aws:") || t.Key.startsWith("kubernetes.io/cluster/")));
|
|
9549
|
+
}
|
|
9550
|
+
function diffVpcSecurityGroupChildren(input) {
|
|
9551
|
+
const declared = new Set(input.declaredSecurityGroupIds);
|
|
9552
|
+
const added = [];
|
|
9553
|
+
for (const g of input.liveSecurityGroups) {
|
|
9554
|
+
if (declared.has(g.id)) continue;
|
|
9555
|
+
added.push({
|
|
9556
|
+
resourceType: "AWS::EC2::SecurityGroup",
|
|
9557
|
+
identifier: g.id,
|
|
9558
|
+
label: g.label ?? g.id,
|
|
9559
|
+
live: { Id: g.id }
|
|
9560
|
+
});
|
|
9561
|
+
}
|
|
9562
|
+
return added;
|
|
9563
|
+
}
|
|
9564
|
+
async function pageSecurityGroups(client, vpcId) {
|
|
9565
|
+
const out = [];
|
|
9566
|
+
let next;
|
|
9567
|
+
do {
|
|
9568
|
+
const res = await client.send(new DescribeSecurityGroupsCommand({
|
|
9569
|
+
Filters: [{
|
|
9570
|
+
Name: "vpc-id",
|
|
9571
|
+
Values: [vpcId]
|
|
9572
|
+
}],
|
|
9573
|
+
NextToken: next
|
|
9574
|
+
}));
|
|
9575
|
+
out.push(...res.SecurityGroups ?? []);
|
|
9576
|
+
next = res.NextToken;
|
|
9577
|
+
} while (next);
|
|
9578
|
+
return out;
|
|
9579
|
+
}
|
|
9547
9580
|
async function pageSubnets(client, vpcId) {
|
|
9548
9581
|
const out = [];
|
|
9549
9582
|
let next;
|
|
@@ -9635,12 +9668,14 @@ async function enumerateVpcChildren(ctx) {
|
|
|
9635
9668
|
const declaredEndpointIds = [];
|
|
9636
9669
|
const declaredRouteTableIds = [];
|
|
9637
9670
|
const declaredNaclIds = [];
|
|
9671
|
+
const declaredSecurityGroupIds = [];
|
|
9638
9672
|
for (const r of desired.resources) {
|
|
9639
9673
|
if (!parentRefMatches(r.declared.VpcId, vpcId) || !r.physicalId) continue;
|
|
9640
9674
|
if (r.resourceType === "AWS::EC2::Subnet") declaredSubnetIds.push(r.physicalId);
|
|
9641
9675
|
else if (r.resourceType === "AWS::EC2::VPCEndpoint") declaredEndpointIds.push(r.physicalId);
|
|
9642
9676
|
else if (r.resourceType === "AWS::EC2::RouteTable") declaredRouteTableIds.push(r.physicalId);
|
|
9643
9677
|
else if (r.resourceType === "AWS::EC2::NetworkAcl") declaredNaclIds.push(r.physicalId);
|
|
9678
|
+
else if (r.resourceType === "AWS::EC2::SecurityGroup") declaredSecurityGroupIds.push(r.physicalId);
|
|
9644
9679
|
}
|
|
9645
9680
|
const declaredAssociationIds = [];
|
|
9646
9681
|
let hasDeclaredIgwAttachment = false;
|
|
@@ -9697,6 +9732,10 @@ async function enumerateVpcChildren(ctx) {
|
|
|
9697
9732
|
cidr: b.Ipv6CidrBlock
|
|
9698
9733
|
});
|
|
9699
9734
|
}
|
|
9735
|
+
const liveSecurityGroups = (await pageSecurityGroups(client, vpcId)).filter((g) => typeof g.GroupId === "string" && g.GroupName !== "default" && !isAwsManagedSecurityGroup(g.Tags)).map((g) => ({
|
|
9736
|
+
id: g.GroupId,
|
|
9737
|
+
label: g.GroupName ?? g.GroupId
|
|
9738
|
+
}));
|
|
9700
9739
|
return [
|
|
9701
9740
|
...diffVpcChildren({
|
|
9702
9741
|
declaredSubnetIds,
|
|
@@ -9727,6 +9766,10 @@ async function enumerateVpcChildren(ctx) {
|
|
|
9727
9766
|
vpcId,
|
|
9728
9767
|
declaredCidrs,
|
|
9729
9768
|
liveCidrBlocks
|
|
9769
|
+
}),
|
|
9770
|
+
...diffVpcSecurityGroupChildren({
|
|
9771
|
+
declaredSecurityGroupIds,
|
|
9772
|
+
liveSecurityGroups
|
|
9730
9773
|
})
|
|
9731
9774
|
];
|
|
9732
9775
|
}
|