awslabs / aws-config-rdk

The AWS Config Rules Development Kit helps developers set up, author and test custom Config rules. It contains scripts to enable AWS Config, create a Config rule and test it with sample ConfigurationItems.
https://aws-config-rdk.readthedocs.io
Apache License 2.0
461 stars 172 forks source link

Error handling when no/invalid credentials present #118

Open rafihm opened 6 years ago

rafihm commented 6 years ago

currenly RDK throws below stack trace if no/invalid credentials are specified. A proper error message would be nice.

root@ip-172-31-43-115:~# rdk init Running init! Traceback (most recent call last): File "/usr/local/bin/rdk", line 33, in return_val = my_rdk.process_command() File "/usr/local/lib/python2.7/dist-packages/rdk/rdk.py", line 68, in process_command exit_code = method_to_call() File "/usr/local/lib/python2.7/dist-packages/rdk/rdk.py", line 93, in init my_config = my_session.client('config') File "/usr/local/lib/python2.7/dist-packages/boto3/session.py", line 263, in client aws_session_token=aws_session_token, config=config) File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 889, in create_client client_config=config, api_version=api_version) File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 76, in create_client verify, credentials, scoped_config, client_config, endpoint_bridge) File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 291, in _get_client_args verify, credentials, scoped_config, client_config, endpoint_bridge) File "/usr/local/lib/python2.7/dist-packages/botocore/args.py", line 45, in get_client_args endpoint_url, is_secure, scoped_config) File "/usr/local/lib/python2.7/dist-packages/botocore/args.py", line 112, in compute_client_args service_name, region_name, endpoint_url, is_secure) File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 364, in resolve service_name, region_name) File "/usr/local/lib/python2.7/dist-packages/botocore/regions.py", line 122, in construct_endpoint partition, service_name, region_name) File "/usr/local/lib/python2.7/dist-packages/botocore/regions.py", line 135, in _endpoint_for_partition raise NoRegionError() botocore.exceptions.NoRegionError: You must specify a region.

mingteoh commented 4 years ago

rdk 0.7.10 and i am seeing same error today.

update: it seems like only default profile will work, other named profiles will not even if prefix command with AWS_PROFILE=xxx

gauravjain77 commented 1 year ago

I am still facing this issue. Do we have any solution to fix this ?

bmorrissirromb commented 1 year ago

Possible design here: Wrap return Session(**session_args) with a try-except. Raise a user-oriented exception if it fails.