This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename dynamodb terraform module names
- Loading branch information
1 parent
7a3b130
commit 33bd2a3
Showing
5 changed files
with
38 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import logging | ||
from typing import Any | ||
|
||
from pydantic import BaseModel, field_validator | ||
|
||
|
||
class DatabaseConfig(BaseModel): | ||
database_type: str = "mongodb" | ||
type: str = "mongodb" | ||
aws_region: str | None = None | ||
|
||
@field_validator("database_type") | ||
@field_validator("type") | ||
@classmethod | ||
def validate_database_type(cls, value: str): | ||
value = value.lower() | ||
logging.info("Validating database type: %s", value) | ||
if value not in ["mongodb", "dynamodb"]: | ||
raise ValueError("Database type must be either mongodb or mysql") | ||
raise ValueError("Database type must be either mongodb or dynamodb") | ||
return value | ||
|
||
def model_post_init(self, __context: Any) -> None: | ||
if self.database_type == "dynamodb": | ||
assert self.aws_region is not None | ||
if self.type == "dynamodb" and self.aws_region is None: | ||
raise ValueError("AWS region must be provided for DynamoDB database type") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters