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
Panic: value for "variable" was requested before it was provided #35097
Comments
This looks to have been introduced in https://github.com/hashicorp/terraform/releases/tag/v1.8.2. Pinning to v1.8.1 works. At a guess in #35030. |
At a guess this might be related to our use of the In main.tf: data "aws_default_tags" "this" {}
module "production" {
source = "./modules/example"
tags = merge(data.aws_default_tags.this.tags, {
environment = "prod"
})
}
provider "aws" {
region = "eu-west-1"
default_tags {
tags = {
system = "example"
}
}
} And in the module: data "aws_default_tags" "this" {}
variable "tags" {
type = map(string)
description = "This variable specifies the AWS tags to apply to all resources."
nullable = true
}
provider "aws" {
region = "eu-west-1"
default_tags {
tags = merge(var.tags, {
"environment:id" = "example-${var.environment}"
})
}
} |
Hi @sjparkinson, Thanks for filing the issue. Yes, the linked PR looks to have been the root cause of the change. The bug is being triggered by the provider configuration existing in the module. Providers defined within a module are supported in limited cases for compatibility with early versions of Terraform, but it is not a recommended pattern to use. Optimally the provider configuration should be defined in the root module and passed into the child module which requires it. I think we can avoid the panic, but there may still be other compatibility issues with a legacy module structure like this and the new testing framework. Thanks! |
That makes sense, what we are doing does feel a bit off so great to have this pointer! |
Terraform Version
Terraform Configuration Files
tests/s3.tftest.hcl:
s3.tf:
Debug Output
https://gist.githubusercontent.com/sjparkinson/19680d8d703d8b81ca5e959cf5b95586/raw/45a13c77ee709e62cf293f674e808e448824c593/terraform-trace-output.txt
Expected Behavior
Actual Behavior
Steps to Reproduce
terraform init
terraform test
Additional Context
This looks to have been introduced in 5.47.0, no issues with 5.46.0.Actually, seems more like an issue in the latest version of Terraform rather than the AWS provider, as we're seeing
terraform test
fail on other branches still using the older version of the provider too.References
No response
The text was updated successfully, but these errors were encountered: