-
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
Panic when using complex types returned from modules #24067
Comments
I've been able to generate a minimal example, and can share a crash log as well. I think this is the same bug - although the type is slightly different, it is flexible. I can solve this crash by removing the variable's type statement entirely, it is not a fixed type as with the previous example. Also, I can make it Link to crash log: crash.log main code: module "test" {
source = "./module/"
components = {
kv = {}
pki = {
domains = ["fakeapp.domain.com"]
}
}
}
output "policies" {
value = module.test
} module code: variable "components" {
type = map(map(any))
default = { kv = {} }
}
locals {
kv_enabled = length([for i, j in var.components : 1 if i == "kv"]) > 0 ? true : false
pki_enabled = length([for i, j in var.components : 1 if i == "pki"]) > 0 ? true : false
pki_settings = lookup(var.components, "pki", {})
}
data "vault_policy_document" "pki_read_policy" {
count = local.pki_enabled ? 1 : 0
dynamic "rule" {
for_each = length(lookup(local.pki_settings, "domains", [])) > 0 ? toset(["enabled"]) : toset([])
content {
path = "pki/certs/*"
capabilities = ["list"]
description = "List certs"
}
}
}
output "policy" {
value = data.vault_policy_document.pki_read_policy.0.hcl
} |
Also experienced this when trying to map vars into a complex variable type. Configuration too complex and private to share as another crash log. But +1 for the issue. I think in my case it was map(objects) that contained map(objects). azs[A] contained 1 object in subnets. azs[B] contained 2 objects in subnets. I realise this isn't supported and worked out my error, but assume it should record an error not panic. Originally - static
Attempting dynamic content in an instance of subnets
Working dynamic content
|
Using terraform v0.12.21 I got a similar crash. The variable inside a module was defined as
|
I've reproduced this using @mbrancato's example on Terraform 0.12.25. For ease of reproduction, I've put a reproduction case in github that can be cloned and run. |
This bug has been fixed in the 0.13.0-beta1 prerelease, via this go-cty change. The reproduction case still has a type error, which is caused by declaring the type of the module's For this use case, it might make more sense to have separate variables for |
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
I attempted to generate a minimal example, but was unable to reproduce. The code causing the problem looks like this.
edit: I've updated the examples to better reflect what the setup looked like.
with module-one being:
and module-two being:
Debug Output
Crash Output
I can't share the full crash.log since it contains internal code - if I hit this again, I will see if I can get a minimal example working:
console panic
Expected Behavior
Actual Behavior
Steps to Reproduce
terraform apply
Additional Context
I solved this by changing the type of the variable. Originally this was:
but I solved this by changing to:
References
The text was updated successfully, but these errors were encountered: