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

terraform_required_providers throws incorrect "Missing version constraint" warning #190

Closed
grimm26 opened this issue Jul 1, 2024 · 1 comment

Comments

@grimm26
Copy link

grimm26 commented Jul 1, 2024

❯ tflint --version
TFLint version 0.51.2
+ ruleset.aws (0.31.0)
+ ruleset.terraform (0.7.0-bundled)
rule "terraform_required_providers" {
  enabled = true
  version = false
}
❯ cat main.tf
terraform {
  required_version = "~> 1.7"
}

module "test" {
  providers = {
    aws.this = aws.us-west-2
  }
  source = "../testmod"
  thing  = "foo"
}
❯ cat ../testmod/main.tf
terraform {
  required_version = "~> 1.7"
  required_providers {
    aws = {
      source                = "hashicorp/aws"
      version               = ">= 5.0"
      configuration_aliases = [aws.this]
    }
  }
}

variable "thing" {
  description = "the thing"
  type        = string
}

output "thing" {
  value = var.thing
}
❯ tflint
1 issue(s) found:

Warning: Missing version constraint for provider "aws" in `required_providers` (terraform_required_providers)

  on main.tf line 5:
   5: module "test" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.7.0/docs/rules/terraform_required_providers.md

If I add

  required_providers {
    aws = {
      source = "hashicorp/aws"
    }
  }

to the terraform block in main.tf, tflint runs cleanly. I would think it should run clean with my initial config as well.

@bendrucker
Copy link
Member

Duplicate of #21. TFLint isn't aware of the idea of passing providers between modules. It's a tricky problem so there hasn't been any movement towards a fix.

@bendrucker bendrucker closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants