Terraform: Invalid Terraform version constraint in module gives confusing error

Created on 24 May 2019  路  6Comments  路  Source: hashicorp/terraform

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

enhancement

All 6 comments

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?

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

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.

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

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?

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.

Was this page helpful?
0 / 5 - 0 ratings