-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
provider configurations not evaluated correctly when in a module using count #24851
Comments
Hi @marinsalinas! I'm thrilled that you're trying out 0.13. Thanks! The module We are expecting to do a public beta of 0.13.0. Since you're already looking into it, you seem like a great person to get feedback from when that's available. |
Hi @marinsalinas, Thanks for trying things out! The underlying issue here is that you cannot have a provider configuration within a module that will be expanded. Due to some dependent work being sorted out, we have not implement the validation for this yet. In the future this config would fail with an error explaining the problem, instead of just silently failing to evaluate the provider. While the ability to iterate over providers is something that would be used with module expansion, it is a separate feature in and of itself. What you are looking for is being tracked in #24476, which is a narrower use case of #9448. |
Oh, awesome! So following this idea to not use a provider configuration inside modules that will be expanded, I'm wondering if this configuration should work: ./modules/test/main.tf
data "aws_region" "current" {} ./main.tf
locals {
secondary_clusters = [
{
region = "us-east-2"
replicas = 3
instance_size = "db4.large"
},
{
region = "us-east-1"
replicas = 5
instance_size = "db4.large"
},
{
region = "us-west-2"
replicas = 12
instance_size = "db4.large"
}
]
}
provider "aws" {
count = length(local.secondary_regions)
region = local.secondary_regions[count.index].region
alias = local.secondary_regions[count.index].region
}
module "test" {
count = length(local.secondary_clusters)
providers = {
aws = "aws.${local.secondary_clusters[count.index].region}" //maybe - aws = "aws[count.index]"
}
source = "./modules/test"
region = local.secondary_clusters[count.index].region
} |
@marinsalinas Not quite -- your example includes a few things that won't work. I recommend checking out the related issues @jbardin linked as they're relevant to what you're trying to do here :) Meanwhile, we interpreted the issue you opened here as "provider blocks in modules using Thank you for the report! |
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. |
Terraform Version
Terraform Configuration Files
Debug Output
https://gist.github.com/marinsalinas/8dea55ed182bc9b6991739bf27c5c7a6
Crash Output
Expected Behavior
Initialize provider by region.
Actual Behavior
The region variable is not recognized in the provider block when use count.
Steps to Reproduce
terraform init
terraform plan
Additional Context
We are waiting for this feature on Terraform since we need to create RDS regional clusters dynamically by a list of regions provided.
References
The text was updated successfully, but these errors were encountered: