Linkedin

  • Home >
  • Use Serverspec for test-driven development of infrastructure code

Use Serverspec for test-driven development of infrastructure code

Project Overview

Project Detail

This pattern shows you how to use Serverspec to use test-driven development (TDD) when writing infrastructure code on the Amazon Web Services (AWS) Cloud. The pattern also covers automation with AWS CodePipeline. TDD will focus attention on what the infrastructure code must do and sets a clear definition of done. You can use Serverspec to test infrastructure created by tools such as AWS CloudFormation, Terraform by HashiCorp, and Ansible.

Serverspec helps with refactoring infrastructure code. With Serverspec, you can write RSpec tests to check installation of various packages and software, run commands, check for running processes and ports, check file permission settings, and so forth. Serverspec checks whether your servers are configured correctly. You install only Ruby on your servers. You don't need to install any agent software.

Test-driven infrastructure provides the following benefits:

  • Cross-platform testing

  • Validation of expectations

  • Confidence in your automation

  • Infrastructure consistency and stability

  • Fail early

You can use this pattern to run Serverspec unit tests for Apache software and check file permission settings during Amazon Machine Image (AMI) creation. An AMI will be created only if all the test cases pass. Serverspec will perform following tests:

  • Apache process is running.

  • Apache port is running.

  • Apache configuration files and directories exist at certain locations, and so forth.

  • File permissions are correctly configured.

https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/use-serverspec-for-test-driven-development-of-infrastructure-code.html?did=pg_card&trk=pg_card

To know more about this project connect with us

Use Serverspec for test-driven development of infrastructure code