src.api.config module

src.api.config.get_db_login()[source]

Retrieves database login credentials from environment variables or AWS Secrets Manager.

This function first checks if the ‘LOCAL_DB’ environment variable is set to ‘1’.

If it is, it returns a predefined set of local database credentials.

If ‘LOCAL_DB’ is not set to ‘1’, it then checks if the ‘DB_HOST’ environment variable is set. If it is, it returns the database credentials from the ‘DB_USERNAME’, ‘DB_PASSWORD’, ‘DB_HOST’, ‘DB_PORT’, and ‘DB_NAME’ environment variables.

If neither ‘LOCAL_DB’ nor ‘DB_HOST’ are set, it attempts to retrieve the database credentials from AWS Secrets Manager. If it fails to retrieve the credentials from Secrets Manager, it falls back to the predefined local database credentials.

Returns:

A list containing the username, password, host, port, and database name, in that order.

Return type:

list

Raises:
  • RuntimeError – If the database configuration is not found in the environment

  • variables and the local database credentials are not set.