Class: Kitchen::Provisioner::Terraform
- Inherits:
-
Base
- Object
- Base
- Kitchen::Provisioner::Terraform
- Includes:
- Terraform::Configurable
- Defined in:
- lib/kitchen/provisioner/terraform.rb
Overview
The Terraform 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
Terraform >= 0.15.0
The root module is validated by running a command like the following example:
terraform validate \
[-no-color] \
<directory>
Terraform < 0.15.0
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.
Methods included from Terraform::Configurable
Instance Method Details
#call(state) ⇒ Object
Converges a Test Kitchen instance.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/kitchen/provisioner/terraform.rb', line 82 def call(state) driver = instance.driver transport = driver.transport ::Kitchen::Terraform::Provisioner::Converge.new( config: driver.send(:config), connection: transport.connection({}), debug_connection: transport.connection(logger: ::Kitchen::Terraform::DebugLogger.new(logger)), logger: logger, version_requirement: version_requirement, workspace_name: workspace_name, ).call state: state rescue => error ::Kitchen::Terraform::Raise::ActionFailed.new(logger: logger).call message: error. end |