0

I hope to upload text file in aws s3.

import boto3
s3=boto3.client('s3')
s3.upload_file('s3_transfer_file.txt','first-storage-for-practice','s3_script.txt')

Getting this error when running the code above:

An error occurred (InvalidAccessKeyId) when calling the PutObject operation: The AWS Access Key Id you provided does not exist in our records.

What should I do to fix this?

Arkistarvh Kltzuonstev
  • 6,824
  • 7
  • 26
  • 56
Regina Kang
  • 135
  • 2
  • 11
  • 1
    Does this answer your question? [The AWS Access Key Id does not exist in our records](https://stackoverflow.com/questions/39051477/the-aws-access-key-id-does-not-exist-in-our-records) – Amit Baranes Nov 30 '19 at 09:49

2 Answers2

1

Example usage

import boto3
boto3.client('s3' , region_name='us-west-2',aws_access_key_id='ACCESS_KEY_ID',aws_secret_access_key='SECRET')
s3.upload_file('s3_transfer_file.txt','first-storage-for-practice','s3_script.txt')
Ahmed Abdelazim
  • 717
  • 7
  • 14
1

You need to provide your AWS credentials in order to use the services, take a look at https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html

You can do the following:

 import boto3
 s3=boto3.client('s3', your_AWS_AccesKey, your_AWS_SecretKey)
 s3.upload_file('s3_transfer_file.txt','first-storage-for-practice','s3_script.txt')
jacdDev
  • 196
  • 1
  • 8