func hclField(m map[string]interface{}, key string) (string, error) {
	v, ok := m[key]
	if !ok {
		return "", nil
	}
	b, err := hclencoder.Encode(v)
	if err != nil {
		return "", err
	}
	return fmt.Sprintf("%s = %s", key, string(b)), nil
}
hclField returns a hcl marshaled field e.g. `name = "foo"`, if present.
For required fields, use the hcl func.
package template
import (
	"fmt"
	"regexp"
	"strings"
	"time"
	"github.com/rodaine/hclencoder"
)
var funcMap = map[string]interface{}{
	"get":               get,
	"has":               has,
	"hcl":               hcl,
	"hclField":          hclField,
	"merge":             merge,
	"replace":           replace,
	"resourceName":      resourceName,
	"now":               time.Now,
	"trimSpace":         strings.TrimSpace,
	"regexReplaceAll":   regexReplaceAll,
	"makeSlice":         makeSlice,
	"schemaDescription": schemaDescription,
}
var invalidIDRE = regexp.MustCompile("[^a-z0-9_]")
func get(m map[string]interface{}, key string, def ...interface{}) interface{} {
	split := strings.Split(key, ".")
	for i, k := range split {
		v, ok := m[k]
		switch {
		case !ok:
			if len(def) == 1 {
				return def[0]
			}
			return nil
		case i == len(split)-1:
			return v
		default:
			m = v.(map[string]interface{})
		}
	}
	return nil
}
func has(m map[string]interface{}, key string) bool {
	return get(m, key) != nil
}
func hcl(v interface{}) (string, error) {
	b, err := hclencoder.Encode(v)
	if err != nil {
		return "", err
	}
	return strings.TrimSpace(string(b)), nil
}