-
-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move from Azure to AWS S3 for blob storage #5023
base: main
Are you sure you want to change the base?
Conversation
@@ -6,18 +8,12 @@ task :backup_db_rds => :environment do | |||
current_time = Time.current.strftime("%Y%m%d%H%M%S") | |||
|
|||
logger.info("Copying the database...") | |||
backup_filename = "#{current_time}.rds.dump" | |||
backup_filename = "#{Rails.env}-#{current_time}.rds.dump" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
storage_account_name: account_name, | ||
storage_access_key: account_key | ||
) | ||
client = Aws::S3::Client.new(region: 'us-east-2') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the same as
client = ActiveStorage::Blob.services.fetch(:amazon)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically. In this case I'm going straight to the client rather than doing it in a roundabout way through ActiveStorage.
Is CORS enabled on S3? Will be needed for direct uploads, introduced here: #4937 |
Yep, it should be! |
class MoveAzureBlobsToS3 < ActiveRecord::Migration[7.2] | ||
# https://stackoverflow.com/questions/71699789/activestorage-transfer-all-assets-from-one-bucket-to-another-bucket | ||
def up | ||
return unless Rails.env.staging? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so only run this migration in staging. I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good!
We'll let @cielf merge as part of a controlled staging validation (upload files, merge this, see that they're still there, upload more files) |
I was hoping to get to this today but life interfered. Hopefully Friday. |
This PR does the following:
amazon
storage provider. I've set up blob storage buckets for both production and staging.amazon
for staging only for now.My suggestion for testing:
Once testing is complete, this branch is safe to merge, and we can put in a further PR that will apply these changes to prod.