-
Notifications
You must be signed in to change notification settings - Fork 23
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
chore: Refactor airflow-dags
module to use Pydantic
#127
Merged
LeonLuttenberger
merged 6 commits into
awslabs:main
from
LeonLuttenberger:chore/refactor-airflow-dags-module
Jun 18, 2024
+154
−76
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a32389e
Refactor `airflow-dags` module to use Pydantic
LeonLuttenberger e8c653f
fix dependencies
LeonLuttenberger 5af6f9d
fix formatting
LeonLuttenberger 2e536d6
update changeelog
LeonLuttenberger eaf98a6
fix mypy
LeonLuttenberger b6a6ddf
Merge branch 'main' into chore/refactor-airflow-dags-module
LeonLuttenberger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,4 +1,6 @@ | ||
aws-cdk-lib==2.137.0 | ||
cdk-nag==2.28.89 | ||
aws-cdk-lib~=2.137.0 | ||
cdk-nag~=2.28.89 | ||
boto3~=1.34.84 | ||
attrs==23.2.0 | ||
attrs~=23.2.0 | ||
pydantic~=2.7.4 | ||
pydantic-settings~=2.3.3 |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"""Defines the stack settings.""" | ||
|
||
from abc import ABC | ||
from typing import Dict, Optional | ||
|
||
from pydantic import Field, computed_field | ||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
||
|
||
class CdkBaseSettings(BaseSettings, ABC): | ||
"""Defines common configuration for settings.""" | ||
|
||
model_config = SettingsConfigDict( | ||
case_sensitive=False, | ||
env_nested_delimiter="__", | ||
protected_namespaces=(), | ||
extra="ignore", | ||
populate_by_name=True, | ||
) | ||
|
||
|
||
class ModuleSettings(CdkBaseSettings): | ||
"""Seedfarmer Parameters. | ||
|
||
These parameters are required for the module stack. | ||
""" | ||
|
||
model_config = SettingsConfigDict(env_prefix="SEEDFARMER_PARAMETER_") | ||
|
||
mwaa_exec_role_arn: str | ||
bucket_policy_arn: Optional[str] = Field(default=None) | ||
permission_boundary_arn: Optional[str] = Field(default=None) | ||
|
||
tags: Optional[Dict[str, str]] = Field(default=None) | ||
|
||
|
||
class SeedFarmerSettings(CdkBaseSettings): | ||
"""Seedfarmer Settings. | ||
|
||
These parameters comes from seedfarmer by default. | ||
""" | ||
|
||
model_config = SettingsConfigDict(env_prefix="SEEDFARMER_") | ||
|
||
project_name: str = Field(default="") | ||
deployment_name: str = Field(default="") | ||
module_name: str = Field(default="") | ||
|
||
@computed_field # type: ignore | ||
@property | ||
def app_prefix(self) -> str: | ||
"""Application prefix.""" | ||
prefix = "-".join([self.project_name, self.deployment_name, self.module_name]) | ||
return prefix | ||
|
||
|
||
class CDKSettings(CdkBaseSettings): | ||
"""CDK Default Settings. | ||
|
||
These parameters comes from AWS CDK by default. | ||
""" | ||
|
||
model_config = SettingsConfigDict(env_prefix="CDK_DEFAULT_") | ||
|
||
account: str | ||
region: str | ||
|
||
|
||
class ApplicationSettings(CdkBaseSettings): | ||
"""Application settings.""" | ||
|
||
seedfarmer_settings: SeedFarmerSettings = Field(default_factory=SeedFarmerSettings) | ||
module_settings: ModuleSettings = Field(default_factory=ModuleSettings) | ||
cdk_settings: CDKSettings = Field(default_factory=CDKSettings) |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we need this?
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.
It makes the error output easier to read in my opinion. Any parameter validation error will be in the standard output rather than buried in the stack trace.