Find unused variables in terraform modules.
Forked from https://github.com/nvkv/tf-unused and migrated to docker_image based pre-commit hook.
Table of Contents generated with DocToc
- Download binary for appropriate platform from releases page.
- Put it somewhere in
$PATH
tf-unused <path-to-tf-module>
When no path specified, tf-unused
will check current directory instead.
If there are unused variables, they will be printed out and process will return non-zero return code.
Otherwise nothing will be printed and process will exit with 0.
% tf-unused tests/fixtures/has_unused/
In tests/fixtures/has_unused/vars.tf:
* Unused definition legacy_switch_i_forgot_to_remove
* Unused definition surprisingly_unimportant_variable
In tests/fixtures/has_unused/some.tfvars:
* Unused value for some_random_variable
% echo $?
1
% tf-unused tests/fixtures/has_no_unused/
% echo $?
0
Requires docker.
Add this to your .pre-commit-config.yaml
:
- repo: https://github.com/mijdavis2/tf-unused
sha: '' # Use the sha / tag you want to point at
hooks:
- id: tf-unused