diff --git a/lambda_functions/vetext_incoming_forwarder_lambda/vetext_incoming_forwarder_lambda.py b/lambda_functions/vetext_incoming_forwarder_lambda/vetext_incoming_forwarder_lambda.py index 695ca087fe..b9b54cf194 100644 --- a/lambda_functions/vetext_incoming_forwarder_lambda/vetext_incoming_forwarder_lambda.py +++ b/lambda_functions/vetext_incoming_forwarder_lambda/vetext_incoming_forwarder_lambda.py @@ -36,7 +36,7 @@ def vetext_incoming_forwarder_lambda_handler(event: dict, context: any): logger.debug(event) push_to_dead_letter_sqs(event, "vetext_incoming_forwarder_lambda_handler") - return create_twilio_response(400) + return create_twilio_response() logger.info("Successfully processed event to event_bodies") logger.debug(event_bodies) @@ -61,10 +61,10 @@ def vetext_incoming_forwarder_lambda_handler(event: dict, context: any): logger.exception(e) push_to_dead_letter_sqs(event, "vetext_incoming_forwarder_lambda_handler") - return create_twilio_response(500) + return create_twilio_response() -def create_twilio_response(status_code): +def create_twilio_response(status_code: int = 200): twiml_response = '' response = { @@ -143,11 +143,15 @@ def read_from_ssm(key: str) -> str: try: ssm_client = boto3.client('ssm') + logger.info("Generated ssm_client") + response = ssm_client.get_parameter( Name=key, WithDecryption=True ) + logger.info("received ssm parameter") + return response.get("Parameter", {}).get("Value", '') except Exception as e: logger.error("General Exception With Call to VeText") @@ -206,7 +210,7 @@ def make_vetext_request(request_body): connection = None try: - connection = http.client.HTTPSConnection(domain, context=ssl._create_unverified_context()) + connection = http.client.HTTPSConnection(domain, timeout=6, context=ssl._create_unverified_context()) logger.info("generated connection to VeText") connection.request( diff --git a/tests/lambda_functions/vetext_incoming_forwarder_lambda/test_vetext_incoming_forwarder_lambda.py b/tests/lambda_functions/vetext_incoming_forwarder_lambda/test_vetext_incoming_forwarder_lambda.py index c5da2c653b..ba4dc74a0f 100644 --- a/tests/lambda_functions/vetext_incoming_forwarder_lambda/test_vetext_incoming_forwarder_lambda.py +++ b/tests/lambda_functions/vetext_incoming_forwarder_lambda/test_vetext_incoming_forwarder_lambda.py @@ -127,7 +127,7 @@ def test_failed_sqs_invocation_call_throws_general_exception_goes_to_retry_sqs(m mocker.patch(f'{LAMBDA_MODULE}.process_body_from_sqs_invocation', side_effect=Exception) response = vetext_incoming_forwarder_lambda_handler(event, None) - assert response['statusCode'] == 500 + assert response['statusCode'] == 200 sqs_mock.assert_not_called() @pytest.mark.parametrize('event', [(albInvokedWithoutAddOn), (albInvokeWithAddOn)]) @@ -136,7 +136,7 @@ def test_failed_alb_invocation_call_throws_general_exception_goes_to_retry_sqs(m mocker.patch(f'{LAMBDA_MODULE}.process_body_from_alb_invocation', side_effect=Exception) response = vetext_incoming_forwarder_lambda_handler(event, None) - assert response['statusCode'] == 500 + assert response['statusCode'] == 200 assert response['body'] == '' sqs_mock.assert_not_called() @@ -182,7 +182,7 @@ def test_unexpected_event_received(mocker, all_path_env_param_set): event = {} response = vetext_incoming_forwarder_lambda_handler(event, None) - assert response['statusCode'] == 400 + assert response['statusCode'] == 200 assert response['body'] == '' sqs_dead_letter_mock.assert_called_once()