Reputation: 387
Currently, I am trying to connect to AWS from an Ubuntu 14 VM running inside a Windows 8 OS. In the Ubuntu shell, I run:
$AWS_ACCESS_KEY=my_access_key
$AWS_SECRET_ACCESS_KEY=my_secret_key
$python
$export AWS_ACCESS_KEY
$export AWS_SECRET_ACCESS_KEY
$python
>>>import os
>>>from boto import ec2
>>>auth = {"aws_access_key_id":os.environ.get("AWS_ACCESS_KEY"),
>>>"aws_secret_access_key":os.environ.get("AWS_SECRET_ACCESS_KEY")}
>>>conn = ec2.connect_to_region("us-east-1", **auth)
>>>conn.get_all_instances()
The error message I get is
boto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized
AuthFailure
AWS was not able to validate the provided access credentials
At first I thought that my credentials weren't being provided correctly. However, in Windows:
C:\>SET AWS_ACCESS_KEY=my_access_key
C:\>SET AWS_SECRET_ACCESS_KEY=my_secret_key
C:\>python
>>>import os
>>>from boto import ec2
>>>auth = {"aws_access_key_id":os.environ.get("AWS_ACCESS_KEY"),
>>>"aws_secret_access_key":os.environ.get("AWS_SECRET_ACCESS_KEY")}
>>>conn = ec2.connect_to_region("us-east-1", **auth)
>>>conn.get_all_instances()
Returns all of the reservations as expected. I compared the value of auth from both Python shells, and they are the same. The Python and boto versions appear to be the same. I haven't tried using a boto config file, but I would prefer not to, as this is a component of a script that should be deployable by multiple users in my organization.
Is there a better way to pass my authentication? Is there some nuance to Linux/Windows that I'm missing?
Upvotes: 1
Views: 228
Reputation: 451
I had this issue, and it was actually a very simple problem I hadn't even thought of. AWS will give a credentials issue (even if the bucket is public access) if the system is missing the config file in the .aws directory. I used WinSCP to transfer the .aws file from my home directory on windows to my home directory on the linux system and it ran without issues
Upvotes: 2
Reputation: 9481
The new convention is to use AWS_ACCESS_KEY_ID
not AWS_ACCESS_KEY
probably you have an older version of Boto on your Windows machine.
Upvotes: 1