Here we can easily set a connection with the sling conns set command and later refer to them by their name. This ensures credentials are not visible by other users when using process monitors, for example.
# set a connection by providing the key=value pairs$slingconnssetAWS_S3type=s3bucket=sling-bucketaccess_key_id=ACCESS_KEY_IDsecret_access_key="SECRET_ACCESS_KEY"# we set a database connection with just the url$slingconnssetMY_PGurl='postgresql://postgres:myPassword@pghost:5432/postgres'
To see what credential keys are necessary/accepted for each type of connector, click below:
The Sling Env file is the primary way sling reads connections. It needs to be saved in the path ~/.sling/env.yaml where the ~ denotes the path of the user Home folder, which can have different locations depending on the operating system (see here for Windows, here for Mac and here for Linux). Sling automatically creates the .sling folder in the user home directory, which is typically as shown below:
Linux: /home/<username>/.sling, or /root/.sling if user is root
Mac: /Users/<username>/.sling
Windows: C:\Users\<username>\.sling
Once in the user home directory, setting the Sling Env File (named env.yaml) is easy, and adheres to the structure below. Running sling the first time will auto-create it. You can alternatively provide the environment variable SLING_HOME_DIR.
To see what credential keys are necessary/accepted for each type of connector, click below:
# Holds all connection credentials for Extraction and Loadingconnections:marketing_pg:url:'postgres://...'ssh_tunnel:'ssh://...'# optional# or dbt profile styledmarketing_pg:type:postgreshost: [hostname] user: [username] password: [password] port: [port] dbname: [database name]schema: [dbt schema] ssh_tunnel:'ssh://...'finance_bq:type:bigquerymethod:service-accountproject: [GCP project id]dataset: [the name of your dbt dataset]keyfile: [/path/to/bigquery/keyfile.json]# Global variables for specific settings, available to all connections at runtime (Optional)variables:aws_access_key:'...'aws_secret_key:'...'
Environment Variables
Sling also reads environment variables. Simply export a connection URL (or YAML payload) to the current shell environment to use them.
To see examples of setting environment variables for each type of connector, click below: