awslogs
awslogs copied to clipboard
Can't use non-default profile
awslogs get
works if I replace my default profile with the profile I want to use, but doesn't if I try to specify the profile with the args --profile
.
Version: 0.14.0
Python: 3.9.0 (default, Nov 14 2020, 10:50:03)
[Clang 12.0.0 (clang-1200.0.32.27)]
boto3 version: 1.14.20
Platform: macOS-11.0.1-x86_64-i386-64bit
Args: ['/usr/local/bin/awslogs', 'get', '/aws/lambda/dev-notify-freshservice', '--watch', '--profile', 'amp-dev-peter', '--region', 'eu-west-1']
Config: {'aws_access_key_id': 'SENSITIVE', 'aws_secret_access_key': 'SENSITIVE', 'aws_session_token': 'SENSITIVE', 'aws_profile': 'SENSITIVE', 'aws_region': None, 'aws_endpoint_url': None, 'log_group_name': '/aws/lambda/dev-notify-freshservice', 'log_stream_name': 'ALL', 'filter_pattern': None, 'watch': True, 'watch_interval': 1, 'output_group_enabled': True, 'output_stream_enabled': True, 'output_timestamp_enabled': False, 'output_ingestion_time_enabled': False, 'start': '5m', 'end': None, 'color': 'auto', 'query': None, 'func': 'list_logs'}
Traceback (most recent call last):
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/awslogs/bin.py", line 175, in main
logs = AWSLogs(**vars(options))
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/awslogs/core.py", line 89, in __init__
self.client = boto3_client(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/awslogs/core.py", line 44, in boto3_client
return session.client(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/boto3/session.py", line 258, in client
return self._session.create_client(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/botocore/session.py", line 831, in create_client
client = client_creator.create_client(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/botocore/client.py", line 83, in create_client
client_args = self._get_client_args(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/botocore/client.py", line 285, in _get_client_args
return args_creator.get_client_args(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/botocore/args.py", line 71, in get_client_args
final_args = self.compute_client_args(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/botocore/args.py", line 147, in compute_client_args
endpoint_config = self._compute_endpoint_config(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/botocore/args.py", line 218, in _compute_endpoint_config
return self._resolve_endpoint(**resolve_endpoint_kwargs)
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/botocore/args.py", line 300, in _resolve_endpoint
return endpoint_bridge.resolve(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/botocore/client.py", line 360, in resolve
resolved = self.endpoint_resolver.construct_endpoint(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/botocore/regions.py", line 133, in construct_endpoint
result = self._endpoint_for_partition(
File "/usr/local/Cellar/awslogs/0.14.0_1/libexec/lib/python3.9/site-packages/botocore/regions.py", line 148, in _endpoint_for_partition
raise NoRegionError()
botocore.exceptions.NoRegionError: You must specify a region.
i also found this issue, and resolved it by editing ~/.aws/config
and making sure my non-default profile had a region set in there by adding this:
[profile myotherprofile]
region=eu-west-2
I double check --profile argument and found out is working as expected.
# ~/.aws/config
[default]
output = json
region = us-east-1
# ~/.aws/credentials
[default]
aws_access_key_id = XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXXXXX
[develop]
aws_access_key_id = XXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXX
Then in command line
awslogs groups --profile develop
The --profile
option works fine for me. Recommend closing this ticket. Unless @petercoulton objects.