code: func NewDynamicValue(val cty.Value, ty cty.Type) (DynamicValue, error) {
  	// If we're given cty.NilVal (the zero value of cty.Value, which is
  	// distinct from a typed null value created by cty.NullVal) then we'll
  	// assume the caller is trying to represent the _absense_ of a value,
  	// and so we'll return a nil DynamicValue.
  	if val == cty.NilVal {
  		return DynamicValue(nil), nil
  	}
  
  	// Currently our internal encoding is msgpack, via ctymsgpack.
  	buf, err := ctymsgpack.Marshal(val, ty)
  	if err != nil {
  		return nil, err
  	}
  
  	return DynamicValue(buf), nil
  }
docs: // NewDynamicValue creates a DynamicValue by serializing the given value
  // against the given type constraint. The value must conform to the type
  // constraint, or the result is undefined.
  //
  // If the value to be encoded has no predefined schema (for example, for
  // module output values and input variables), set the type constraint to
  // cty.DynamicPseudoType in order to save type information as part of the
  // value, and then also pass cty.DynamicPseudoType to method Decode to recover
  // the original value.
  //
  // cty.NilVal can be used to represent the absense of a value, but callers
  // must be careful to distinguish values that are absent at the Go layer
  // (cty.NilVal) vs. values that are absent at the cty layer (cty.NullVal
  // results).