Class: TerraformWrapper::Tasks::Import
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- TerraformWrapper::Tasks::Import
- Includes:
- Shared::Logging
- Defined in:
- lib/terraform-wrapper/tasks/import.rb
Instance Method Summary collapse
- #import_task ⇒ Object
-
#initialize(binary:, code:, options:) {|_self| ... } ⇒ Import
constructor
A new instance of Import.
Methods included from Shared::Logging
configure_logger_for, logger_for
Constructor Details
#initialize(binary:, code:, options:) {|_self| ... } ⇒ Import
Returns a new instance of Import.
22 23 24 25 26 27 28 29 30 |
# File 'lib/terraform-wrapper/tasks/import.rb', line 22 def initialize(binary:, code:, options:) @binary = binary @code = code @options = yield self if block_given? import_task end |
Instance Method Details
#import_task ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/terraform-wrapper/tasks/import.rb', line 34 def import_task desc 'Import a piece of existing infrastructure into Terraform state for a given configuration on an infrastructure component.' task :import, %i[config address id] => :binary do |_t, args| = @options.merge({ 'name' => args[:config] }) logger.info('Processing configuration for Terraform import...') config = TerraformWrapper::Shared::Config.new(code: @code, options: ) runner = TerraformWrapper::Shared::Runner.new(binary: @binary, code: @code) logger.info("Running Terraform import for service: #{config.service}, component: #{@code.name}...") runner.init(config: config) runner.import(address: args[:address], id: args[:id]) end end |