From 612fbdb53d19d283cf8e95a4155365d437300b35 Mon Sep 17 00:00:00 2001 From: Ryan McGinty Date: Wed, 20 Nov 2024 13:43:22 -0800 Subject: [PATCH 1/3] fix launch template class method --- .../constructs_/batch/launch_template.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/aibs_informatics_cdk_lib/constructs_/batch/launch_template.py b/src/aibs_informatics_cdk_lib/constructs_/batch/launch_template.py index 7f1c5cf..d761760 100644 --- a/src/aibs_informatics_cdk_lib/constructs_/batch/launch_template.py +++ b/src/aibs_informatics_cdk_lib/constructs_/batch/launch_template.py @@ -41,7 +41,6 @@ class BatchLaunchTemplateBuilder(IBatchLaunchTemplateBuilder["BatchLaunchTemplat def grant_instance_role_permissions(self, instance_role: iam.Role): pass - @abstractmethod def create_launch_template( self, descriptor: IBatchEnvironmentDescriptor, From ce6af7d3b1ab934c181b97eb9a2f1c2e7e766444 Mon Sep 17 00:00:00 2001 From: Ryan McGinty Date: Wed, 20 Nov 2024 13:46:14 -0800 Subject: [PATCH 2/3] make external sns trigger construct more configurable --- .../constructs_/external_sns_trigger.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/aibs_informatics_cdk_lib/constructs_/external_sns_trigger.py b/src/aibs_informatics_cdk_lib/constructs_/external_sns_trigger.py index bb7f599..63768b2 100644 --- a/src/aibs_informatics_cdk_lib/constructs_/external_sns_trigger.py +++ b/src/aibs_informatics_cdk_lib/constructs_/external_sns_trigger.py @@ -21,6 +21,10 @@ def __init__( external_sns_event_name: Union[str, ResourceNameBaseEnum], external_sns_topic_arn: str, external_sns_event_queue_filters: Optional[Sequence[Mapping[str, Any]]] = None, + external_sns_event_queue_name: Optional[str] = None, + external_sns_event_dlq_name: Optional[str] = None, + external_sns_event_queue_retention_period: Optional[cdk.Duration] = None, + sqs_event_source_enabled: Optional[bool] = None, **kwargs, ) -> None: """This intended to be a generic CDK construct that defines resources necessary to @@ -59,7 +63,14 @@ def __init__( """ super().__init__(scope=scope, id=id) - external_sns_event_dlq_name = env_base.prefixed(external_sns_event_name, "sns-event-dlq") + if external_sns_event_queue_name is None: + external_sns_event_queue_name = env_base.prefixed( + external_sns_event_name, "sns-event-queue" + ) + if external_sns_event_dlq_name is None: + external_sns_event_dlq_name = env_base.prefixed( + external_sns_event_name, "sns-event-dlq" + ) self.external_sns_event_dlq = sqs.Queue( scope=self, id=env_base.get_construct_id(external_sns_event_name, "sns-event-dlq"), @@ -71,7 +82,7 @@ def __init__( scope=self, id=env_base.get_construct_id(external_sns_event_name, "sns-event-queue"), queue_name=env_base.prefixed(external_sns_event_name, "sns-event-queue"), - retention_period=cdk.Duration.days(7), + retention_period=external_sns_event_queue_retention_period or cdk.Duration.days(7), dead_letter_queue=sqs.DeadLetterQueue( max_receive_count=2, queue=self.external_sns_event_dlq, @@ -103,7 +114,9 @@ def __init__( queue=self.external_sns_event_queue, report_batch_item_failures=True, filters=external_sns_event_queue_filters, - enabled=(env_base.env_type is EnvType.PROD), + enabled=(env_base.env_type is EnvType.PROD) + if sqs_event_source_enabled is None + else sqs_event_source_enabled, ) ) self.external_sns_event_queue.grant_consume_messages(triggered_lambda_fn) From 41905e09a0aa32dc5245e14674f879f1bf7a965e Mon Sep 17 00:00:00 2001 From: Ryan McGinty Date: Wed, 20 Nov 2024 15:03:14 -0800 Subject: [PATCH 3/3] address pr comments --- .../constructs_/external_sns_trigger.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/aibs_informatics_cdk_lib/constructs_/external_sns_trigger.py b/src/aibs_informatics_cdk_lib/constructs_/external_sns_trigger.py index 63768b2..24335fc 100644 --- a/src/aibs_informatics_cdk_lib/constructs_/external_sns_trigger.py +++ b/src/aibs_informatics_cdk_lib/constructs_/external_sns_trigger.py @@ -23,7 +23,7 @@ def __init__( external_sns_event_queue_filters: Optional[Sequence[Mapping[str, Any]]] = None, external_sns_event_queue_name: Optional[str] = None, external_sns_event_dlq_name: Optional[str] = None, - external_sns_event_queue_retention_period: Optional[cdk.Duration] = None, + external_sns_event_queue_retention_period: Optional[cdk.Duration] = cdk.Duration.days(7), sqs_event_source_enabled: Optional[bool] = None, **kwargs, ) -> None: @@ -71,6 +71,9 @@ def __init__( external_sns_event_dlq_name = env_base.prefixed( external_sns_event_name, "sns-event-dlq" ) + if sqs_event_source_enabled is None: + sqs_event_source_enabled = env_base.env_type is EnvType.PROD + self.external_sns_event_dlq = sqs.Queue( scope=self, id=env_base.get_construct_id(external_sns_event_name, "sns-event-dlq"), @@ -82,7 +85,7 @@ def __init__( scope=self, id=env_base.get_construct_id(external_sns_event_name, "sns-event-queue"), queue_name=env_base.prefixed(external_sns_event_name, "sns-event-queue"), - retention_period=external_sns_event_queue_retention_period or cdk.Duration.days(7), + retention_period=external_sns_event_queue_retention_period, dead_letter_queue=sqs.DeadLetterQueue( max_receive_count=2, queue=self.external_sns_event_dlq, @@ -114,9 +117,7 @@ def __init__( queue=self.external_sns_event_queue, report_batch_item_failures=True, filters=external_sns_event_queue_filters, - enabled=(env_base.env_type is EnvType.PROD) - if sqs_event_source_enabled is None - else sqs_event_source_enabled, + enabled=sqs_event_source_enabled, ) ) self.external_sns_event_queue.grant_consume_messages(triggered_lambda_fn)