/terracove

Recursively test a directory tree for Terraform diffs and coverage

Primary LanguageGoMIT LicenseMIT

terracove

A recursive terraform repository tester powered by Terratest.

drawing drawing drawing drawing drawing drawing

Key FeaturesInstallUsageQuickstartCreditsSupportLicense

screenshot


Key Features

  • Test in parallel multiple directory paths
  • Export Results:
    • junit with --junit
    • json summary with --json
    • html report with --html
  • Generate % coverage for each module and root directory
  • Ignore Errors and Empty Modules
  • Supports terraform and terragrunt in the same directory tree

Install

The recommended way to install on MacOS is via brew:

brew tap elementtech/elementtech
brew install terracove

If you'd like to use Docker, you can use the official image:

docker run --rm -v $(pwd):/data ghcr.io/elementtech/terracove /data --json --junit --html

Or, you can install directly from release:

curl -sS https://raw.githubusercontent.com/elementtech/terracove/main/install.sh | bash

Usage

Usage:
  terracove [paths]... [flags]

Flags:
  -e, --exclude strings         Exclude directories while parsing tree
  -h, --help                    help for terracove
  -w, --html                    Output HTML Report
      --ignore-empty            Ignore Modules with 0 Resources
      --ignore-errors           Ignore Planning Errors
  -j, --json                    Output JSON
  -x, --junit                   Output Junit XML
      --minimal                 Don't Append Raw/JSON Plan to the Exported Output
      --o-html string           Output HTML Report File (default "terracove.html")
      --o-json string           Output JSON File (default "terracove.json")
      --o-junit string          Output Junit XML File (default "terracove.xml")
  -t, --validate-tf-by string   validate terraform by the existence of [filename] in a directory (default "main.tf")
  -g, --validate-tg-by string   validate terragrunt by the existence of [filename] in a directory (default "terragrunt.hcl")
  -v, --version                 version for terracove

Quickstart

Note that you must have terraform/terragrunt binaries installed on your machine

The examples directory contains 4 modules. 2 of them are terraform and 2 are terragrunt.

Oh no! It appears some of them have some problems. Let's see exactly what is going on. Clone this repository and give it a try.

git clone https://github.com/elementtech/terracove.git
cd terracove
terracove --minimal --junit --json --html . 
# . == examples == examples/terraform examples/terragrunt

Open the terracove.xml, terracove.json or terracove.html and observe the results. You should see the following:

[
 {
  "Timestamp": "1984-01-01T19:32:58+05:00",
  "Path": ".",
  "Results": [
   {
    "Path": "examples/terragrunt/no-resources",
    "ResourceCount": 0,
    "Coverage": 100,
    ...
   },
   {
    "Path": "examples/terragrunt/error",
    "Coverage": 0,
    ...
   },
   {
    "Path": "examples/terraform/tfstate-diff",
    "ResourceCount": 2,
    "ResourceCountDiff": 1,
    "Coverage": 50,
    ...
   },
   {
    "Path": "examples/terraform/success",
    "ResourceCount": 2,
    "ResourceCountExists": 2,
    "Coverage": 100,
    ...
   }
  ],
  "Coverage": 62.5
 }
]

Credits

This project uses or is inspired by the following open source projects:

Support

Buy Me A Coffee

License

MIT