Skip to content

Commit

Permalink
Remove optional extra value from credentials JSON
Browse files Browse the repository at this point in the history
Secrets manager entry holding DB credentials could have
dbInstanceIdentifier or dbCluesterIdentifier depending on the type of
database in use. This change removes both keys.

Also checks if key is present in dict before attempting to delete it.
  • Loading branch information
eternaltyro committed Mar 28, 2024
1 parent 6d9774b commit ee392a5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,9 @@ def get_db_connection_params() -> dict:
connection_params = json.loads(db_credentials)

connection_params["user"] = connection_params["username"]
for k in ("dbinstanceidentifier", "engine", "username"):
connection_params.pop(k, None)
for k in ("dbinstanceidentifier", "dbClusterIdentifier", "engine", "username"):
if k in connection_params:
connection_params.pop(k, None)

if None in connection_params.values():
raise ValueError(
Expand Down

0 comments on commit ee392a5

Please sign in to comment.