Skip to content

Connect Configuration

Environment detection and secrets management for AWS services.


_ConfigurationManager

Python
_ConfigurationManager()

Loads configuration for AWS credentials, RDS secrets, SSH tunnel setup, and DB options. Configuration is loaded in order: optional .env → environment vars → kwargs.

construct_db_uri

Python
construct_db_uri() -> str

Build a SQLAlchemy/Postgres URI from the current DB config.

initialize

Python
initialize(env_path: Optional[str] = None, silent: bool = False, **kwargs)

Initialize config from .env (if provided), environment, and kwargs.

load_rds_secret

Python
load_rds_secret(secret_dict: dict)

Populate DB connection fields from a secret dictionary.

reset

Python
reset()

Reset config to its initial state.

_SshTunnelManager

Python
_SshTunnelManager(config: dict)

Handles creation and teardown of an SSH tunnel to a remote database host. Requires config with SSH credentials and target DB host/port.

Initialize SSH tunnel manager with DB + SSH credentials.

Text Only
- PGHOST, PGPORT, PGPASSWORD, etc.
- SSH_TUNNEL:
    - SSH_SERVER
    - SSH_PORT
    - SSH_USER
    - (SSH_PASSWORD | SSH_KEY_PATH)

start_tunnel

Python
start_tunnel() -> tuple[str, int]

Starts the SSH tunnel.

RETURNS DESCRIPTION
tuple[str, int]

Local bind address and port tuple.

stop_tunnel

Python
stop_tunnel()

Stops the tunnel if running.