s3cmd fails on first upload attempt

s3cmd fails on first upload attempt

Noticed this with a script that called s3cmd.  The first upload attempt would fail and then an automatic second attempt would complete successfully.

zzz is just a bit of obfuscation.

# s3cmd  put zzz.json s3://zzz/zzz.json
upload: 'zzz.json' -> 's3://zzz/zzz.json'  [1 of 1]
 189 of 189   100% in    0s     4.27 kB/s  done
upload: 'zzz.json' -> 's3://zzz/zzz.json'  [1 of 1]
 189 of 189   100% in    0s  1524.66 B/s  done

Running the command with the -v flagged:

DEBUG: Response: {'status': 400, 'headers': {'x-amz-id-2': ..zzz..
<Message>The authorization header is malformed; the region \'US\' is wrong; 
expecting \'us-east-1\'</Message><Region>us-east-1</Region>..zzz...</Error>', 
'size': 189L}

The original configuration wizard added the US as the region in .s3cfg.

So simply updating .s3cfg with the the proper region corrected the issue:

bucket_location = us-east-1

and rerun goes well:

# s3cmd put zzz.json s3://zzz/zzz.json
upload: 'zzz.json' -> 's3://zzz/zzz.json' [1 of 1]
 189 of 189 100% in 0s 1538.00 B/s done