Skip to content
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

update iam code in main #2

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions titiler/pgstac/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""TiTiler+PgSTAC FastAPI application."""

import logging
import os
import re
from contextlib import asynccontextmanager
from typing import Dict
Expand Down Expand Up @@ -73,11 +74,17 @@ async def lifespan(app: FastAPI):
# Create Connection Pool
pg_settings, conn_kwargs = rds_connect_args(postgres_settings, rds_settings)

await connect_to_db(
app,
settings=postgres_settings,
**conn_kwargs,
)
if os.environ.get("TITILER_API_RDS_USE_IAM_AUTH") == "TRUE":
await connect_to_db(
app,
settings=pg_settings,
**conn_kwargs,
)
else:
await connect_to_db(
app,
settings=postgres_settings,
)
yield
# Close the Connection Pool
await close_db_connection(app)
Expand Down
2 changes: 1 addition & 1 deletion titiler/pgstac/rds.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def rds_connect_args(
pg_settings: PostgresSettings, rds_settings: RDSSettings
) -> Tuple[PostgresSettings, dict]:
"""Gather connections parameters and return them as a tuple of PostgresSettings
and additional kwargs to be passed directly to database.connect_to_db.
and additional kwargs to be passed directly to db.connect_to_db.

The returned PostgresSettings will be updated with values pulled from SSM
and SecretsManager based on the RDSSettings.
Expand Down