SQLALCHEMY_DATABASE_URI not setting properly for RDS Elastic beanstalk deployment

0

I am using AWS elastic beanstalk RDS in deploying my flask app. If I include the line below in my config.py, I get a sevre health error saying that the web services are not running. However, if I completely omit the URL, or set it to something like "sqlite:///site.db". The app deploys successfully but gives an Internal Server Error when I try to add something to the database in the application. There are no logs.

SQLALCHEMY_DATABASE_URI = ("mysql+pymysql://"+ os.environ['RDS_USERNAME'] + ":" 
                                         + os.environ['RDS_PASSWORD']+ "@" 
                                         + os.environ['RDS_HOSTNAME'] 
                                           + ":3306/ebdb")
config.py
from dotenv import load_dotenv

load_dotenv()  # Load environment variables from .env file

class Config:
    SECRET_KEY = os.getenv('SECRET_KEY') 
       SQLALCHEMY_DATABASE_URI = ("mysql+pymysql://"+ os.environ['RDS_USERNAME'] + ":" 
                                         + os.environ['RDS_PASSWORD']+ "@" 
                                         + os.environ['RDS_HOSTNAME'] 
                                           + ":3306/ebdb")
    SESSION_PERMANENT = False 

Additionally, is there a way to allow the usage of flask_session using AWS without hardcoding the secret key? I couldn't find a place to configure environment variables like these in the elastic beanstalk console.

Joshua
asked 5 months ago79 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions