Skip to content

Latest commit

 

History

History
79 lines (50 loc) · 2.54 KB

README.md

File metadata and controls

79 lines (50 loc) · 2.54 KB

terraform-linter

Binary that lints a set of terraform files to adhere to the Vidsy linting guidelines.

Documentation

image

Vidsy linting

Terraform stacks can quickly get out of sync as different people and teams work on them. At Vidsy we have a set of simple guidelines for stacks to try and keep them consistent and easy to navigate and read.

Usage

Releases

The binary is versioned and released on each tagged merge to master, this can be found in the releases.

Once downloaded and installed, run the following to lint your stack:

terraform-linter --tf-directory"/path/to/terrform/files"

Docker

The binary is also built to a container and pushed up to docker hub. To lint the files in the current directory run:

docker run --rm=true -v ${pwd}:/stack vidsyhq/terraform-linter --tf-directory="/stack"

Linting rules

The following file structure is linted (Not all files are mandatory):

- stack
-- data.tf (Only 'data' resources)
-- outputs.tf (Only 'output' resources)
-- providers.tf (Only 'provider' and 'terraform' resources)
-- resources.tf (Only `resource', 'module' or 'local' resources)
-- variables.tf (Only 'variable' resources)

providers.tf

If this file exists, the following is checked:

  1. Should only contain 1 or more provider configs and one terraform config.
  2. Names should match ^[a-z0-9][a-z0-9_]*[a-z0-9]$.
  3. Should contain no data, local, module, output orresource resources.

resources.tf

If this file exists, the following is checked:

  1. Should contain 1 or more local, module or resource resources.
  2. Names should match ^[a-z0-9][a-z0-9_]*[a-z0-9]$.
  3. Should not contain data, provider, terraform or output resources.

data.tf

If this file exists, the following is checked:

  1. Should contain 1 or more data resources.
  2. Names should match ^[a-z0-9][a-z0-9_]*[a-z0-9]$.
  3. Should not contain local, module, output, provider, resource or terraform resources.

outputs.tf

If this file exists, the following is checked:

  1. Should contain 1 or more output resources.
  2. Names should match ^[a-z0-9][a-z0-9_]*[a-z0-9]$.
  3. Should not contain data, local, module, provider, resource or terraform resources.