DevOps Zone is brought to you in partnership with:

Mark is a graph advocate and field engineer for Neo Technology, the company behind the Neo4j graph database. As a field engineer, Mark helps customers embrace graph data and Neo4j building sophisticated solutions to challenging data problems. When he's not with customers Mark is a developer on Neo4j and writes his experiences of being a graphista on a popular blog at http://markhneedham.com/blog. He tweets at @markhneedham. Mark is a DZone MVB and is not an employee of DZone and has posted 529 posts at DZone. You can read more from them at their website. View Full User Profile

Fabric/Boto: boto.exception.NoAuthHandlerFound

01.21.2013
| 2040 views |
  • submit to reddit

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_key
And that should do the trick!
Published at DZone with permission of Mark Needham, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)