hashicorp/terraform

Terraform 0.13 Error: Duplicate required providers configuration

Closed this issue · 2 comments

Terraform Version

NOTE: The bug report comments suggest running terraform -v which is no longer a valid flag in 0.13. terraform version works

Terraform v0.13.0-beta2

Terraform Configuration Files

provider_ns1.tf

terraform {
  required_providers {
    ns1 = {
      source  = "terraform-providers/ns1"
      version = "~> 1.5"
    }
  }
}

providers.tf

/******************************************************************************
 * Provider Config
 *****************************************************************************/
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 2.65"
    }
    local = {
      source  = "hashicorp/local"
      version = "~> 1.4.0"
    }
  }

  required_version = ">= 0.13"
}

Expected Behavior

I should still be able to separate provider configurations into separate files. required_providers configurations should merge together into a single block as files are processed. Duplicate providers in the merged block should cause an error.

Actual Behavior

Error: Duplicate required providers configuration

  on providers.tf line 5, in terraform:
   5:   required_providers {

A module may have only one required providers configuration. The required
providers were previously configured at provider_ns1.tf:2,3-21.

Steps to Reproduce

  1. terraform init

Hello @jyoder-deloitte, thank you for this report!

This is a known breaking change we are adding in 0.13, and you can read the relevant PR here: #24763. I'll borrow from the summary of that PR here:

We now permit at most one required_providers block per module (except for overrides). This prevents users (and Terraform) from struggling to understand how to merge multiple required_providers configurations, with version and source attributes split across multiple blocks.

This is a purposeful change for 0.13, so I'm going to close this issue.

As well, thank you for the note about terraform -v! This was accidentally broken when adding a different feature allowing json output from the version command, and has since been fixed.

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.