Fixed process of updating app on running instances
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m29s

This commit is contained in:
2025-05-21 16:16:02 -05:00
parent 5767124031
commit be719a6e34
5 changed files with 21 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
import os
import boto3
from .constants import AWS_REGION
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
@@ -7,8 +8,14 @@ from functools import lru_cache
@lru_cache(maxsize=1)
def get_db_credentials():
"""Fetch and cache DB credentials from SSM Parameter Store"""
ssm = boto3.client('ssm')
"""Fetch and cache DB credentials from environment or SSM Parameter Store"""
if os.getenv("MOCK_AUTH", "").lower() == "true":
return (
f"postgresql://{os.getenv('DB_USER')}:{os.getenv('DB_PASSWORD')}"
f"@{os.getenv('DB_HOST')}/{os.getenv('DB_NAME')}"
)
ssm = boto3.client('ssm', region_name=AWS_REGION)
try:
host = ssm.get_parameter(Name='/iptv-updater/DB_HOST', WithDecryption=True)['Parameter']['Value']
user = ssm.get_parameter(Name='/iptv-updater/DB_USER', WithDecryption=True)['Parameter']['Value']