Redshift Connector
A StrataBI Platform Module
Powered by Shaleio
Tier: Supported · module id redshift_connector · type multi_page_app (an app StrataBI renders from its own pages) · requires StrataBI · stands alone
Amazon Redshift data for StrataBI tiles. A Lambda runs named, parameterised queries through the Redshift Data API against a Redshift Serverless workgroup or a provisioned cluster and returns the result to the tile. No database drivers, no passwords in the function, no VPC attachment.
tile (inputs) → query Lambda → Redshift Data API (ExecuteStatement with parameters) → your workgroup or cluster
↑ │
└────────── DescribeStatement / GetStatementResult ←───────────────┘ → CSV → the tileInstall
- Choose the mode (the installer asks):
| Mode | Connects as |
|---|---|
serverless | the function's IAM role, on a workgroup (workgroup_name) |
cluster | the function's IAM role with temporary credentials, on a provisioned cluster (cluster_identifier) |
secret | a database user kept in AWS Secrets Manager (secret_arn) |
Give the target's ARN (target_arn) so the function's rights name exactly that workgroup or cluster.
stratactl install redshift_connector. The outputquery_role_arnis the function's role.- In Redshift, the function is the database user
IAMR:<role name>(IAM modes). Grant it what tiles may read:
``sql GRANT USAGE ON SCHEMA analytics TO "IAMR:stratabi-redshift_connector-query"; GRANT SELECT ON ALL TABLES IN SCHEMA analytics TO "IAMR:stratabi-redshift_connector-query"; ``
- Open the module in StrataBI: Connection shows the database user and version; Tables and views lists a schema.
Named queries
Queries live in the module's src/query/queries.json: a name, the SQL, and typed parameters (string, int, float, date, timestamp, identifier) with defaults. A tile names the query (inputs.query, or the tile's id); its inputs fill the parameters, which the Data API binds — values are never pasted into SQL. The Data API passes values as strings, so cast where the type matters:
{"name": "daily_counts",
"sql": "SELECT trunc(event_time) AS day, count(*) AS events FROM analytics.events WHERE event_time > dateadd(day, -CAST(:days AS INTEGER), getdate()) GROUP BY 1 ORDER BY 1",
"params": {"days": {"type": "int", "default": 30}}}Use it in a dashboard
{"id": "daily_counts", "title": "Events per day", "triggered_by": ["days"],
"exec": {"type": "lambda", "module_id": "redshift_connector", "lambda_index": 0, "result_kind": "dataframe",
"result_format": "csv", "result_name": "result.csv", "sync": true, "timeout_seconds": 60},
"load": {"mode": "input", "keep_previous": true},
"block": {"type": "plotly", "config": {"figure": {"data": [{"type": "bar", "x": "@day", "y": "@events"}]}}}}For queries that take longer than a minute, leave out "sync": the tile runs in the background, and the function waits up to its 300-second timeout, then cancels the statement.
Settings
| Setting | Default | Meaning |
|---|---|---|
mode | serverless | serverless, cluster or secret |
database | dev | the database to connect to |
allow_adhoc_sql | false | let tiles send their own read-only SELECT / WITH (inputs.sql) |
max_rows | 50,000 | rows returned to a tile; more are cut with a note |
Security
- The function may run statements on the one target, and describe, read and cancel only the statements it started. Credentials are issued for the chosen mode only.
- Ad-hoc SQL is off by default. Even when on, connect as a database user that can only read: the statement check is lexical, not a SQL parser.
- Query text and parameters appear in CloudTrail; result rows do not. Results reach StrataBI as run artifacts, governed by its roles.
Shaleio