How to Configure Mastra Redshift Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up mastra redshift read only access by creating a dedicated database role. You then grant select rights on specific schemas and pass those credentials to your agent. Teams often start by reusing a broad admin user for speed. That shortcut lets an automated workflow alter tables or read every private column. How mastra redshift read only access works in your architecture Mastra runs as an agent framework that executes tools and workflows on a schedule. When an agent needs data, it call

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 mastra redshift read only access by creating a dedicated database role. You then grant select rights on specific schemas and pass those credentials to your agent. Teams often start by reusing a broad admin user for speed. That shortcut lets an automated workflow alter tables or read every private column.

How mastra redshift read only access works in your architecture

Mastra runs as an agent framework that executes tools and workflows on a schedule. When an agent needs data, it calls a tool that talks to Amazon Redshift. The database checks the user role before it runs any query.

To keep the data warehouse safe, admins build a dedicated read role in Redshift. First, the admin grants usage on the target schema to this new role. Next, the admin grants select rights on the tables the agent needs. The admin also updates default privileges so future tables inherit the same read rule.

Once the role is ready, the team creates a database user for the agent. They assign the read role to this user and store the login details securely. The Mastra workflow reads these details from secret storage when the app starts. Each time the agent builds a query, it opens a session with those restricted rights.

What database roles solve and what they leave open

Native database roles stop agents from dropping tables or changing rows. If a prompt causes the agent to send a delete statement, Redshift blocks it. This setup protects data integrity across your analytics tables.

Still, a database role only checks who logs in and which tables they read. It does not inspect what individual queries do in flight. Once a session starts, the agent can read every column in an allowed table. If a customer table holds emails, phone numbers, or card numbers, the query returns them. Those raw values then flow straight into the model prompt and external logs.

Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static roles also struggle with shared agent identities. Many workflows run under one service account in production. When a bad query slows down the cluster, the database log only shows the shared user. Platform teams cannot tell which user request or workflow triggered the heavy query. Managing separate database users for every single agent task adds heavy work for admins.

How to scope agent queries and protect sensitive columns

A strong setup pairs native database roles with query controls during the session. Start by limiting the database role to the exact views required for the task. Avoid granting select rights on whole schemas when the agent only needs two tables.

You also need a way to handle sensitive columns during query execution. Data masking rewrites matched fields like emails or national IDs in the query results. This step happens before the rows reach the agent or the language model. Teams also link each agent query to the specific workflow run that started it. Clear audit logs help engineers fix slow queries and pass security reviews fast.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can a Mastra agent still read new tables added to a schema?

Only if you set default privileges on the schema for that database role. Without that rule, an admin must grant select rights on each new table by hand.

Does a read-only role hide sensitive customer columns from the agent?

No, standard table grants allow the user to read every column in that table by default. You must use column-level grants, narrow views, or dynamic data masking to rewrite fields like card numbers.

How do we stop an agent from running huge queries on Redshift?

Assign the agent user to a separate workload management queue in Redshift. You can set query timeout rules and row limits on that queue to protect cluster speed.

The query runs. The emails stay hidden.