strip unknown values from the resource config

Computed values are now all added to the config value as unknowns. Strip
these out to match the legacy expatiations.
This commit is contained in:
James Bardin 2018-05-22 14:41:51 -04:00 committed by Martin Atkins
parent d6d655f21d
commit e6478599c6

View File

@ -238,6 +238,11 @@ func NewResourceConfigShimmed(val cty.Value, schema *configschema.Block) *Resour
panic(fmt.Errorf("NewResourceConfigShimmed given %#v; an object type is required", val.Type()))
}
ret := &ResourceConfig{}
// Computed fields will all be present with unknown values. Strip them out
// before passing to the provider.
val = cty.UnknownAsNull(val)
legacyVal := hcl2shim.ConfigValueFromHCL2(val)
ret.Config = legacyVal.(map[string]interface{}) // guaranteed compatible because we require an object type
ret.Raw = ret.Config