From 2da6e023e148e230262c1728e44c9220861fa3f7 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 9 May 2022 10:25:13 -0400 Subject: [PATCH] Island: Construct and register AWSService in the composition root --- monkey/monkey_island/cc/services/initialize.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/monkey/monkey_island/cc/services/initialize.py b/monkey/monkey_island/cc/services/initialize.py index bcc11676d..8e0540329 100644 --- a/monkey/monkey_island/cc/services/initialize.py +++ b/monkey/monkey_island/cc/services/initialize.py @@ -1,9 +1,8 @@ from pathlib import Path -from threading import Thread from common import DIContainer from common.aws import AWSInstance -from monkey_island.cc.services import DirectoryFileStorageService, IFileStorageService, aws_service +from monkey_island.cc.services import AWSService, DirectoryFileStorageService, IFileStorageService from monkey_island.cc.services.post_breach_files import PostBreachFilesService from monkey_island.cc.services.run_local_monkey import LocalMonkeyRunService @@ -12,13 +11,12 @@ from . import AuthenticationService, JsonFileUserDatastore def initialize_services(data_dir: Path) -> DIContainer: container = DIContainer() + container.register_instance(AWSInstance, AWSInstance()) + container.register_instance( IFileStorageService, DirectoryFileStorageService(data_dir / "custom_pbas") ) - container.register_instance(AWSInstance, AWSInstance()) - - # Takes a while so it's best to start it in the background - Thread(target=aws_service.initialize, name="AwsService initialization", daemon=True).start() + container.register_instance(AWSService, container.resolve(AWSService)) # This is temporary until we get DI all worked out. PostBreachFilesService.initialize(container.resolve(IFileStorageService))