0
 from boto.s3.connection import S3Connection

 AWS_KEY = 'abc'
 AWS_SECRET = 'xyz'

 print AWS_KEY
 print AWS_SECRET

 aws_connection = S3Connection(AWS_KEY, AWS_SECRET)

 print aws_connection


 #Create the bucket in a specific region.

 bucket = aws_connection.create_bucket('mybucket0005',location='us-west-2')

This code i am running for creating bucket;but getting below Error,

Traceback (most recent call last):

File "<ipython-input-63-f14efbf83dc6>", line 16, in <module>
bucket = aws_connection.create_bucket('mybucket0005',location='us-west-2')

File "/usr/local/lib/python2.7/dist-packages/boto/s3/connection.py", line 625, in create_bucket
response.status, response.reason, body)

S3ResponseError: S3ResponseError: 403 Forbidden
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidAccessKeyId</Code><Message>The AWS Access Key Id you     provided does not exist in our records.</Message>
<AWSAccessKeyId>abc</AWSAccessKeyId><RequestId>930E9DC30F239D11</RequestId><HostId>xlaLEeS7C4KYgLOKOShF9uGhLgM+4OdFYiLGn7F5JvKty38kAir5vSNSDH7q5TWFPO/6BEjeHaA=</HostId></Error>

I want to Access AWS S3 Files from Python.Help me out.

0

2 Answers 2

1

The message in this case is quite explicit

The AWS Access Key Id you provided does not exist in our records.

There is no abc key. If you have an AWS account, go to the IAM console and take the key from there: http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html

Even better create a new user that will only be used for CLI. You need to make sure this user will have rights on your s3 bucket (if the goal is to manage that). Once you have the user created, create security credentials that you can use from your script.

Another point: DO NOT EXPOSE YOUR AWS KEY directly in your script. Check the Boto doc on how to manage your credentials and use them from your script.

Sign up to request clarification or add additional context in comments.

6 Comments

access_key = 'AKIAIOSFODNN7EXAMPLE' secret_key = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' I am using this one only..still getting same error.
honestly EXAMPLE in your access_key, I am not saying it can not happen but I really doubt, dont take it from somewhere on the net, take it from your account
Now i am using correct access key from my account only. now its showing this error:(while creating bucket) raise ex gaierror: [Errno -2] Name or service not known
humm .. can you try bucket = aws_connection.create_bucket('mybucket0005', Location.USWest2) I would also recommend you switch to latest boto3 (rather than boto v2)
Now i am able to create bucket..i want to read CSV file now i am using this code : body = obj.get()['Body'].read() not able to read.
|
0

Did you check if your AWS keys are correct? You can use Commandeer App to Test it out from the new/existing account screen. Testing your AWS credentials from Commandeer App

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.