A database or instance is given a public address that the internet can reach
What it finds
A database with publiclyAccessible: true, or an instance with a public IP address, can be reached from anywhere the security groups allow. Keeping them in private subnets behind a load balancer or bastion removes that exposure.
Reported are publiclyAccessible: true and associatePublicIpAddress: true in the properties of constructs, in files that use the CDK.
From the rule's source, publicly_accessible_resource.rs.
import * as rds from "aws-cdk-lib/aws-rds";declare const stack: any;declare const engine: any;export const db = new rds.DatabaseInstance(stack, "Db", { engine, publiclyAccessible: true });tx0 reports: publiclyAccessible makes this resource reachable Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:publicly-accessible-resource" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:publicly-accessible-resource] reason="..."tx0 explain tx0/ts:publicly-accessible-resource shows the same in the terminal. Found a false positive? Report it.