validate config generation

Have the resource validation node check if config generation is possible
when there is no config given. We can't check the output path here
because that is a plan option, so a final suggestion to use
-generate-config-out will have to wait until plan.
pull/35543/head
James Bardin 2 years ago
parent cc2abe4cfd
commit 196e009c76

@ -192,9 +192,14 @@ func (t *ConfigTransformer) transformSingle(g *Graph, config *configs.Config) er
toDiags = toDiags.Append(hd)
to, td := addrs.ParseAbsResourceInstance(traversal)
toDiags = toDiags.Append(td)
canGenerate := !toDiags.HasErrors() && to.Resource.Key == addrs.NoKey
if t.generateConfigPathForImportTargets != "" && canGenerate {
// Check if we can generate config for this target. During
// validation we won't have a valid config path, but we should still
// add the Node since it will only be used for further validation.
canGenerate := !toDiags.HasErrors() && to.Resource.Key == addrs.NoKey &&
(t.op == walkValidate || t.generateConfigPathForImportTargets != "")
if canGenerate {
log.Printf("[DEBUG] ConfigTransformer: adding config generation node for %s", i.Config.ToResource)
// TODO: if config generation is ever supported for for_each

Loading…
Cancel
Save