Skip to content

Commit 0b3213d

Browse files
committed
add config and env variables for AWS credentials
1 parent 8aa9d8d commit 0b3213d

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ SENTRY_DSN=
4343
# Configure these with your own Docker registry images
4444
DOCKER_IMAGE_BACKEND=backend
4545
DOCKER_IMAGE_FRONTEND=frontend
46+
47+
AWS_ACCESS_KEY_ID=fake-access-key-changethis
48+
AWS_SECRET_ACCESS_KEY=fake-secret-key-changethis
49+
AWS_REGION=us-east-1
50+
AWS_S3_ATTACHMENTS_BUCKET=patient-attachments

backend/app/api/deps.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections.abc import Generator
22
from typing import Annotated
33

4+
import boto3
45
import jwt
56
from fastapi import Depends, HTTPException, status
67
from fastapi.security import OAuth2PasswordBearer
@@ -55,3 +56,11 @@ def get_current_active_superuser(current_user: CurrentUser) -> User:
5556
status_code=403, detail="The user doesn't have enough privileges"
5657
)
5758
return current_user
59+
60+
# dependency for AWS SDK boto3 session
61+
aws_session = boto3.Session(
62+
aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
63+
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
64+
region_name=settings.AWS_REGION,
65+
)
66+
AwsDep = Annotated[boto3.Session, Depends(lambda: aws_session)]

backend/app/core/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ def emails_enabled(self) -> bool:
9595
FIRST_SUPERUSER: EmailStr
9696
FIRST_SUPERUSER_PASSWORD: str
9797

98+
# configuration for AWS client
99+
AWS_ACCESS_KEY_ID: str
100+
AWS_SECRET_ACCESS_KEY: str
101+
AWS_REGION: str
102+
AWS_S3_ATTACHMENTS_BUCKET: str
103+
98104
def _check_default_secret(self, var_name: str, value: str | None) -> None:
99105
if value == "changethis":
100106
message = (

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ services:
107107
- POSTGRES_USER=${POSTGRES_USER?Variable not set}
108108
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
109109
- SENTRY_DSN=${SENTRY_DSN}
110+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID?Variable not set}
111+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY?Variable not set}
112+
- AWS_REGION=${AWS_REGION?Variable not set}
113+
- AWS_S3_ATTACHMENTS_BUCKET=${AWS_S3_ATTACHMENTS_BUCKET?Variable not set}
110114

111115
healthcheck:
112116
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/utils/health-check/"]

0 commit comments

Comments
 (0)