diff --git a/awscli/customizations/agenttoolkit/utils.py b/awscli/customizations/agenttoolkit/utils.py index 3caa354c20c9..21611068342f 100644 --- a/awscli/customizations/agenttoolkit/utils.py +++ b/awscli/customizations/agenttoolkit/utils.py @@ -75,6 +75,11 @@ def create_client(session, parsed_globals): overrides = {} if not getattr(parsed_globals, 'region', None): + LOG.debug( + 'No --region given, using %s, the only region Agent Toolkit ' + 'is available in.', + AGENT_TOOLKIT_REGION, + ) overrides['region_name'] = AGENT_TOOLKIT_REGION return create_client_from_parsed_globals( session, diff --git a/tests/unit/customizations/agenttoolkit/test_utils.py b/tests/unit/customizations/agenttoolkit/test_utils.py index d4cd5f448bb6..dbd2fbc3927c 100644 --- a/tests/unit/customizations/agenttoolkit/test_utils.py +++ b/tests/unit/customizations/agenttoolkit/test_utils.py @@ -10,6 +10,7 @@ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. +import logging from argparse import Namespace from unittest.mock import MagicMock @@ -34,3 +35,18 @@ def test_defaults_region_when_none_configured(): def test_honors_explicit_region(): args = _create_client(region='us-west-2') assert args.kwargs.get('region_name') == 'us-west-2' + + +def test_logs_when_defaulting_region(caplog): + with caplog.at_level(logging.DEBUG): + _create_client(region=None) + assert caplog.messages == [ + 'No --region given, using us-east-1, the only region Agent Toolkit ' + 'is available in.' + ] + + +def test_does_not_log_with_explicit_region(caplog): + with caplog.at_level(logging.DEBUG): + _create_client(region='us-west-2') + assert caplog.messages == []