Kitchen-Terraform enables verification of infrastructure systems provisioned with Terraform.
As Kitchen-Terraform integrates several distinctive technologies in a nontrivial manner, reviewing the documentation of each of the aforementioned products is strongly encouraged.
Kitchen-Terraform integrates with the Terraform command-line interface to implement a Test Kitchen workflow for Terraform modules.
Installation instructions can be found in the Terraform: Install Terraform article.
Kitchen-Terraform supports versions of Terraform in the interval of
>= 0.11.4, < 0.15.0.
tfenv can be used to manage versions of Terraform on the system.
Kitchen-Terraform is written in Ruby which requires an interpreter to be installed on the system.
Installation instructions can be found in the Ruby: Installing Ruby article.
Kitchen-Terraform aims to support all versions of Ruby that are in
“normal” or “security” maintenance, which is currently
the interval of
>= 2.4, < 2.8.
rbenv can be used to manage versions of Ruby on the system.
Kitchen-Terraform Ruby Gem
Bundler should be used to manage versions of Kitchen-Terraform on the system. Using Bundler provides easily reproducible Ruby gem installations that can be shared with other systems.
First, create a
Gemfile with contents like the following example. The
pessimistic pinning of the version is recommended to benefit from
the semantic versioning of the Ruby gem.
Defining Kitchen-Terraform as a dependency for Bundler in a Gemfile
source "https://rubygems.org/" do
gem "kitchen-terraform", "~> 5.6"
Second, run the following command.
Installing Kitchen-Terraform with Bundler
The preceding command will create a
Gemfile.lock comprising a list
of the resolved Ruby gem dependencies.
More information can be found in the Bundler: In Depth article.
RubyGems, the default Ruby package manager, can also be used to install a version of Kitchen-Terraform by running a command like the following example.
Installing Kitchen-Terraform with RubyGems
gem install kitchen-terraform --version 5.7.0
This approach is not recommended as it requires more effort to install the gem in a manner that is reproducible and free of dependency conflicts.
More information can be found in the RubyGems: Installing Gems article.
The RbNaCl gem may need to be installed in order to use Ed25519-type SSH keys to connect to systems with the SSH backend. This gem implicitly depends on the system package libsodium, and its presence when libsodium is not installed causes unexpected errors when loading InSpec transport plugins like GCP, so it is not included by default to reduce the burden on users whom do not require support for Ed25519-type SSH keys.
Kitchen-Terraform provides three Test Kitchen plugins which must be configured in a Kitchen configuration file in order to successfully test Terraform configuration.
The Terraform driver manages the state of the Terraform root module.
The Terraform provisioner uses the Terraform driver to apply changes to the Terraform state.
The Terraform verifier uses InSpec to verify the Terraform state.
More information can be found in the Ruby gem documentation.
Versions of Terraform in the 0.11 series may cause
kitchen test to
fail if the initial destroy targets an empty Terraform state. A
workaround for this problem is to use
kitchen verify && kitchen destroy instead of
kitchen test. More
details about the problem are available in
Tutorials and Examples
Several tutorials are available on the Kitchen-Terraform Tutorials page.
The integration tests for Kitchen-Terraform can also be viewed as examples of how it works. The integration test Kitchen configuration file and the integration test directory provide several functional examples which exercise various features of Kitchen-Terraform.
Kitchen-Terraform thrives on community contributions.
Information about contributing to Kitchen-Terraform can be found in the Contributing document.
Kitchen-Terraform adheres to semantic versioning and documents all significant changes accordingly.
Information about changes to Kitchen-Terraform can be found in the Changelog.
Kitchen-Terraform is maintained by community contributors and New Context.
Kitchen-Terraform is distributed under the Apache License.