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.
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.
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.