Reputation: 111
I have bucket in the region EU (London) in S3. I am trying to upload a tar file through command line. At the end it throws an error saying so
A client error (PermanentRedirect) occurred when calling the PutObject operation: The bucket you are attempting to access must be addressed using the specified endpoint.Please send all future requests to this endpoint.
I have correctly configured using aws configure
by giving correct access key and Region. Can someone shed light into this issue
I have created a script to upload database by creating a tar file
HOST=abc.com
DBNAME=db
BUCKET=s3.eu-west-2.amazonaws.com/<bucketname>/
USER=<user>
stamp=`date +"%Y-%m-%d"`
filename="Mgdb_$stamp.tar.gz"
TIME=`/bin/date +%Y-%m-%d-%T`
DEST=/home/$USER/tmp
TAR=$DEST/../$TIME.tar.gz
/bin/mkdir -p $DEST
echo "Backing up $HOST/$DBNAME to s3://$BUCKET/ on $TIME";
/usr/bin/mongodump --host $HOST --port 1234 -u "user" -p "pass" --authenticationDatabase "admin" -o $DEST
/bin/tar czvf $TAR -C $DEST .
/usr/bin/aws s3 cp $TAR s3://$BUCKET/$stamp/$filename
/bin/rm -f $TAR
/bin/rm -rf $DEST
Upvotes: 0
Views: 442
Reputation: 1212
The format for the S3Uri in your script is incorrect. It should be s3://<bucketname>/<prefix>/<filename>
. Then you add the --region
option to specify the bucket region.
$BUCKET=<bucketname>
/usr/bin/aws s3 cp $TAR s3://$BUCKET/$stamp/$filename --region eu-west-2
Upvotes: 0
Reputation: 269470
Just append the region to the AWS Command-Line Interface (CLI) command:
aws s3 cp file.txt s3://my-bucket/file.txt --region eu-west-2
Upvotes: 1