-
Notifications
You must be signed in to change notification settings - Fork 603
feat: Enable AWS IAM auth for DB configuration #9936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| encoded_user = quote(pg_user) | ||
| encoded_password = quote(pg_password) | ||
| connection_str = f"postgresql://{encoded_user}:{encoded_password}@{pg_host}" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: PostgreSQL Config Error Breaks Non-PostgreSQL Deployments
The get_env_postgres_connection_str() function now raises a ValueError when PHOENIX_POSTGRES_PASSWORD is missing (and IAM auth is not enabled). Previously, it returned None in this scenario, allowing graceful handling of incomplete PostgreSQL configurations. This change can cause unexpected startup failures for deployments not using PostgreSQL.
| import boto3 # pyright: ignore | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already imported above
| import boto3 # pyright: ignore |
| except Exception as e: | ||
| logger.warning( | ||
| f"Failed to validate AWS credentials for RDS IAM authentication: {e}. " | ||
| "Ensure AWS credentials are configured via environment variables, " | ||
| "~/.aws/credentials, or IAM role." | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this just a warning and not an exception?
| f"Failed to generate AWS RDS IAM authentication token: {e}. " | ||
| "Ensure AWS credentials are configured and have 'rds-db:connect' permission." | ||
| ) | ||
| raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should understand the effect of this exception
This PR adds support for AWS IAM-based authentication for PostgreSQL connections to AWS Aurora/RDS, enabling the use of short-lived IAM tokens instead of static passwords.
Example:
Ensure boto3 is installed in your phoenix environment
Note
Adds AWS RDS IAM authentication for PostgreSQL, generating short‑lived tokens (via boto3) with SSL enforcement and pool recycling, plus related env vars and optional deps.
phoenix.db.iam_auth.generate_aws_rds_tokenused by async (asyncpg) and sync (psycopg) creators.pool_recycle).aio_postgresql_engineconditionally uses IAM creators; migrations supported with IAM.get_pg_config(..., enforce_ssl=True|False)adds SSL enforcement and rejectssslmode=disableunder IAM.PHOENIX_POSTGRES_USE_AWS_IAM_AUTH,PHOENIX_POSTGRES_AWS_IAM_TOKEN_LIFETIME_SECONDS.get_env_postgres_connection_strupdated to allow user-only URI when IAM is enabled; validates password presence/absence.verify_server_environment_variables.awswithboto3; guidance to install when IAM is enabled.Written by Cursor Bugbot for commit d93a2bd. This will update automatically on new commits. Configure here.