diff --git a/internal/stacks/stackruntime/internal/stackeval/component_config.go b/internal/stacks/stackruntime/internal/stackeval/component_config.go index 3a4007e55c..d717a38c4b 100644 --- a/internal/stacks/stackruntime/internal/stackeval/component_config.go +++ b/internal/stacks/stackruntime/internal/stackeval/component_config.go @@ -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{ diff --git a/internal/stacks/stackruntime/testdata/mainbundle/test/with-single-input/provider-for-each/provider-for-each.tfstack.hcl b/internal/stacks/stackruntime/testdata/mainbundle/test/with-single-input/provider-for-each/provider-for-each.tfstack.hcl new file mode 100644 index 0000000000..09b6b482bf --- /dev/null +++ b/internal/stacks/stackruntime/testdata/mainbundle/test/with-single-input/provider-for-each/provider-for-each.tfstack.hcl @@ -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 + } +} \ No newline at end of file diff --git a/internal/stacks/stackruntime/validate_test.go b/internal/stacks/stackruntime/validate_test.go index 63564a6770..1c687065d2 100644 --- a/internal/stacks/stackruntime/validate_test.go +++ b/internal/stacks/stackruntime/validate_test.go @@ -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.