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

[REG 1.1.9 -> 1.2.0] Module is incompatible with count, for_each, and depends_on #31107

Closed
orgads opened this issue May 23, 2022 · 3 comments
Closed
Labels
bug duplicate issue closed because another issue already tracks this problem

Comments

@orgads
Copy link

orgads commented May 23, 2022

Terraform Version

Terraform v1.2.0
on windows_amd64

Terraform Configuration Files

a/a.tf:

output "value" { value = "foo" }

b/b.tf:

terraform {
  required_providers {
    restapi = {
      source  = "fmontezuma/restapi"
      version = ">=1.14.1"
    }
  }
}

provider "restapi" {
  alias = "test"
  uri   = "https://example.com/api/v1"
}

variable "v" {}

main.tf:

terraform {
  required_providers {
    restapi = {
      source  = "fmontezuma/restapi"
      version = ">=1.14.1"
    }
  }
}

module "a" {
  count = 1
  source = "./a"
}

module "b" {
  source = "./b"
  v = module.a[0].value
}

Debug Output

https://gist.github.com/orgads/cd268112f253363f9f58f19dad306111

Expected Behavior

It should work

Actual Behavior

I'm getting a wrong error message. Module a does not have a provider, and module b doesn't have for_each, count or depends_on. This worked correctly with Terraform 1.1.9.

$ terraform init
Initializing modules...
There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
╷
│ Error: Module is incompatible with count, for_each, and depends_on
│
│   on main.tf line 11, in module "a":
│   11:   count = 1
│
│ The module at module.b is a legacy module which contains its own local provider configurations, and so calls to it may not use the count, for_each, or depends_on arguments.
│
│ If you also control the module "./b", consider updating this module to instead expect provider configurations to be passed by its caller.
╵

Steps to Reproduce

terraform init

@orgads orgads added bug new new issue not yet triaged labels May 23, 2022
@kmoe
Copy link
Member

kmoe commented May 23, 2022

This is a duplicate of #31081, which is fixed in v1.2.1.

@kmoe kmoe closed this as completed May 23, 2022
@orgads
Copy link
Author

orgads commented May 23, 2022

Thank you.

@crw crw added duplicate issue closed because another issue already tracks this problem and removed new new issue not yet triaged labels May 23, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug duplicate issue closed because another issue already tracks this problem
Projects
None yet
Development

No branches or pull requests

3 participants