How can I rename an existing AWS S3 Bucket, for example if I need it to match a redirect (CNAME), and it already contains a bunch of migrated files?
You can’t! It’s not possible to rename buckets in S3 as that functionality doesn’t exist. The following code will do the following, however (without necessitating that you upload all those files again): 1) Create a new bucket; 2) Copy files from the old bucket directly into the new bucket just created; 3) Delete the old bucket:
aws s3 mb s3://[new-bucket]
aws s3 sync s3://[old-bucket] s3://[new-bucket]
aws s3 rb –force s3://[old-bucket]