hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.34k stars 9.49k forks source link

Invalid Terraform version constraint in module gives confusing error #21424

Open dennyx opened 5 years ago

dennyx commented 5 years ago

Terraform Version

Terraform v0.12.0

Terraform Configuration Files

module "kafka_agents" {
  source  = "../terraform-azurerm-private-agents"

  providers = {
    azurerm = "azurerm"
  }

  hostname_format           = "${var.kafka_hostname_format}"

}

Expected Behavior

work as version 0.11.13 that no need to specify version for local modules

Actual Behavior

Error: Invalid provider version constraint
Invalid version core constraint "" in dcos.dcos-infrastructure.kafka_agents.

Steps to Reproduce

# change terraform version to 0.12
terraform init

Additional Context

  1. tried to add version while encountered issue https://github.com/hashicorp/terraform/issues/21328

Thanks for any kindly help

mildwonkey commented 5 years ago

Hi @dennyx ! Thanks for reporting this. Can you share the rest of the configuration, including the module, or a smaller example that we can use to reproduce this issue?

dennyx commented 5 years ago

hi @mildwonkey Thanks for the kindly feeback. Add sample repository https://github.com/dennyx/terraform-21424 for reproduce.

git clone https://github.com/dennyx/terraform-21424.git
cd terraform-21424/terraform-main
terraform init

Appreciate if any kindly help on this, thanks~

ps: add terraform v0.12 download link https://releases.hashicorp.com/terraform/0.12.0/terraform_0.12.0_linux_amd64.zip

mildwonkey commented 5 years ago

Thanks @dennyx! There error is caused by this block (I found it in at least two files):

terraform {
  required_version = ""
}

You cannot have an empty string "" in the version constraint.

dennyx commented 5 years ago

hi @mildwonkey , Thanks for the kindly help, it works now~ And I will close this issue

afterlook commented 5 years ago

Hi @mildwonkey, Doesn't the error message sound a little confusing? Isn't there some way to propagate to this error message the exact name of the variable that violates the constraint?

mildwonkey commented 5 years ago

I agree! The message could certainly be clearer, and it should include the file name (like the other error messages try to do). I'm going to reopen this as an enhancement.

seanmmccormick commented 3 years ago

I get the same error when trying to run through the hello world here: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/azure-get-started