diff options
Diffstat (limited to 'lib/tasks/gitlab/terraform')
-rw-r--r-- | lib/tasks/gitlab/terraform/migrate.rake | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/terraform/migrate.rake b/lib/tasks/gitlab/terraform/migrate.rake new file mode 100644 index 00000000000..a9c16049240 --- /dev/null +++ b/lib/tasks/gitlab/terraform/migrate.rake @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'logger' + +desc "GitLab | Terraform | Migrate Terraform states to remote storage" +namespace :gitlab do + namespace :terraform_states do + task migrate: :environment do + logger = Logger.new(STDOUT) + logger.info('Starting transfer of Terraform states to object storage') + + begin + Gitlab::Terraform::StateMigrationHelper.migrate_to_remote_storage do |state_version| + message = "Transferred Terraform state version ID #{state_version.id} (#{state_version.terraform_state.name}/#{state_version.version}) to object storage" + + logger.info(message) + end + rescue => e + logger.error("Failed to migrate: #{e.message}") + end + end + end +end |