@@ -89,7 +89,7 @@ def test_secrets_manager_different_region_but_still_fips(self, mock_boto3_client
8989
9090 @patch ("datadog_lambda.config.Config.fips_mode_enabled" , True )
9191 @patch ("botocore.session.Session.create_client" )
92- def test_ssm_fips_endpoint (self , mock_boto3_client ):
92+ def test_ssm_fips_endpoint_supported_region (self , mock_boto3_client ):
9393 mock_client = MagicMock ()
9494 mock_client .get_parameter .return_value = {
9595 "Parameter" : {"Value" : "test-api-key" }
@@ -124,6 +124,30 @@ def test_ssm_gov_endpoint(self, mock_boto3_client):
124124 mock_boto3_client .assert_called_with ("ssm" , endpoint_url = None )
125125 self .assertEqual (api_key , "test-api-key" )
126126
127+ @patch ("datadog_lambda.config.Config.fips_mode_enabled" , True )
128+ @patch ("botocore.session.Session.create_client" )
129+ def test_ssm_fips_endpoint_unsupported_region (self , mock_boto3_client ):
130+ mock_client = MagicMock ()
131+ mock_client .get_parameter .return_value = {
132+ "Parameter" : {"Value" : "test-api-key" }
133+ }
134+ mock_boto3_client .return_value = mock_client
135+
136+ os .environ ["AWS_REGION" ] = "eu-west-1"
137+ os .environ ["DD_API_KEY_SSM_NAME" ] = "test-ssm-param"
138+
139+ with self .assertLogs ("datadog_lambda.api" , level = "WARNING" ) as log_context :
140+ api_key = api .get_api_key ()
141+
142+ mock_boto3_client .assert_called_with ("ssm" , endpoint_url = None )
143+ self .assertEqual (api_key , "test-api-key" )
144+ self .assertTrue (
145+ any (
146+ "does not support SSM FIPS endpoints" in log_msg
147+ for log_msg in log_context .output
148+ )
149+ )
150+
127151 @patch ("datadog_lambda.config.Config.fips_mode_enabled" , True )
128152 @patch ("botocore.session.Session.create_client" )
129153 @patch ("datadog_lambda.api.decrypt_kms_api_key" )
0 commit comments