jorgebastida / jorgebastida/awslogs

NoRegionError when default region defined in config file

Open
#401 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5k
Forks
342
PR merge metrics
No merged PRs in 30d

Description

awslogs produces a NoRegionError when using an AWS profile that has a default region defined in ~/.aws/config but no region defined in the profile's section in ~/.aws/credentials. No error is produced after adding the region in the profile's section in the credentials file.

Version: 0.15.0
Python: 3.9.18 (main, Jan 24 2024, 16:34:55)
[Clang 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc1238
boto3 version: 1.34.131
Platform: FreeBSD-13.2-RELEASE-p11-amd64-64bit-ELF
Args: ['/home/myusername/.local/bin/awslogs', 'get', '/aws/lambda/nameofmylambda, '-s1h', '--profile', 'myusername-cli']
Config: {options}

Traceback (most recent call last):
File "/home/myusername/.local/lib/python3.9/site-packages/awslogs/bin.py", line 206, in main
logs = AWSLogs(**vars(options))
File "/home/myusername/.local/lib/python3.9/site-packages/awslogs/core.py", line 88, in init
self.client = boto3_client(
File "/home/myusername/.local/lib/python3.9/site-packages/awslogs/core.py", line 45, in boto3_client
return session.client(
File "/home/myusername/.local/lib/python3.9/site-packages/boto3/session.py", line 297, in client
return self._session.create_client(
File "/home/myusername/.local/lib/python3.9/site-packages/botocore/session.py", line 997, in create_client
client = client_creator.create_client(
File "/home/myusername/.local/lib/python3.9/site-packages/botocore/client.py", line 161, in create_client
client_args = self._get_client_args(
File "/home/myusername/.local/lib/python3.9/site-packages/botocore/client.py", line 520, in _get_client_args
return args_creator.get_client_args(
File "/home/myusername/.local/lib/python3.9/site-packages/botocore/args.py", line 100, in get_client_args
final_args = self.compute_client_args(
File "/home/myusername/.local/lib/python3.9/site-packages/botocore/args.py", line 219, in compute_client_args
endpoint_config = self._compute_endpoint_config(
File "/home/myusername/.local/lib/python3.9/site-packages/botocore/args.py", line 369, in _compute_endpoint_config
return self._resolve_endpoint(**resolve_endpoint_kwargs)
File "/home/myusername/.local/lib/python3.9/site-packages/botocore/args.py", line 474, in _resolve_endpoint
return endpoint_bridge.resolve(
File "/home/myusername/.local/lib/python3.9/site-packages/botocore/client.py", line 625, in resolve
resolved = self.endpoint_resolver.construct_endpoint(
File "/home/myusername/.local/lib/python3.9/site-packages/botocore/regions.py", line 229, in construct_endpoint
result = self._endpoint_for_partition(
File "/home/myusername/.local/lib/python3.9/site-packages/botocore/regions.py", line 277, in _endpoint_for_partition
raise NoRegionError()
botocore.exceptions.NoRegionError: You must specify a region.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in awslogs/core.py at boto3_client around line 45 and AWSLogs initialization around line 88, then reproduce the command with a profile whose region is only in ~/.aws/config. Check how the session and client receive the profile and region, and verify that the command succeeds without duplicating the region in ~/.aws/credentials.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.