Credentials from a secret manager
Point a password or token at a secret in AWS Secrets Manager, so DSUI reads it when it needs it and never stores it.
On this page
A connection normally holds its credentials. You can instead point a password or token field at a secret in a secret manager. DSUI reads the value when it calls the service, keeps it in memory for a few minutes, and never writes it to dsui.yaml or its database. What DSUI stores is the reference, which is not secret.
Secret managers come from the secrets plugin. You list the managers you use under providers, and the connection form offers each of them. This page uses AWS Secrets Manager. Other plugins can add other managers.
Set up the secrets plugin#
Add the plugin under plugins in dsui.yaml, with one entry per secret manager:
plugins:
secrets:
source: git
repository: northgraindata/dsui
path: packages/plugin-secrets
config:
providers:
aws:
type: aws-secrets-manager
region: eu-west-1
accessKeyId: ${AWS_ACCESS_KEY_ID}
secretAccessKey: ${AWS_SECRET_ACCESS_KEY}The key, here aws, is the name that references use. type picks the secret manager. Restart DSUI after you change the plugin.
| Option | Applies to | Meaning |
|---|---|---|
type | All | aws-secrets-manager |
label | All | The name shown in the connection form. Defaults to the type |
region | aws-secrets-manager | Defaults to the region that your AWS credentials come with |
accessKeyId | aws-secrets-manager | The access key. Give it together with secretAccessKey |
secretAccessKey | aws-secrets-manager | The secret for the access key |
sessionToken | aws-secrets-manager | For temporary credentials. Needs the two keys above |
endpoint | aws-secrets-manager | For emulators such as LocalStack |
identity | aws-secrets-manager | Credentials from a token that a service signs, instead of keys. Set by DSUI Cloud. Needs roleArn, tokenUrl, and token, and can’t be combined with the keys above |
To read from several regions or accounts, add one entry for each, for example aws-eu and aws-us. The form shows them as separate choices.
Give DSUI access to the secrets#
Write the credentials under the provider, the same way you write them for any other service. Use ${NAME} so the values stay in the environment and out of the file, as described in connect a service. Create a user or role for DSUI that can read only the secrets it needs.
If you leave accessKeyId, secretAccessKey, and sessionToken out, the plugin uses the AWS default credential chain instead. That is the better choice when DSUI runs where AWS already knows who it is:
- An IAM role on the instance, task, or pod that runs DSUI
AWS_WEB_IDENTITY_TOKEN_FILEandAWS_ROLE_ARN, for Kubernetes service accounts and other OIDC setupsAWS_PROFILE, for single sign-on on a workstation
Allow the user or role to read only the secrets that DSUI needs. If a secret is encrypted with your own KMS key, it also needs kms:Decrypt on that key:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "arn:aws:secretsmanager:eu-west-1:123456789012:secret:prod/*"
}
]
}Let DSUI list your secrets#
The list in the form needs one more permission, secretsmanager:ListSecrets, which can’t be limited to particular secrets. It is optional. Without it the field is a plain input.
{
"Effect": "Allow",
"Action": "secretsmanager:ListSecrets",
"Resource": "*"
}DSUI tries to list once. If AWS refuses, DSUI remembers that for 5 minutes and shows a plain input, so a role that can only read doesn’t cause an error on every keystroke. Only people with the admin or owner role see the list, because the names of secrets show what exists. The list matches names that start with what you type, and the part after # is never searched.
Write a reference#
A reference is a secret’s name or ARN. To read one field of a secret that stores JSON, add # and the field name:
| Reference | Reads |
|---|---|
prod/airflow | The whole text of the secret |
prod/airflow#password | The password field of a JSON secret |
arn:aws:secretsmanager:eu-west-1:123456789012:secret:prod/airflow-AbCdEf#password | The same field, by ARN. Use an ARN to read a secret in another account |
The field must hold text. DSUI doesn’t read binary secrets.
Use a reference in the workspace#
In a service’s connection dialog, every field has a key icon next to its label. The icon appears once a secret manager is set up.
Choose the secret manager#
Select the key icon next to the field. If you set up more than one manager, choose which.
Enter the reference#
Type the name or ARN, for example
prod/airflow#password. When you select the field, DSUI lists your secrets. Keep typing to narrow the list, then choose one with the pointer or with the arrow keys and Enter. The list only fills the field in, so you can still type any reference.Test and save#
Select Test connection. DSUI reads the secret to run the test. If you save the connection, DSUI keeps the reference and not the value.
Use a reference in dsui.yaml#
Replace the value with a $secret object that names the manager and the reference:
adapters:
postgresql:
source: git
repository: "git+https://github.com/northgraindata/dsui"
path: packages/adapter-postgresql
plugins:
secrets:
source: git
repository: northgraindata/dsui
path: packages/plugin-secrets
config:
providers:
aws:
type: aws-secrets-manager
services:
- id: app-database
adapter: postgresql
name: Application database
connection:
host: postgres
database: app
username: app
password:
$secret:
provider: aws
reference: prod/app-database#passwordprovider is the name of the entry under providers. Any field in connection can take a reference, not only passwords. A reference always returns text, which DSUI passes on as if you had typed it, so a port or a flag read from a secret works like one you enter by hand. You can use ${NAME} inside reference, for example to choose a secret per environment.
What to expect#
- Rotation. DSUI reads each secret again at most every 5 minutes. After you rotate a secret, services pick up the new value within that time, with no restart.
- Failures. If a secret can’t be read, the test or the service shows which reference failed and why, for example
Could not read "prod/app-database" from AWS Secrets Manager: AccessDeniedException. DSUI never includes a secret’s value in an error. - A missing plugin. If a service points at a manager whose plugin isn’t installed, it reports
Secret provider "aws" is not installed. - Other credentials. Only fields in a service’s
connectiontake a reference. Plugin settings and the master key still come from the environment.