Binary that lints a set of terraform files to adhere to the Vidsy linting guidelines.
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.
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"
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"
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)
If this file exists, the following is checked:
- Should only contain 1 or more
provider
configs and oneterraform
config. - Names should match
^[a-z0-9][a-z0-9_]*[a-z0-9]$
. - Should contain no
data
,local
,module
,output
orresource
resources.
If this file exists, the following is checked:
- Should contain 1 or more
local
,module
orresource
resources. - Names should match
^[a-z0-9][a-z0-9_]*[a-z0-9]$
. - Should not contain
data
,provider
,terraform
oroutput
resources.
If this file exists, the following is checked:
- Should contain 1 or more
data
resources. - Names should match
^[a-z0-9][a-z0-9_]*[a-z0-9]$
. - Should not contain
local
,module
,output
,provider
,resource
orterraform
resources.
If this file exists, the following is checked:
- Should contain 1 or more
output
resources. - Names should match
^[a-z0-9][a-z0-9_]*[a-z0-9]$
. - Should not contain
data
,local
,module
,provider
,resource
orterraform
resources.