From f36646d0a379869cab0072c343b6ed01c5d018c4 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Tue, 30 Apr 2019 12:09:15 +0200 Subject: [PATCH 1/2] Store S3 keys in Config before calling db2fog This ensures that Db2fog always picks up the latest value of the S3_* env vars and not the one that was persisted last time. Now you can do things like `S3_BUCKET=xxx bundle exec rake db2fog:backup` if you had to. --- config/initializers/db2fog.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/initializers/db2fog.rb b/config/initializers/db2fog.rb index 1e05ceae1a..acaafdc5a2 100644 --- a/config/initializers/db2fog.rb +++ b/config/initializers/db2fog.rb @@ -1,3 +1,5 @@ +require_relative 'spree' + # See: https://github.com/yob/db2fog DB2Fog.config = { :aws_access_key_id => Spree::Config[:s3_access_key], From d5b08c602a00ef9a5f773864bdb6f09c61ffc85d Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Tue, 30 Apr 2019 12:29:04 +0200 Subject: [PATCH 2/2] Allow passing a specific AWS region to S3 settings This solves the error showed below when executed `bundle exec rake db2fog:backup RAILS_ENV=staging` on Katuma staging ``` Excon::Error::BadRequest: Expected(200) <=> Actual(400 Bad Request) excon.error.response :body => "\nAuthorizationHeaderMalformedThe authorization header is malformed; the region 'us-east-1' is wrong; expecting 'eu-central-1'eu-central-13DE2763883FC601D1E6UapnblBqVZM0SeeLrdPNDd+VaQ0nxCWwrQ9mi8HjRo2xevAUwtSq5V3fxhsj4Cj9ynnDroco=" ``` --- config/initializers/db2fog.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/initializers/db2fog.rb b/config/initializers/db2fog.rb index acaafdc5a2..3e1ed96202 100644 --- a/config/initializers/db2fog.rb +++ b/config/initializers/db2fog.rb @@ -7,3 +7,5 @@ DB2Fog.config = { :directory => ENV['S3_BACKUPS_BUCKET'], :provider => 'AWS' } + +DB2Fog.config[:region] = ENV['S3_REGION'] if ENV['S3_REGION']