hashicorp / terraform-config-inspect

A helper library for shallow inspection of Terraform configurations
Mozilla Public License 2.0
376 stars 76 forks source link

Merge source across required_providers blocks #44

Closed alisdair closed 4 years ago

alisdair commented 4 years ago

If multiple terraform.required_providers blocks are in the config, we already merge the version constraints for each provider. We should also merge the source attribute, and warn if there are duplicates.

Consider the following configuration:

terraform {
  required_providers {
    foo = {
      version = "1.0.0"
    }
  }
}

terraform {
  required_providers {
    foo = {
      source = "abc/foo"
    }
  }
}

Before this commit, this would result in a provider requirement for "foo" with version "1.0.0", but no source. This commit merges the source attribute from the second block into this requirement.

justincampbell commented 4 years ago

Also FWIW, I don't believe the Terraform Registry codebase uses any Markdown output from this library.

alisdair commented 4 years ago

After some more discussion about how this would be used in Terraform, we're not going ahead with this change.