Connection
Powerpipe Connections provide a mechanism for defining credentials and options for interacting with external systems.
connection "postgres" "my_server" { host = "localhost" port = 5432 db = "mydb" username = "myuser" password = "mypassword123"}
Mod authors often use connections to set the default database, and allow users to pass a connection at run time using a variable.
Connections are defined using the connection
block in one or more Powerpipe config files. Powerpipe will load ALL configuration files (*.ppc
) from every directory in the configuration search path, with decreasing precedence. The set of connections is the union of all connections defined in these directories.
Each connection has a type label and a name. There is a type for each service: connection.steampipe, connection.postgres, connection.mysql, ,connection.duckdb, connection.sqlite, etc. The arguments and attributes vary by type.
Default connections
Powerpipe also creates a single implicit default connection for each connection type. The connection is named default
(connection.steampipe.default
, connection.postgres.default
, etc). The intent of the default connection is that Powerpipe can "just work" with your existing setup, and is similar to the default connection that Steampipe creates for each plugin. For example, the Postgres default connection will use the standard libpq environment variables to create a Powerpipe connection that will use the same connection that the psql
CLI would use, the Steampipe default connection will connect to the local Steampipe instance on postgres://steampipe@127.0.0.1:9193/steampipe
, etc.
You can override the default by simply creating a connection for that type that is named default
:
connection "steampipe" "default" { host = "steampipe.myorg.com" port = 9193 db = "steampipe" username = "myusername" password = "mypassword123"}