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

Allow dynamic interpolation capability for module providers in terraform 0.13 #25932

Closed
swetli opened this issue Aug 20, 2020 · 2 comments
Closed
Labels
enhancement new new issue not yet triaged

Comments

@swetli
Copy link

swetli commented Aug 20, 2020

Current Terraform Version

Terraform v0.13.0

...

Use-cases

With the addition of for_each capability for modules in terraform 0.13 we finally got the missing feature we all wanted but it is still incomplete in case we need to instantiate modules for different providers. This is true especially in the case when calling the same module is needed but for different account/region - and unfortunately many AWS features still need to be managed on per account/ per region level

Proposal

Have the following structure possible:

variable account_list {
  default = [
    "112233445566",
    "223344556677",
  ]
}

variable regions {
  default = [
    "eu-central-1",
    "eu-west-1",
  ]
}

locals {
  accounts_and_regions = { for p in setproduct(var.account_list, var.regions) : "${p[0]}/${p[1]}" => {
    account_id = p[0]
    region     = p[1]
    }
  }
}

module "xxx" {
  for_each = local.accounts_and_regions

  providers = {
    aws = format("aws.account_%s-%s", each.value.account_id, each.value.region)
  }
  
  source = "./modules/module_source"
}
@swetli swetli added enhancement new new issue not yet triaged labels Aug 20, 2020
@jbardin
Copy link
Member

jbardin commented Aug 20, 2020

Hi @swetli

Unfortunately this is not something that can be added to the 0.13 release, since it would involve some major internal changes to Terraform to accomplish. We have some open issues requesting the ability to dynamically assign providers already #25244 and #19932. We can track the individual features there.

Thanks!

@jbardin jbardin closed this as completed Aug 20, 2020
@ghost
Copy link

ghost commented Oct 11, 2020

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.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants