stacks: Fix unknown provider values crashing validation phase (#35155)

* test to reproduce

* stacks: Fix unknown provider values crashing validation phase

* remove extra type information

---------

Co-authored-by: CJ Horton <cjhorton@hashicorp.com>
pull/35171/head
Liam Cervante 2 years ago committed by GitHub
parent 3845aa1a7d
commit 7a8ffff66e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -336,6 +336,12 @@ func (c *ComponentConfig) CheckProviders(ctx context.Context, phase EvalPhase) (
})
continue
}
} else if result.Value == cty.DynamicVal {
// Then we don't know the concrete type of this reference at this
// time, so we'll just have to accept it. This is somewhat expected
// during the validation phase, and even during the planning phase
// if we have deferred attributes. We'll get an error later (ie.
// during the plan phase) if the type doesn't match up then.
} else {
// We got something that isn't a provider reference at all.
diags = diags.Append(&hcl.Diagnostic{

@ -0,0 +1,32 @@
required_providers {
testing = {
source = "hashicorp/testing"
version = "0.1.0"
}
}
variable "provider_set" {
type = set(string)
default = ["a", "b"]
}
provider "testing" "configurations" {
for_each = var.provider_set
}
variable "input" {
type = string
}
component "self" {
source = "../"
for_each = var.provider_set
providers = {
testing = provider.testing.configurations[each.value]
}
inputs = {
input = var.input
}
}

@ -61,6 +61,11 @@ var (
"input": cty.StringVal("input"),
},
},
filepath.Join("with-single-input", "provider-for-each"): {
planInputVars: map[string]cty.Value{
"input": cty.StringVal("input"),
},
},
}
// invalidConfigurations are shared between the validate and plan tests.

Loading…
Cancel
Save