bi-preview and an example project ID. Replace them with your verified identifiers.
Start with a dedicated BI user
Create a machine user with its own Upsun account. Give it the Project viewer role and the Viewer role for the environment type it needs. Leave other environment types unassigned unless they’re needed. These are environment type permissions, so a Staging role applies to all Staging environments. Check inherited team permissions, too. The account shouldn’t acquire broader access through another membership. A Viewer can’t push code. By default, it can’t SSH into application containers either. You’ll make an exception for 1 dedicated app later. Create an API token for the machine user. I prefer this for automation because it gives you a credential you can rotate independently of anyone’s personal account. An SSH key attached to that user is another option, particularly if your BI tool only supports key-based SSH authentication. With the CLI, authentication uses SSH certificates that cycle every hour. The CLI obtains the certificate using your authenticated session, including when you authenticate with an API token. You get a temporary SSH credential without manually distributing a permanent SSH key for the BI integration.Give your database a read-only endpoint
Both databases support endpoints with different permissions. Each relationship can use a specific endpoint and receive the corresponding database credentials. Choose the configuration for your database:- MariaDB
- PostgreSQL
Suppose your service is called
mariadb and your database schema is main. Add a reporting endpoint with ro privileges:Merge this into your existing service configuration. Keep your current MariaDB version, schema names, and application endpoint permissions. The mysql endpoint above preserves the usual default endpoint for the application.Once you explicitly configure schemas or endpoints, Upsun no longer supplies their defaults. Include every existing schema and endpoint you still need, as described in the multiple databases documentation.The ro permission allows reads, views, and temporary tables. It doesn’t allow changing the application’s stored tables. Setting default_schema also lets CLI tools identify which database to connect to.See the MariaDB endpoint permissions for details.Add an application that does very little
Add a separate app calledbi-access under applications in the same configuration file:
The example below uses the MariaDB service. For PostgreSQL, change service: mariadb to service: postgresql in the reports relationship. Use your existing service name if it differs.
Keep your existing applications alongside this entry. Create a bi-access directory in the repository with a tracked file, such as a README, so Git preserves it.
The separate source root keeps the main application’s files out of this app’s build. Python supplies a runtime here, but you aren’t writing Python code. The start command does nothing beyond keeping the process alive. Don’t add an HTTP route to this app.
The access.ssh setting lowers the minimum SSH role to Viewer for this app. Other apps keep their own access settings, whose default minimum is Contributor. This permits any Viewer with the relevant environment access to enter bi-access, rather than naming 1 particular user.
The only relationship is reports, pointing to the reporting endpoint. The main application can retain its normal database permissions in its own container.
I recommend starting this container at 0.1 CPU. Its workload is forwarding an SSH connection, while the database executes the queries. Check throughput and memory usage if you move large amounts of data.
After the preview deployment completes, use the resource configuration command to size this app. Run this as a project administrator, before switching to the BI account:
Connect the BI tool through the app
Deploy the configuration in a preview environment first. If you’ve changed user permissions, redeploy to apply SSH access changes. On the machine running the tunnel, authenticate the CLI as the BI user. For an interactive check, this command prompts for its token:UPSUN_CLI_TOKEN through that machine’s secret manager instead. Keep the BI token on the tunnel host; the Upsun app doesn’t need it.
Open a single relationship tunnel, explicitly selecting the dedicated app:
127.0.0.1, port 3307, database main, and the credentials from the reports relationship.
The local port is your choice: 3307 works for either database because the tunnel forwards it to the relationship’s remote port.
You can inspect those credentials as the BI user with:
bi-access and the app tunnel instructions. A tool using certificates needs a way to refresh them. Attaching an SSH key to the same restricted user may fit that tool better.
Check the permissions with the BI account
Before connecting production reporting, test the setup using the machine user’s credentials in your preview environment:- Confirm a
SELECTagainst a known table succeeds throughreports. - On a disposable test table (or a preview environment), confirm an
INSERTfails with a permissions error. - Confirm SSH into
bi-accesssucceeds, while SSH into the main application is denied. - Check the BI user’s roles deny code pushes and that no privileged credentials appear inside
bi-access.