captainblack
captainblack

Reputation: 4425

AWS CLI: copy command fails when copying from instance to bucket

I have two EC2 instances running in a custom VPC, with one running Ubuntu 16.04 and the other running Amazon Linux 2017.03. I have also assigned a IAM Role that allows read and write access to all S3 buckets.

However when I try to run the copy command, to copy a file from the instance to the S3 bucket, it fails on the Ubuntu server. The command I run on both servers is:

aws s3 cp /myfolder/myfile.txt s3://mybucket/backups/

It gives the following error on Ubuntu:

upload failed: ../../myfolder/myfile.txt to s3://mybucket/backups/myfile.txt seek() takes 2 positional arguments but 3 were given

Everything else works, for example, downloading a file from the bucket to the server through the copy command. There is no problem in the VPC setting and neither the IAM Role nor the Security Group, since the same applies to the other server running Amazon Linux.

PS: Running the copy command with the --dryrun switch gives no error on the Ubuntu server.

Upvotes: 3

Views: 4099

Answers (2)

music_piano
music_piano

Reputation: 698

I have the same issue. The problem is I used the Ubuntu package manager to install the aws package. We should use this command to install the aws command:

pip3 install awscli --upgrade --user

for more information, see Installing, updating, and uninstalling the AWS CLI in the documentation.

Upvotes: 0

Ravi
Ravi

Reputation: 982

Most likely it's python version and aws cli version mismatch issue. Post aws cli version and python version

python -V
aws --version

Install awscli with pip only so that it gets proper python version.

pip install awscli

Ref: github.com/aws/aws-cli/issues/2403

Upvotes: 7

Related Questions