Skip to content
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

Cleanup of BatchLaunchTemplate + make External SNS trigger configurable #23

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 17 additions & 3 deletions src/aibs_informatics_cdk_lib/constructs_/external_sns_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = cdk.Duration.days(7),
sqs_event_source_enabled: Optional[bool] = None,
**kwargs,
) -> None:
"""This intended to be a generic CDK construct that defines resources necessary to
Expand Down Expand Up @@ -59,7 +63,17 @@ 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"
)
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"),
Expand All @@ -71,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=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,
Expand Down Expand Up @@ -103,7 +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),
enabled=sqs_event_source_enabled,
)
)
self.external_sns_event_queue.grant_consume_messages(triggered_lambda_fn)
Expand Down
Loading