Terraform Test Driven Development
Testing Terraform code currently requires knowledge of a new set of tools which make crossing the bridge from Application Development to Infrastructure quite difficult.
t2d2 helps bridge this gap by allowing you write your IaC tests with familiar JavaScript testing frameworks like Jest, Mocha, UVU etc.,.
- Create a starter jest project. You can explore the sample test in resources.ts
mkdir my-infra-project
cd my-infra-project
npm init @t2d2/jest-starter
- Customize the terraform workspace path in your tests'
beforeAll
hook, if required.
...
profile = await t2d2.init({
profileName: 'resources',
workspaceDir: './tf', # <--
})
...
- Start your TDD cycles.
Main package in the t2d2 Suite, helps with:
- Setting up the Terraform workspace through code
- Functions to write unit tests
npm init package to setup a jest test project with t2d2
t2d2 core test helpers, supercharged as jest custom matchers