Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions awscli/customizations/agenttoolkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/customizations/agenttoolkit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 == []
Loading