From 548b4a4b75fcb7e6f306fb957fcf2ff1265bcf49 Mon Sep 17 00:00:00 2001 From: "John \"Preston\" Mille" Date: Mon, 20 Nov 2023 09:44:31 +0000 Subject: [PATCH] WIP --- ecs_composex/aps/aps_stack.py | 2 +- ecs_composex/kinesis/kcl_helpers.py | 4 +- ecs_composex/mods_manager.py | 68 +++++++++---------- ecs_composex/rds/rds_db_template.py | 2 +- .../rds/rds_parameter_groups_helper.py | 2 +- ecs_composex/rds_resources_settings.py | 4 +- ecs_composex/resource_settings.py | 2 +- 7 files changed, 41 insertions(+), 43 deletions(-) diff --git a/ecs_composex/aps/aps_stack.py b/ecs_composex/aps/aps_stack.py index 12e8e0e4..3120699b 100644 --- a/ecs_composex/aps/aps_stack.py +++ b/ecs_composex/aps/aps_stack.py @@ -134,7 +134,7 @@ def add_extra_outputs(self): def create_aps_log_group( new_aps: ManagedPrometheus, props: dict, - macro_value: Union[bool, dict], + macro_value: bool | dict, template: Template, ) -> None: """Handles the CreateNewLogGroup macro parameter""" diff --git a/ecs_composex/kinesis/kcl_helpers.py b/ecs_composex/kinesis/kcl_helpers.py index dbde3079..02359357 100644 --- a/ecs_composex/kinesis/kcl_helpers.py +++ b/ecs_composex/kinesis/kcl_helpers.py @@ -60,7 +60,7 @@ def add_cloudwatch_metric_data_permission(family: ComposeFamily) -> None: ) -def define_dynamodb_statement(dynamodb_definition: Union[bool, dict]) -> list: +def define_dynamodb_statement(dynamodb_definition: bool | dict) -> list: sid = "DynamodbKCL" if isinstance(dynamodb_definition, bool): statement = [ @@ -108,7 +108,7 @@ def define_dynamodb_statement(dynamodb_definition: Union[bool, dict]) -> list: def add_dynamodb_permissions( - family: ComposeFamily, dynamodb_definition: Union[bool, dict] + family: ComposeFamily, dynamodb_definition: bool | dict ) -> None: """ Adds permissions to access DynamoDB diff --git a/ecs_composex/mods_manager.py b/ecs_composex/mods_manager.py index 20c83150..cdf3258b 100644 --- a/ecs_composex/mods_manager.py +++ b/ecs_composex/mods_manager.py @@ -53,14 +53,14 @@ def __init__( res_key: str, x_class, posix_path, - resource_class: Union[ - XResource, - ServicesXResource, - ApiXResource, - AwsEnvironmentResource, - NetworkXResource, - DatabaseXResource, - ] = None, + resource_class: ( + XResource + | ServicesXResource + | ApiXResource + | AwsEnvironmentResource + | NetworkXResource + | DatabaseXResource + ) = None, definition: dict = None, ): if definition and not isinstance(definition, dict): @@ -90,14 +90,14 @@ def __del__(self): @property def resource_class( self, - ) -> Union[ - XResource, - ServicesXResource, - ApiXResource, - AwsEnvironmentResource, - NetworkXResource, - DatabaseXResource, - ]: + ) -> ( + XResource + | ServicesXResource + | ApiXResource + | AwsEnvironmentResource + | NetworkXResource + | DatabaseXResource + ): return self._resource_class @property @@ -153,14 +153,14 @@ def resources( self, ) -> dict[ str, - Union[ - XResource, - ServicesXResource, - ApiXResource, - AwsEnvironmentResource, - NetworkXResource, - DatabaseXResource, - ], + ( + XResource + | ServicesXResource + | ApiXResource + | AwsEnvironmentResource + | NetworkXResource + | DatabaseXResource + ), ]: return self._resources @@ -168,14 +168,14 @@ def resources( def resources_list( self, ) -> list[ - Union[ - XResource, - ServicesXResource, - ApiXResource, - AwsEnvironmentResource, - NetworkXResource, - DatabaseXResource, - ] + ( + XResource + | ServicesXResource + | ApiXResource + | AwsEnvironmentResource + | NetworkXResource + | DatabaseXResource + ) ]: return [_res for _res in self._resources.values() if _res is not None] @@ -343,9 +343,7 @@ def add_module_from_module_def(self, res_key: str, mod_key: str, module_name: st if extension_module: return extension_module - def load_module( - self, res_key: str, res_def: Union[dict, bool] - ) -> Union[XResourceModule, None]: + def load_module(self, res_key: str, res_def: dict | bool) -> XResourceModule | None: if not res_key.startswith(X_KEY): return mod_key = re.sub(X_KEY, "", res_key) diff --git a/ecs_composex/rds/rds_db_template.py b/ecs_composex/rds/rds_db_template.py index 9205b850..2644b6ad 100644 --- a/ecs_composex/rds/rds_db_template.py +++ b/ecs_composex/rds/rds_db_template.py @@ -432,7 +432,7 @@ def override_set_properties(props: dict, db: Rds) -> None: ) -def determine_resource_type(db_name: str, properties: dict) -> Union[type, None]: +def determine_resource_type(db_name: str, properties: dict) -> type | None: """ Function to determine if the properties are the ones of a DB Cluster or DB Instance. Default assumes DBCluster if it can't make it out from properties. diff --git a/ecs_composex/rds/rds_parameter_groups_helper.py b/ecs_composex/rds/rds_parameter_groups_helper.py index b42b5256..ae68f050 100644 --- a/ecs_composex/rds/rds_parameter_groups_helper.py +++ b/ecs_composex/rds/rds_parameter_groups_helper.py @@ -65,7 +65,7 @@ def get_db_cluster_engine_parameter_group_defaults( def get_family_from_engine_version( engine_name: str, engine_version: str, session: Session = None -) -> Union[str, None]: +) -> str | None: """ Get the engine family from engine name and version """ diff --git a/ecs_composex/rds_resources_settings.py b/ecs_composex/rds_resources_settings.py index df203669..74c7449b 100644 --- a/ecs_composex/rds_resources_settings.py +++ b/ecs_composex/rds_resources_settings.py @@ -419,7 +419,7 @@ def add_secrets_access_policy( service_family: ComposeFamily, secret_import, db: DatabaseXResource, - use_task_role: Union[bool, dict] = False, + use_task_role: bool | dict = False, ) -> None: """ Function to add or append policy to access DB Secret for the Execution Role @@ -451,7 +451,7 @@ def add_secrets_access_policy( def handle_task_role_access( - use_task_role: Union[dict, bool], + use_task_role: dict | bool, policy: PolicyType, secret_import, task_role, diff --git a/ecs_composex/resource_settings.py b/ecs_composex/resource_settings.py index 0627da00..4d98c38e 100644 --- a/ecs_composex/resource_settings.py +++ b/ecs_composex/resource_settings.py @@ -240,7 +240,7 @@ def define_iam_permissions( dest_resource_template, policy_title, access_type_policy_model, - access_definition: Union[str, dict], + access_definition: str | dict, resource_arns, access_subkey: str = None, roles=None,