FIX: migrate_to_s3 wasn't IAM profile aware

FIX: migrate_to_s3 wasn’t IAM profile aware

diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake
index 59998e9..dcd8c30 100644
--- a/lib/tasks/uploads.rake
+++ b/lib/tasks/uploads.rake
@@ -316,17 +316,25 @@ def migrate_to_s3
     exit 1
   end
 
-  unless ENV["DISCOURSE_S3_SECRET_ACCESS_KEY"].present? &&
+  unless ENV["DISCOURSE_S3_BUCKET"].present? &&
     ENV["DISCOURSE_S3_REGION"].present? &&
-    ENV["DISCOURSE_S3_ACCESS_KEY_ID"].present? &&
-    ENV["DISCOURSE_S3_SECRET_ACCESS_KEY"].present?
+    (
+      (
+        ENV["DISCOURSE_S3_ACCESS_KEY_ID"].present? &&
+        ENV["DISCOURSE_S3_SECRET_ACCESS_KEY"].present?
+      ) ||
+      ENV["DISCOURSE_S3_USE_IAM_PROFILE"].present?
+    )
 
     puts <<~TEXT
       Please provide the following environment variables
         - DISCOURSE_S3_BUCKET
         - DISCOURSE_S3_REGION
+        and either
         - DISCOURSE_S3_ACCESS_KEY_ID
         - DISCOURSE_S3_SECRET_ACCESS_KEY
+        or
+        - DISCOURSE_S3_USE_IAM_PROFILE
     TEXT
     exit 2
   end

GitHub sha: 725588f8

1 Like