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

required_version has no effect #10715

Closed
seanknox opened this issue Dec 14, 2016 · 9 comments · Fixed by #10720
Closed

required_version has no effect #10715

seanknox opened this issue Dec 14, 2016 · 9 comments · Fixed by #10720
Assignees

Comments

@seanknox
Copy link
Contributor

Terraform Version

Terraform v0.8.0

Affected Resource(s)

  • terraform { required_version = "> ..." }

Terraform Configuration Files

terraform {
  required_version = "> 0.8.1"
}

Debug Output

Unfortunately I have a lot of sensitive information in my debug output that I can't include.

Expected Behavior

An error is shown and TF exits due to TF version < 0.8.1

Actual Behavior

Plans are executed with Terraform 0.8.0

Steps to Reproduce

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

  1. Add the following terraform configuration:
terraform {
  required_version = "> 0.8.1"
}
  1. terraform apply
@mitchellh
Copy link
Contributor

2016-12-13 at 8 43 pm

I'm not sure what you're doing wrong but your exact configuration works for me exactly. Can you double check and report back if I'm missing something? Thanks!

@seanknox
Copy link
Contributor Author

@mitchellh should it matter if I'm declaring the terraform resource in a modules manifest (no direct resources otherwise)? e.g.

terraform {
  required_version = "> 0.8.1"
}

module "s3" {
  source = "./modules/s3"
  depends-id = "${ module.vpc.depends-id }"

  bucket-prefix = "${ var.s3-bucket }"

  hyperkube-image = "${ var.k8s["hyperkube-image"] }"
  hyperkube-tag = "${ var.k8s["hyperkube-tag"] }"
  internal-tld = "${ var.internal-tld }"
  name = "${ var.name }"
  region = "${ var.aws["region"] }"
  service-cluster-ip-range = "${ var.cidr["service-cluster"] }"
}

@mitchellh
Copy link
Contributor

@seanknox I tried two scenarios, both of which were successful:

  • No terraform block, do a terraform get, add the terraform block, terraform apply (errored)

  • terraform block in place, terraform get (errored)

@seanknox
Copy link
Contributor Author

@mitchellh ok, this is interesting:

  • I can successfully trigger the version error on a new project with a main.tf just like yours:
[seanknox:~/src/terraform-foo]$ cat main.tf
terraform {
  required_version = "> 0.8.1"
}

[seanknox:~/src/terraform-foo]$ terraform plan
The currently running version of Terraform doesn't meet the
version requirements explicitly specified by the configuration.
Please use the required version or update the configuration.
Note that version requirements are usually set for a reason, so
we recommend verifying with whoever set the version requirements
prior to making any manual changes.

  Module: root
  Required version: > 0.8.1
  Current version: 0.8.0
  • In an existing project modeled after tack, adding the terraform resources to the top level modules.tf file seems to have no effect:
[seanknox:~/src/devinfra]$ ls                                                                
Makefile            manifests           scripts             terraform.tfvars
README.md           modules             staff_ips.txt       test
io.tf               modules.tf          terraform.tfplan    tmp
makefiles           modules_override.tf terraform.tfstate   vpc-existing.tfvars

[seanknox:~/src/devinfra]$ head modules.tf                                                   
terraform {
  required_version = "> 0.8.1"
}

module "s3" {
  source = "./modules/s3"
  depends-id = "${ module.vpc.depends-id }"

  bucket-prefix = "${ var.s3-bucket }"

[seanknox:~/src/devinfra]$ terraform plan                                                   
There are warnings and/or errors related to your configuration. Please
fix these before continuing.

Warnings:

  * template_file.user-data: using template_file as a resource is deprecated; consider using the data source instead
  * template_file.cloud-config: using template_file as a resource is deprecated; consider using the data source instead
  * template_file.discover-client #0: using template_file as a resource is deprecated; consider using the data source instead
  * template_file.discover-client #2: using template_file as a resource is deprecated; consider using the data source instead

<snip>

No errors found. Continuing with 15 warning(s).

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but
will not be persisted to local or remote state storage.

module.bastion.template_file.user-data: Refreshing state... (ID: 03bd397e91eda413a2ccae2a5d663415640b3c48f11eef1a01668c74c8e06885)
<snip>

@mitchellh
Copy link
Contributor

That's it. I know what is happening.

When an _override is present it trigger's Terraform's merge config behavior (which it otherwise doesn't need to invoke). This doesn't honor terraform blocks. Reopening and fixing this now.

Reiterating: This only affects your config if the module with terraform also has an _override file.

@mitchellh mitchellh reopened this Dec 14, 2016
@mitchellh
Copy link
Contributor

By the way, thanks for sticking with this and being helpful. It led to knowing whats going on. 👨‍❤️‍👨

@seanknox
Copy link
Contributor Author

Ah! And I also learned that I have an _override and what it does. :)

mitchellh added a commit that referenced this issue Dec 14, 2016
Fixes #10715

`config.Merge` was not updated to support a number of new features. This
updates the codepath to merge various fields, including the `terraform`
block which was the issue in #10715.

The `Merge` API is called when an `_override` file is present to _merge_
configurations. Normally configurations are _appended_. Only an override
file triggers a _merge_.

I started working on a generic library to do this automatically awhile
back but never finished it. This might motivate me to do so. In the
interest of getting a fix out though, we'll continue the manual
approach.
@mitchellh
Copy link
Contributor

Fixed in the referenced PR. Thanks again!

@mitchellh mitchellh self-assigned this Dec 14, 2016
@ghost
Copy link

ghost commented Apr 18, 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 Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants