Class: Kitchen::Terraform::Driver::Destroy
- Inherits:
-
Object
- Object
- Kitchen::Terraform::Driver::Destroy
- Defined in:
- lib/kitchen/terraform/driver/destroy.rb
Overview
A Test Kitchen instance is destroyed 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>
Selecting or Creating the Test Terraform Workspace
The workspace is selected by running a command like the following example:
terraform workspace select <name>
The workspace is created by running a command like the following example:
terraform workspace new <name>
Destroying the Terraform State
The state is destroyed by running a command like the following example:
terraform destroy \
-auto-approve \
-lock=<lock> \
-lock-timeout=<lock_timeout>s \
-input=false \
[-no-color] \
-parallelism=<parallelism> \
-refresh=true \
[-var=<variables.first>...] \
[-var-file=<variable_files.first>...] \
<root_module_directory>
Selecting the Default Terraform Workspace
The workspace is selected by running a command like the following example:
terraform workspace select <name>
Deleting the Test Terraform Workspace
The workspace is deleted by running a command like the following example:
terraform workspace delete <name>
Instance Method Summary collapse
-
#call ⇒ self
#call executes the action.
-
#initialize(config:, logger:, version_requirement:, workspace_name:) ⇒ Kitchen::Terraform::Driver::Destroy
constructor
#initialize prepares a new instance of the class.
Constructor Details
#initialize(config:, logger:, version_requirement:, workspace_name:) ⇒ Kitchen::Terraform::Driver::Destroy
#initialize prepares a new instance of the class.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/kitchen/terraform/driver/destroy.rb', line 72 def initialize(config:, logger:, version_requirement:, workspace_name:) hash_config = config.to_hash.merge upgrade_during_init: false, workspace_name: workspace_name self.command_executor = ::Kitchen::Terraform::CommandExecutor.new( client: config.fetch(:client), logger: logger, ) self.logger = logger self. = { cwd: config.fetch(:root_module_directory), timeout: config.fetch(:command_timeout) } self.workspace_name = workspace_name self.destroy = ::Kitchen::Terraform::Command::Destroy.new config: config self.init = ::Kitchen::Terraform::Command::Init.new config: hash_config self.workspace_delete_test = ::Kitchen::Terraform::Command::WorkspaceDelete.new config: hash_config self.workspace_new_test = ::Kitchen::Terraform::Command::WorkspaceNew.new config: hash_config self.workspace_select_test = ::Kitchen::Terraform::Command::WorkspaceSelect.new config: hash_config self.workspace_select_default = ::Kitchen::Terraform::Command::WorkspaceSelect.new( config: hash_config.merge(workspace_name: "default"), ) 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.
58 59 60 61 62 63 |
# File 'lib/kitchen/terraform/driver/destroy.rb', line 58 def call verify_version.call command: version, options: execute_workflow self end |