Skip to main content

Shift Left Database Security: Roles, Permissions, and Policies as Code

Most teams treat database security as something that happens outside the software development lifecycle. Roles, GRANT / REVOKE statements, and row-level security policies are applied directly to the database through one-off scripts or runbooks. They are rarely reviewed alongside the application code that depends on them or tested against a real instance, leading to drift from environment to environment.

Atlas closes that gap. Roles, users, permissions, default privileges, and row-level security policies are defined as code, stored in version control, planned automatically, validated in CI, and applied to your databases through the same workflow as the rest of your schema. Security moves left into the pull request, where it can be reviewed and tested before it reaches production.

Supported Workflows

Atlas manages security objects through the same two workflows it uses for the rest of the schema, in either Atlas HCL or plain SQL. Pick the one that matches how the rest of your migrations are managed.

Get Started by Database

Atlas supports security as code for the most common open-source and cloud databases. Each guide walks through configuring atlas.hcl, defining roles and permissions in HCL or SQL, and applying changes safely. Atlas understands database-specific concepts: cloud-managed roles on RDS and Cloud SQL, row-level security on PostgreSQL, row policies and quotas on ClickHouse, login-mapped users on SQL Server, and more.

Schema HCL Definitions

Roles, users, permissions, and policies can be authored in either Atlas HCL or plain SQL. Use the references below to look up the exact syntax for each block.

IAM Authentication

Cloud-managed databases let Atlas authenticate with short-lived IAM tokens instead of static passwords. Define a data source in atlas.hcl and reference its output in your connection URL.

Policies as Code

Database security in 2026 has new dimensions that did not exist five years ago. AI coding assistants like Cursor, Claude Code, and GitHub Copilot now write schema changes directly, and the files they generate are merged faster than any human review cycle can keep up with. At the same time, audit frameworks (SOC 2, ISO 27002, PCI-DSS, HIPAA) expect evidence that every database change was reviewed, approved, and traceable to a person, which is exactly what manual review at AI speed cannot deliver.

Atlas turns each of these concerns into a policy that lives in your repo, runs in CI, and produces an audit trail by default.