dev_fastapi = FastApi(
...
env_vars={
"RUNTIME_ENV": "dev",
"OPENAI_API_KEY": getenv("OPENAI_API_KEY"),
"DB_HOST": dev_db.get_db_host(),
"DB_PORT": dev_db.get_db_port(),
"DB_USER": dev_db.get_db_user(),
"DB_PASS": dev_db.get_db_password(),
"DB_DATABASE": dev_db.get_db_database(),
"WAIT_FOR_DB": ws_settings.dev_db_enabled,
},
...
)
prd_fastapi = FastApi(
...
env_vars={
"RUNTIME_ENV": "prd",
"OPENAI_API_KEY": getenv("OPENAI_API_KEY"),
"DB_HOST": AwsReference(prd_db.get_db_endpoint),
"DB_PORT": AwsReference(prd_db.get_db_port),
"DB_USER": AwsReference(prd_db.get_master_username),
"DB_PASS": AwsReference(prd_db.get_master_user_password),
"DB_DATABASE": AwsReference(prd_db.get_db_name),
"WAIT_FOR_DB": ws_settings.prd_db_enabled,
},
...
)
The apps in your templates are already configured to read environment variables.