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

Duplicate variables in tfvars should warn or error #15455

Closed
lopopolo opened this issue Jul 3, 2017 · 2 comments
Closed

Duplicate variables in tfvars should warn or error #15455

lopopolo opened this issue Jul 3, 2017 · 2 comments

Comments

@lopopolo
Copy link

lopopolo commented Jul 3, 2017

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

$ terraform -v
Terraform v0.9.10

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

Terraform should error when there are duplicate variable definitions in a *.tfvars file like it does for duplicate variable definitions in *.tf files.

Actual Behavior

No error, no warning. The last definition wins.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@apparentlymart
Copy link
Contributor

Hi @lopopolo! Sorry for the long silence here.

I've verified that as of Terraform v0.12.0-alpha1 -- a prerelease version of the forthcoming v0.12.0 major release -- Terraform will now produce an error if the same variable is assigned a value multiple times in the same tfvars file.

It is intentional that assignments in separate files (or separate assignments directly from the command line using -var=) have a "last assignment wins" rule, since that allows the user to "layer" variable values, such as by having a file with values that are used in most cases and then another separate file that selectively overrides it e.g. for special deployment environments.

We have also updated the documentation for setting variables in an attempt to be clearer about the override behavior and the value precedence when using overrides. This is not visible on the website yet since it is still showing the v0.11.10 documentation, but the changes will be published in conjunction with the v0.12.0 final release.

Since the duplicate-checking behavior is now present on master and will be included in the final release, I'm going to close this out. Thanks for reporting this, and sorry again for the delay in getting back to you about it.

@apparentlymart apparentlymart added this to the v0.12.0 milestone Oct 29, 2018
@ghost
Copy link

ghost commented Mar 31, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants