diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 362e7e6b13..95691072a1 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -21,6 +21,7 @@ import ( "strings" "github.com/hashicorp/terraform/terraform" + "github.com/mitchellh/copystructure" "github.com/mitchellh/mapstructure" ) @@ -370,6 +371,16 @@ func (m schemaMap) Data( }, nil } +// DeepCopy returns a copy of this schemaMap. The copy can be safely modified +// without affecting the original. +func (m *schemaMap) DeepCopy() schemaMap { + copy, err := copystructure.Config{Lock: true}.Copy(m) + if err != nil { + panic(err) + } + return copy.(schemaMap) +} + // Diff returns the diff for a resource given the schema map, // state, and configuration. func (m schemaMap) Diff(