Class: Kitchen::Terraform::Driver::Create
- Inherits:
-
Object
- Object
- Kitchen::Terraform::Driver::Create
- Defined in:
- lib/kitchen/terraform/driver/create.rb
Overview
A Test Kitchen instance is created through the following steps.
Initializing the Terraform Working Directory
The working directory is initialized by running a command like the following example:
terraform init \
-input=false \
-lock=<lock> \
-lock-timeout=<lock_timeout>s \
[-no-color] \
[-upgrade] \
-force-copy \
-backend=true \
[-backend-config=<backend_configurations[0]> ...] \
-get=true \
-get-plugins=true \
[-plugin-dir=<plugin_directory>] \
-verify-plugins=true \
<root_module_directory>
Creating or Selecting the Test Terraform Workspace
The workspace is created by running a command like the following example:
terraform workspace new <name>
The workspace is selected by running a command like the following example:
terraform workspace select <name>
Instance Method Summary collapse
-
#call ⇒ self
#call executes the action.
-
#initialize(config:, logger:, version_requirement:, workspace_name:) ⇒ Kitchen::Terraform::Driver::Create
constructor
#initialize prepares a new instance of the class.
Constructor Details
#initialize(config:, logger:, version_requirement:, workspace_name:) ⇒ Kitchen::Terraform::Driver::Create
#initialize prepares a new instance of the class.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/kitchen/terraform/driver/create.rb', line 60 def initialize(config:, logger:, version_requirement:, workspace_name:) hash_config = config.to_hash.merge upgrade_during_init: true, workspace_name: workspace_name self.command_executor = ::Kitchen::Terraform::CommandExecutor.new( client: config.fetch(:client), logger: logger, ) self.init = ::Kitchen::Terraform::Command::Init.new config: hash_config self.logger = logger self. = { cwd: config.fetch(:root_module_directory), timeout: config.fetch(:command_timeout) } self.workspace_name = workspace_name self.workspace_new = ::Kitchen::Terraform::Command::WorkspaceNew.new config: hash_config self.workspace_select = ::Kitchen::Terraform::Command::WorkspaceSelect.new config: hash_config self.verify_version = ::Kitchen::Terraform::VerifyVersion.new( command_executor: command_executor, config: config, logger: logger, version_requirement: version_requirement, ) self.version = ::Kitchen::Terraform::Command::Version.new end |
Instance Method Details
#call ⇒ self
#call executes the action.
44 45 46 47 48 49 50 |
# File 'lib/kitchen/terraform/driver/create.rb', line 44 def call verify_version.call command: version, options: initialize_directory create_or_select_workspace self end |