2021-01-22 01:08:52 -05:00
# 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
2021-06-08 11:10:00 -04:00
logger = Logger . new ( $stdout )
2021-01-22 01:08:52 -05:00
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
2021-04-26 08:09:44 -04:00
rescue StandardError = > e
2021-01-22 01:08:52 -05:00
logger . error ( " Failed to migrate: #{ e . message } " )
end
end
end
end