Class: Kitchen::Terraform::Provisioner::Converge
- Inherits:
-
Object
- Object
- Kitchen::Terraform::Provisioner::Converge
- Defined in:
- lib/kitchen/terraform/provisioner/converge.rb
Overview
A Test Kitchen instance is converged through the following steps.
Selecting the Test Terraform Workspace
The workspace is selected by running a command like the following example:
terraform workspace select <name>
Updating the Terraform Dependency Modules
The dependency modules are updated by running a command like the following example:
terraform get -update <directory>
Validating the Terraform Root Module
The root module is validated by running a command like the following example:
terraform validate \
[-no-color] \
[-var=<variables.first>...] \
[-var-file=<variable_files.first>...] \
<directory>
Applying the Terraform State Changes
The state changes are applied by running a command like the following example:
terraform apply\
-lock=<lock> \
-lock-timeout=<lock_timeout>s \
-input=false \
-auto-approve=true \
[-no-color] \
-parallelism=<parallelism> \
-refresh=true \
[-var=<variables.first>...] \
[-var-file=<variable_files.first>...] \
<directory>
Retrieving the Terraform Output
The outputs are retrieved by running a command like the following example:
terraform output -json
Instance Method Summary collapse
-
#call(state:) ⇒ self
#call executes the action.
-
#initialize(config:, logger:, version_requirement:, workspace_name:) ⇒ Kitchen::Terraform::Driver::Converge
constructor
#initialize prepares a new instance of the class.
Constructor Details
#initialize(config:, logger:, version_requirement:, workspace_name:) ⇒ Kitchen::Terraform::Driver::Converge
#initialize prepares a new instance of the class.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/kitchen/terraform/provisioner/converge.rb', line 77 def initialize(config:, logger:, version_requirement:, workspace_name:) client = config.fetch :client hash_config = config.to_hash.merge workspace_name: workspace_name self.command_executor = ::Kitchen::Terraform::CommandExecutor.new( client: client, logger: logger, ) self.logger = logger self. = { cwd: config.fetch(:root_module_directory), timeout: config.fetch(:command_timeout) } self.workspace_name = workspace_name self.apply = ::Kitchen::Terraform::Command::Apply.new config: config self.get = ::Kitchen::Terraform::Command::Get.new self.output = ::Kitchen::Terraform::Command::Output.new initialize_outputs_handlers client: client, logger: logger self.validate = ::Kitchen::Terraform::Command::Validate.new config: config self.workspace_select = ::Kitchen::Terraform::Command::WorkspaceSelect.new config: hash_config self.variables = config.fetch :variables self.variables_manager = ::Kitchen::Terraform::VariablesManager.new 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(state:) ⇒ self
#call executes the action.
62 63 64 65 66 67 68 |
# File 'lib/kitchen/terraform/provisioner/converge.rb', line 62 def call(state:) verify_version.call command: version, options: execute_workflow save_variables_and_outputs state: state self end |