Remove s3 bucket check in `migrate_to_s3` task.

Remove s3 bucket check in migrate_to_s3 task.

Bucket creation is expected to be handled by the user. If the bucket does not exist, the script will fail anyway.

diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake
index 852075c..05105f5 100644
--- a/lib/tasks/uploads.rake
+++ b/lib/tasks/uploads.rake
@@ -258,13 +258,6 @@ def migrate_to_s3
     bucket, folder = ENV["DISCOURSE_S3_BUCKET"], ""
   end
 
-  begin
-    s3.head_bucket(bucket: bucket)
-  rescue Aws::S3::Errors::NotFound
-    puts "Bucket '#{bucket}' not found. Creating it..."
-    s3.create_bucket(bucket: bucket) unless dry_run
-  end
-
   puts "Uploading files to S3..."
   print " - Listing local files"

GitHub sha: 979d03aa

Does it show an actionnable error message when the bucket does not exist?

Hmmm yeah the current error message is nice @tgxworld, lets simply keep puts "Bucket '#{bucket}' not found. and throw away the creation part and exit 1 from the script.

1 Like

The keys that we use are given permission for a particular folder in the bucket. Therefore, the keys will not be able to do head_bucket.

3 Likes

I see, ok lets close this off then