This directory contains an example Terraform project that creates infrastructure on Amazon Web Services (AWS) and utilizes kitchen-terraform for testing the server instances.
While the complexity of the Terraform code has been kept to a minimum, it is possible that the configuration of a user's AWS account may still prevent the successful execution of this example.
variables.tf defines the required inputs for the example module.
example.tf creates three server instances: two in the kitchen_terraform_example_1 group and one in the kitchen_terraform_example_2 group.
outputs.tf defines two output variables: the hostnames of the instances in the test suite's only group and an address to use in the suite's Inspec controls.
The Test Kitchen configuration includes all of the plugins provided by kitchen-terraform.
The driver has no configuration options.
The provisioner is configured to use a [variables file] to provide some of the variables required by the example module.
The SSH transport is used due to the AMI used in the example module.
The verifier is configured with a single group named contrived
.
The contrived
group uses the value of the different_host_address
output
to define an Inspec control attribute named other_host_address
and
includes all of the suite's profile's controls. The group uses the
value of the contrived_hostnames
output to obtain the targets to
execute the controls on and provides a static port and username based on
the AMI used in the example module.
The platforms configuration is currently irrelevant but must not be empty.
The suite name corresponds to the integration test directory pathname as usual.
Several required configuration options are missing from the Test Kitchen configuration; these must be provided in a local Test Kitchen configuration.
Before continuing, review the instructions on configuring the AWS account with an isolated user for enhanced security.
.kitchen.local.yml
---
transport:
ssh_key: <pathname/of/private/ssh/key>
suites:
- name: example
provisioner:
variables:
- access_key=<aws_access_key_id>
- public_key_pathname=<pathname/of/public/ssh/key>
- secret_key=<aws_secret_access_key>
WARNING Creating AWS resources could cost money and be charged to the AWS Account's bill; neither kitchen-terraform nor its maintainers are responsible for any incurred costs.
Assuming that the missing configuration has been provided, testing the example module is simple:
$ bundle install
$ bundle exec kitchen test --destroy always