Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused variables in Terraform Files #11412

Open
cemo opened this issue Jan 25, 2017 · 8 comments
Open

Unused variables in Terraform Files #11412

cemo opened this issue Jan 25, 2017 · 8 comments

Comments

@cemo
Copy link

cemo commented Jan 25, 2017

It would be cool to detect unused variables in especially in module files. I usually include a module and check that required parameters for module for how they are used. Sometimes I can see that author is not using a required variable which is simply can be deleted.

@bencoughlan
Copy link

This! I was just looking for the same thing, where I could clean up unused vars.

@pecigonzalo
Copy link

You can use something like:
https://github.com/ContainerLabs/terraform-unused-vars
or if you use pre-commit:
https://github.com/pecigonzalo/pre-commit-terraform-vars

But It would be great to have it integrated onto validate or similar

@mohanidragel
Copy link

This needs to be a thing!!

@dserodio
Copy link

@pecigonzalo ContainerLabs/terraform-unused-vars is gone, do you have any replacements to suggest?

@marcjay
Copy link

marcjay commented Jan 11, 2019

@dserodio there seems to be a copy of the original ContainerLabs/terraform-unused-vars script within @pecigonzalo 's repo here: https://github.com/pecigonzalo/pre-commit-terraform-vars/blob/master/terraform_unused_vars/__main__.py which worked for me 😄

Still would be great to see this feature built in to Terraform

@bendrucker
Copy link
Contributor

Working on adding this to tflint, keep an eye out for a release soon:

terraform-linters/tflint#739

In addition to variables, it will also detect locals and and data sources that have been declared but not referenced.

@Arlington1985
Copy link

I hope terraform would consider what people want faster. Why people should use 3rd party open source tools if it's easily can be implemented with terraform.

@abower-digimarc
Copy link

I'm looking for this as well. Incorporating this into 'terraform validate' even if it was an extra argument would be super useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests