In our Fabric code we make use of Boto to connect to the EC2 API and pull back various bits of information and the first time anyone tries to use it they end up with the following stack trace:
File "/Library/Python/2.7/site-packages/fabric/main.py", line 717, in main *args, **kwargs File "/Library/Python/2.7/site-packages/fabric/tasks.py", line 332, in execute results['<local-only>'] = task.run(*args, **new_kwargs) File "/Library/Python/2.7/site-packages/fabric/tasks.py", line 112, in run return self.wrapped(*args, **kwargs) File "/Users/mark/projects/forward-puppet/ec2.py", line 131, in running instances = instances_by_zones(running_instances(region, role_name)) File "/Users/mark/projects/forward-puppet/ec2.py", line 19, in running_instances ec2conn = ec2.connect_to_region(region) File "/Library/Python/2.7/site-packages/boto/ec2/__init__.py", line 57, in connect_to_region for region in regions(**kw_params): File "/Library/Python/2.7/site-packages/boto/ec2/__init__.py", line 39, in regions c = EC2Connection(**kw_params) File "/Library/Python/2.7/site-packages/boto/ec2/connection.py", line 94, in __init__ validate_certs=validate_certs) File "/Library/Python/2.7/site-packages/boto/connection.py", line 936, in __init__ validate_certs=validate_certs) File "/Library/Python/2.7/site-packages/boto/connection.py", line 548, in __init__ host, config, self.provider, self._required_auth_capability()) File "/Library/Python/2.7/site-packages/boto/auth.py", line 633, in get_auth_handler 'Check your credentials' % (len(names), str(names))) boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['QuerySignatureV2AuthHandler'] Check your credentials
We haven’t told Boto about our AWS credentials and I’ve come across two ways of providing them:As environment variables
export AWS_ACCESS_KEY_ID="aws_access_key_id" export AWS_SECRET_ACCESS_KEY="aws_secret_access_key"In the file ~/.boto
[Credentials] aws_access_key_id = aws_access_key_id aws_secret_access_key = aws_secret_access_keyAnd that should do the trick!
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)