Testing servers with Inspec

Just as your application, code should be covered with unit and integration tests. Infrastructure as Code should have good test coverage as well. There are multiple ways to do infrastructure code tests. They are as follows:

  • Test only the code, without creating a real infrastructure (with tools such as ChefSpec and rspec-puppet)
  • Test a single server
  • Test the complete system

We won't look at the first option to test our infrastructure in this book. For guidance on how to test the complete system (with all the cloud resources, servers, and so on), look at Chapter 7, Collaborative Infrastructure. As for this chapter, let's check one way to test a single server with Terraform and Inspec.

Inspec is a testing framework, written ...

Get Getting Started with Terraform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.