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

count, for_each or depends_on support while using modules #385

Open
pratik141 opened this issue Aug 7, 2022 · 2 comments
Open

count, for_each or depends_on support while using modules #385

pratik141 opened this issue Aug 7, 2022 · 2 comments

Comments

@pratik141
Copy link

$ terraform plan

│ Error: Module module.name contains provider configuration

│ Providers cannot be configured within modules using count, for_each or depends_on

@navtej-splunk
Copy link

Hi @pratik141,
Thanks a lot for bringing up the issue. I am PM on this and would love to get more details on this - what steps or custom configuration might have been set. Can you help with more information on this?

Looking forward to hearing from you.
Best,
Navtej

@pratik-iiss
Copy link

pratik-iiss commented Jul 12, 2023

hi @navtej-splunk
Here is the code and error snippet

error

$ terraform init

Initializing the backend...
Initializing modules...

  • name in mod

    │ Error: Module is incompatible with count, for_each, and depends_on

    │ on main.tf line 4, in module "name":
    │ 4: for_each = toset(["asd", "sdds"])

    │ The module at module.name 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 "./mod", consider updating this module to instead expect provider configurations to be passed by its caller.

code

$ cat main.tf
module "name" {
source = "./mod"

for_each = toset(["and", "sdds"])
appname = each.name

}

mod/main.tf

resource "signalfx_team" "myteam0" {

name = var.appname
description = "Super great team no jerks definitely"

members = [
"userid1",
"userid2",
# …
]

notifications_critical = [
"PagerDuty,credentialId"
]

notifications_info = [
"Email,notify@example.com"
]
}

variable "appname" {

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants