ProviderConfig needs an Inherited flag

If a provider configuration is inherited from another module, any
interpolations in that config won't have variables declared locally. Let
the config only be validated in it's original location.
This commit is contained in:
James Bardin 2017-10-26 18:48:39 -04:00
parent 0afd4a9097
commit 1756b3d09f
2 changed files with 9 additions and 0 deletions

View File

@ -74,6 +74,10 @@ type ProviderConfig struct {
// it can be copied into child module providers yet still interpolated in // it can be copied into child module providers yet still interpolated in
// the correct scope. // the correct scope.
Path []string Path []string
// Inherited is used to skip validation of this config, since any
// interpolated variables won't be declared at this level.
Inherited bool
} }
// A resource represents a single Terraform resource in the configuration. // A resource represents a single Terraform resource in the configuration.
@ -813,6 +817,10 @@ func (c *Config) rawConfigs() map[string]*RawConfig {
} }
for _, pc := range c.ProviderConfigs { for _, pc := range c.ProviderConfigs {
// this was an inherited config, so we don't validate it at this level.
if pc.Inherited {
continue
}
source := fmt.Sprintf("provider config '%s'", pc.Name) source := fmt.Sprintf("provider config '%s'", pc.Name)
result[source] = pc.RawConfig result[source] = pc.RawConfig
} }

View File

@ -395,6 +395,7 @@ func (t *Tree) inheritProviderConfigs(stack []*Tree) {
pc.Path = pt.Path() pc.Path = pt.Path()
pc.Path = append([]string{RootName}, pt.path...) pc.Path = append([]string{RootName}, pt.path...)
pc.RawConfig = parentProvider.RawConfig pc.RawConfig = parentProvider.RawConfig
pc.Inherited = true
log.Printf("[TRACE] provider %q inheriting config from %q", log.Printf("[TRACE] provider %q inheriting config from %q",
strings.Join(append(t.Path(), pc.FullName()), "."), strings.Join(append(t.Path(), pc.FullName()), "."),
strings.Join(append(pt.Path(), parentProvider.FullName()), "."), strings.Join(append(pt.Path(), parentProvider.FullName()), "."),