How to Configure Amazon Q SQL Server Audit Log
You set up an amazon q sql server audit log by tracking database logins and queries. You also pair those database logs with local agent command history on developer machines. Most engineering teams start by giving their coding assistant a standard database login. They often reuse an existing admin or read-write user to save time during setup. When roles are too broad, an AI agent can read or change any table. A basic database log will only show that the shared account ran a query. How the nati
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up an amazon q sql server audit log by tracking database logins and queries. You also pair those database logs with local agent command history on developer machines. Most engineering teams start by giving their coding assistant a standard database login. They often reuse an existing admin or read-write user to save time during setup. When roles are too broad, an AI agent can read or change any table. A basic database log will only show that the shared account ran a query.
How the native amazon q sql server audit log works
To track activity well, you first need to understand how SQL Server handles logins. A database user is the identity of a login when it connects to a database. For people who need many databases on an instance, a login in master is common. For one or a few databases, a contained database user with a password works well. An admin must first enable contained databases on both the server and the database. SQL Server supports thirteen types of database users for different access needs.
Once you create a dedicated user for the coding agent, you assign a role. SQL Server includes fixed database roles with permissions that cannot be changed. Every database role, including the public role, has permission to connect to the database. Members of the data reader role can read all data from all user tables. They can also read all user views across the database. Members of the data writer role can add, delete, or change data in tables. You can also use deny roles to block reading or writing on user tables. Meanwhile, the database owner role can run all maintenance tasks and drop the database.
When Amazon Q runs a database query, it uses the credentials from your local setup. The database engine records the login name and the statement in its native log. If you give the agent its own SQL user, the log shows that user name. You can then review the server audit file to see when that user logged in.
What native roles solve and what they leave open
Giving the AI agent a dedicated read-only role solves several basic security problems right away. It stops the assistant from dropping tables or changing rows by mistake during a task. It also separates agent traffic from human admin traffic inside your server audit records. If you add a deny role, you can block access to all user tables entirely.
Still, native database roles and server logs leave a big operational gap open. Database roles only decide who can log in and which broad actions they can take. They do not inspect what individual statements or commands do while they run in flight. For example, a user in the fixed data reader role can read every user table. That means the coding agent can still pull emails, phone numbers, or card numbers. The native audit log only tells you that a select query happened after the fact. It does not rewrite matched fields in results before they reach the AI model.
Audit Log Integrity + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why shared local credentials weaken your audit trail
Another problem comes from how AI coding agents run tools on a developer laptop. The agent often runs commands in a local shell using the developer's own environment variables. If five engineers share one test database login, the audit log shows one user name. You cannot tell which person prompted the agent to run a heavy or risky query. You also cannot tell if a human typed the query or the agent generated it.
Rotating those shared database passwords across every developer laptop takes a lot of manual work. Until you remove static keys from local shells, your database audit log remains incomplete. Teams need a way to tie every single statement back to a real human identity. They also need controls that check queries and mask sensitive fields like national IDs live.
Check SQL Server batches and results on the wire
SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server. It reads plain batches and parameterized queries on the TDS wire while passing Windows login through untouched.
Before a batch hits the server, hoop.dev guardrails check the statement against your rules. Disallowed actions get a native TDS error with your message. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns that match your rules. Every query and decision is logged. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Can I use a fixed database role to limit Amazon Q to one table?
No, the fixed data reader role grants read access to all user tables and views. The permissions assigned to fixed database roles in SQL Server cannot be changed.
Should I use a login in master or a contained user for an AI agent?
Use a contained database user if the agent only needs one or a few databases. Use a SQL user tied to a login in master if it needs many databases.
Do native SQL Server logs stop an AI agent from reading sensitive columns?
No, native audit logs only record database events for you to review after they run. They do not rewrite emails, phone numbers, or card numbers in query results in flight.
Related guides
In this post