Trino configuration files contain passwords and sensitive data in plain text. Corporation security policies are not tolerant with it. That kind of information must be hidden from users who are not authorized to have access to it. As a rule of thumb, DevOps and security teams are responsible to set up and maintain the part of configuration with sensitive information. It can be achieved by implementing environment variables to supply passwords and sensitive data in Trino configuration files. A Trino property value is replaced with a name of an environment variable.
The simplest method is to populate environment variables manually or with a shell script before starting of Trino. This functionality is fully supported by Trino. Also, it is possible to read data from a secure storage and assign values to environment variables. Both ways are shown in the article. As a storage, it is used a text file with limited access, but it can be replaced with another type of a storage.
The samples are based on Starburst 393-e open-source distribution and RHEL 7 Linux distribution. There are two different cases depending on what Trino installation is used RPM or tar.
Manually populated environment variable
Add environment variable in Linux
export MYSQL_SERVER_PASSWORD=password123
Use the variable in MySql catalog configuration file
connector.name=mysql connection-url=jdbc:mysql://example.net:3306 connection-user=root connection-password=${ENV:MYSQL_SERVER_PASSWORD}
Environment variable extracted from text file
RPM installation
Create
ini
file with secretsThe file contains entries in format
name=value
, for example,MYSQL_SERVER_PASSWORD=password123
.nano /root/trino_secrets.ini
Load sensitive information from
ini
fileRead the environment variable in
/etc/starburst/env.sh
Trino configuration file.export MYSQL_SERVER_PASSWORD=$(awk -F "=" '/MYSQL_SERVER_PASSWORD/ {print $2}' /root/trino_secrets.ini)
Deploy the setup files to a coordinator and/or workers
- /root/trino_secrets.ini
- /etc/starburst/env.sh
Limit access to
ini
file on each Trino nodeMake
root
as an owner of the file and remove everybody else from accessing the file.chown root:root /root/trino_secrets.ini chmod g+rw,u+rw,o-rwx /root/trino_secrets.ini
Use the variable in MySql catalog configuration file
connector.name=mysql connection-url=jdbc:mysql://example.net:3306 connection-user=root connection-password=${ENV:MYSQL_SERVER_PASSWORD}
tar installation
Create
sh
file with secretssudo /trino/trino_secrets.sh
Each entry is an environment variable export. Surround variable values with single quotes (
'
) to mitigate any special characters.export MYSQL_SERVER_PASSWORD='password123'
Limit access to the secret file to a user running Trino service, for example, starburst.
sudo chown -R starburst:starburst /trino sudo chmod -R o-rxw /trino
Run the secret file in Trino launcher script
Add
. /trino/trino_secrets.sh
command beforeexec "$(dirname "$0")/launcher.py" "$@"
line.Open Trino launcher script if Trino has been installed in
/usr/lib/starburst
folder.sudo nano /usr/lib/starburst/bin/launcher
Make changes
. /trino/trino_secrets.sh exec "$(dirname "$0")/launcher.py" "$@"
Use the variable in MySql catalog configuration file
connector.name=mysql connection-url=jdbc:mysql://example.net:3306 connection-user=root connection-password=${ENV:MYSQL_SERVER_PASSWORD}
Comments
comments powered by Disqus