Skip to content

Commit 2d6171d

Browse files
authored
[Feat] User 애플리케이션에 MongoDB(DocumentDB) 연결 (#15)
## 작업 내역 (관련 이슈) - #14 ## 특이 사항 -
2 parents f8736fb + bbd974b commit 2d6171d

5 files changed

Lines changed: 143 additions & 1 deletion

File tree

.aws/ecs-task-definition.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,35 @@
1515
],
1616
"essential": true,
1717
"environment": [
18+
{
19+
"name": "ENV",
20+
"value": "prod"
21+
}
1822
],
1923
"environmentFiles": [],
2024
"mountPoints": [],
2125
"volumesFrom": [],
2226
"secrets": [
27+
{
28+
"name": "MONGODB_URI",
29+
"valueFrom": "arn:aws:ssm:ap-northeast-2:864981757354:parameter/xrpedia/documentdb/host"
30+
},
31+
{
32+
"name": "MONGODB_PORT",
33+
"valueFrom": "arn:aws:ssm:ap-northeast-2:864981757354:parameter/xrpedia/documentdb/port"
34+
},
35+
{
36+
"name": "MONGODB_DB",
37+
"valueFrom": "arn:aws:ssm:ap-northeast-2:864981757354:parameter/xrpedia/documentdb/dbname"
38+
},
39+
{
40+
"name": "MONGODB_USER",
41+
"valueFrom": "arn:aws:secretsmanager:ap-northeast-2:864981757354:secret:rds!cluster-b06771f3-3e07-4b6c-8e7b-b793cb7b498e-CcZIQG:username::"
42+
},
43+
{
44+
"name": "MONGODB_PASSWORD",
45+
"valueFrom": "arn:aws:secretsmanager:ap-northeast-2:864981757354:secret:rds!cluster-b06771f3-3e07-4b6c-8e7b-b793cb7b498e-CcZIQG:password::"
46+
}
2347
],
2448
"ulimits": [],
2549
"logConfiguration": {

poetry.lock

Lines changed: 102 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ boto3 = "^1.37.16"
1515
botocore = "^1.37.16"
1616
dotenv = "^0.9.9"
1717
httpx = "^0.28.1"
18+
pymongo = "^4.11.3"
1819

1920
[build-system]
2021
requires = ["poetry-core"]

src/main/config/__init__.py

Whitespace-only changes.

src/main/config/mongodb.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
from dotenv import load_dotenv
3+
from pymongo import MongoClient
4+
5+
load_dotenv()
6+
7+
MONGO_URI = os.getenv("MONGODB_URI")
8+
MONGO_PORT = os.getenv("MONGODB_PORT")
9+
MONGO_DB = os.getenv("MONGODB_DB")
10+
MONGO_USER = os.getenv("MONGODB_USER")
11+
MONGO_PASSWORD = os.getenv("MONGODB_PASSWORD")
12+
13+
14+
def get_mongo_client():
15+
client = MongoClient("mongodb://" + MONGO_USER + ":" + MONGO_PASSWORD + "@" + MONGO_URI + ":" + MONGO_PORT + "/" + MONGO_DB + "?retryWrites=true")
16+
return client

0 commit comments

Comments
 (0)