diff --git a/monkey/monkey_island/cc/resources/remote_run.py b/monkey/monkey_island/cc/resources/remote_run.py index 64dcb9fbf..b1b2d5f7b 100644 --- a/monkey/monkey_island/cc/resources/remote_run.py +++ b/monkey/monkey_island/cc/resources/remote_run.py @@ -45,15 +45,11 @@ class RemoteRun(flask_restful.Resource): body = json.loads(request.data) resp = {} if body.get('type') == 'aws': - #is_auth = RemoteRunAwsService.update_aws_auth_params() - #resp['auth'] = is_auth - #if is_auth: - # result = self.run_aws_monkeys(body) - # resp['result'] = result - #else: - RemoteRunAwsService.update_aws_region_authless() - result = self.run_aws_monkeys(body) - resp['result'] = result + is_auth = RemoteRunAwsService.update_aws_auth_params() + resp['auth'] = is_auth + if is_auth: + result = self.run_aws_monkeys(body) + resp['result'] = result return jsonify(resp) # default action diff --git a/monkey/monkey_island/cc/services/remote_run_aws.py b/monkey/monkey_island/cc/services/remote_run_aws.py index 6d206e6e4..019db10d3 100644 --- a/monkey/monkey_island/cc/services/remote_run_aws.py +++ b/monkey/monkey_island/cc/services/remote_run_aws.py @@ -51,6 +51,8 @@ class RemoteRunAwsService: Updates the AWS authentication parameters according to config :return: True if new params allow successful authentication. False otherwise """ + AwsService.set_region(RemoteRunAwsService.aws_instance.region) + access_key_id = ConfigService.get_config_value(['cnc', 'aws_config', 'aws_access_key_id'], False, True) secret_access_key = ConfigService.get_config_value(['cnc', 'aws_config', 'aws_secret_access_key'], False, True) @@ -58,8 +60,6 @@ class RemoteRunAwsService: AwsService.set_auth_params(access_key_id, secret_access_key) RemoteRunAwsService.is_auth = AwsService.test_client() - AwsService.set_region(RemoteRunAwsService.aws_instance.region) - return RemoteRunAwsService.is_auth @staticmethod