Class: Kitchen::Provisioner::Terraform
- Inherits:
-
Base
- Object
- Base
- Kitchen::Provisioner::Terraform
- Includes:
- Terraform::Configurable
- Defined in:
- lib/kitchen/provisioner/terraform.rb
Overview
The provisioner applies changes to the Terraform state based on the configuration of the root module.
Commands
The following command-line actions are provided by the provisioner.
kitchen converge
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
Configuration Attributes
The provisioner has no configuration attributes, but the provisioner
mapping must be declared with the plugin name within the Test Kitchen configuration file.
provisioner:
name: terraform
Ruby Interface
This class implements the interface of Kitchen::Configurable which requires the following Reek suppressions: :reek:MissingSafeMethod { exclude: [ finalize_config! ] }
Constant Summary collapse
- UNSUPPORTED_BASE_ATTRIBUTES =
UNSUPPORTED_BASE_ATTRIBUTES is the list of attributes inherited from Kitchen::Provisioner::Base which are not supported by Kitchen::Provisioner::Terraform.
[ :command_prefix, :downloads, :http_proxy, :https_proxy, :ftp_proxy, :max_retries, :root_path, :retry_on_exit_code, :sudo, :sudo_command, :wait_for_retry, ]
Instance Method Summary collapse
-
#call(state) ⇒ Object
Converges a Test Kitchen instance.
-
#finalize_config!(instance) ⇒ self
#finalize_config! invokes the super implementation and then initializes the strategy.
Methods included from Terraform::Configurable
Instance Method Details
#call(state) ⇒ Object
Converges a Test Kitchen instance.
82 83 84 85 86 |
# File 'lib/kitchen/provisioner/terraform.rb', line 82 def call(state) converge_strategy.call state: state rescue => error action_failed.call message: error. end |
#finalize_config!(instance) ⇒ self
#finalize_config! invokes the super implementation and then initializes the strategy.
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/kitchen/provisioner/terraform.rb', line 94 def finalize_config!(instance) super instance self.action_failed = ::Kitchen::Terraform::Raise::ActionFailed.new logger: logger self.converge_strategy = ::Kitchen::Terraform::Provisioner::Converge.new( config: instance.driver.send(:config), logger: logger, version_requirement: version_requirement, workspace_name: workspace_name, ) self end |