Infrastructure as Code (IaC) makes it easy to define and deploy cloud resources. But what happens when the code drifts from reality? IaC drift detection is the process of identifying differences between your declared configuration and the actual state of your system. Without it, hidden changes can bypass review and break compliance.
Row-Level Security (RLS) adds another layer. This is where the stakes intensify. RLS controls which data rows each user can see in a database query. It enforces data boundaries at query time. If RLS rules drift—through untracked changes in PostgreSQL policies, schema updates, or permission grants—you lose the guarantee that users only see what they should.
Traditional IaC drift detection focuses on infrastructure: networks, containers, storage. But for RLS, detection must drill into database policies. You must capture the state of CREATE POLICY definitions, role grants, and default privileges. Then compare these to your IaC manifests. This comparison should run automatically, on every deploy, and periodically in production.
The process: