Strange 301 Error AWS CLI S3 copy

Recently I was setting up a new region and had some automation in my config management to configure the region portion of the .aws config on a Linux box. When I attempted to pull an asset from the S3 bucket I got the following error:

A client error (301) occurred when calling the HeadObject operation: Moved Permanently

This is a really misleading error message. the actual problem here is that the region in the AWS config doesn’t match the region that the bucket lives in. You can solve this a few different ways but the easiest is to either pass the region in your aws s3 cp command or if you are only using buckets and assets from that same region you can update your region= line of the config.