func (s *Schema) coreConfigSchemaBlock() *configschema.NestedBlock {
	ret := &configschema.NestedBlock{}
	if nested := s.Elem.(*Resource).coreConfigSchema(); nested != nil {
		ret.Block = *nested
	}
	switch s.Type {
	case TypeList:
		ret.Nesting = configschema.NestingList
	case TypeSet:
		ret.Nesting = configschema.NestingSet
	case TypeMap:
		ret.Nesting = configschema.NestingMap
	default:
		panic(fmt.Errorf("invalid s.Type %s for s.Elem being resource", s.Type))
	}
	ret.MinItems = s.MinItems
	ret.MaxItems = s.MaxItems
	if s.Required && s.MinItems == 0 {
		ret.MinItems = 1
	}
	if s.Optional && s.MinItems > 0 {
		ret.MinItems = 0
	}
	if s.Computed && !s.Optional {
		ret.MinItems = 0
		ret.MaxItems = 0
	}
	return ret
}
coreConfigSchemaBlock prepares a configschema.NestedBlock representation of
a schema. This is appropriate only for collections whose Elem is an instance
of Resource, and will panic otherwise.
package schema
import (
	"fmt"
	"github.com/hashicorp/terraform/configs/configschema"
	"github.com/zclconf/go-cty/cty"
)
func (m schemaMap) CoreConfigSchema() *configschema.Block {
	if len(m) == 0 {
		return &configschema.Block{}
	}
	ret := &configschema.Block{
		Attributes: map[string]*configschema.Attribute{},
		BlockTypes: map[string]*configschema.NestedBlock{},
	}
	for name, schema := range m {
		if schema.Elem == nil {
			ret.Attributes[name] = schema.coreConfigSchemaAttribute()
			continue
		}
		if schema.Type == TypeMap {
			if _, isResource := schema.Elem.(*Resource); isResource {
				sch := *schema  
				sch.Elem = &Schema{
					Type: TypeString,
				}
				ret.Attributes[name] = sch.coreConfigSchemaAttribute()
				continue
			}
		}
		switch schema.ConfigMode {
		case SchemaConfigModeAttr:
			ret.Attributes[name] = schema.coreConfigSchemaAttribute()
		case SchemaConfigModeBlock:
			ret.BlockTypes[name] = schema.coreConfigSchemaBlock()
		default:  
			if schema.Computed && !schema.Optional {
				ret.Attributes[name] = schema.coreConfigSchemaAttribute()
				continue
			}
			switch schema.Elem.(type) {
			case *Schema, ValueType:
				ret.Attributes[name] = schema.coreConfigSchemaAttribute()
			case *Resource:
				ret.BlockTypes[name] = schema.coreConfigSchemaBlock()
			default:
				panic(fmt.Errorf("invalid Schema.Elem %#v; need *Schema or *Resource", schema.Elem))
			}
		}
	}
	return ret
}
func (s *Schema) coreConfigSchemaAttribute() *configschema.Attribute {
	reqd := s.Required
	opt := s.Optional
	if reqd && s.DefaultFunc != nil {
		v, err := s.DefaultFunc()
		if err != nil || (err == nil && v != nil) {
			reqd = false
			opt = true
		}
	}
	return &configschema.Attribute{
		Type:        s.coreConfigSchemaType(),
		Optional:    opt,
		Required:    reqd,
		Computed:    s.Computed,
		Sensitive:   s.Sensitive,
		Description: s.Description,
	}
}