Skip to content

Commit

Permalink
chore: test db connection
Browse files Browse the repository at this point in the history
  • Loading branch information
montoyaobeso committed Jun 5, 2024
1 parent b8fa468 commit 1067041
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
5 changes: 0 additions & 5 deletions src/app/aws/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
import json
import logging

logger = logging.getLogger()
logger.setLevel(logging.INFO)


def get_secret(secret_name: str, region: str = "us-west-2"):

logging.info(f"Trying to get secret {secret_name}")

# Create a Secrets Manager client
session = boto3.session.Session()
client = session.client(service_name="secretsmanager", region_name=region)
Expand Down
5 changes: 0 additions & 5 deletions src/app/db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@

from src.app.aws.secrets import get_secret

logger = logging.getLogger()
logger.setLevel(logging.INFO)

if os.environ["STAGE"] != "local":
db_credentials = get_secret("stori-database-credentials")
os.environ["POSTGRES_USER"] = db_credentials["username"]
os.environ["POSTGRES_PASSWORD"] = db_credentials["password"]
os.environ["POSTRES_HOST"] = db_credentials["host"]
os.environ["POSTRES_DB"] = db_credentials["database"]
else:
logger.info("Executing in local enviroment.")

SQLALCHEMY_DATABASE_URL = f"postgresql://{os.environ['POSTGRES_USER']}:{os.environ['POSTGRES_PASSWORD']}@{os.environ['POSTRES_HOST']}/{os.environ['POSTGRES_DB']}"

Expand Down

0 comments on commit 1067041

Please sign in to comment.