func NewInstanceInfo(addr addrs.AbsResourceInstance) *InstanceInfo {
	path := make([]string, len(addr.Module))
	for i, step := range addr.Module {
		if step.InstanceKey != addrs.NoKey {
			panic("NewInstanceInfo cannot convert module instance with key")
		}
		path[i] = step.Name
	}
	id := fmt.Sprintf("%s.%s", addr.Resource.Resource.Type, addr.Resource.Resource.Name)
	if addr.Resource.Resource.Mode == addrs.DataResourceMode {
		id = "data." + id
	}
	if addr.Resource.Key != addrs.NoKey {
		switch k := addr.Resource.Key.(type) {
		case addrs.IntKey:
			id = id + fmt.Sprintf(".%d", int(k))
		default:
			panic(fmt.Sprintf("NewInstanceInfo cannot convert resource instance with %T instance key", addr.Resource.Key))
		}
	}
	return &InstanceInfo{
		Id:         id,
		ModulePath: path,
		Type:       addr.Resource.Resource.Type,
	}
}
NewInstanceInfo constructs an InstanceInfo from an addrs.AbsResourceInstance.

InstanceInfo is a legacy type, and uses of it should be gradually replaced
by direct use of addrs.AbsResource or addrs.AbsResourceInstance as
appropriate.

The legacy InstanceInfo type cannot represent module instances with instance
keys, so this function will panic if given such a path. Uses of this type
should all be removed or replaced before implementing "count" and "for_each"
arguments on modules in order to avoid such panics.

This legacy type also cannot represent resource instances with string
instance keys. It will panic if the given key is not either NoKey or an
IntKey.
package terraform
import (
	"fmt"
	"reflect"
	"sort"
	"strconv"
	"strings"
	"github.com/mitchellh/copystructure"
	"github.com/mitchellh/reflectwalk"
	"github.com/zclconf/go-cty/cty"
	"github.com/hashicorp/terraform/addrs"
	"github.com/hashicorp/terraform/config"
	"github.com/hashicorp/terraform/configs/configschema"
	"github.com/hashicorp/terraform/configs/hcl2shim"
)
type Resource struct {
	Name       string
	Type       string
	CountIndex int
	Id           string
	Info         *InstanceInfo
	Config       *ResourceConfig
	Dependencies []string
	Diff         *InstanceDiff
	Provider     ResourceProvider
	State        *InstanceState
	Flags        ResourceFlag
}
func NewResource(addr addrs.ResourceInstance) *Resource {
	ret := &Resource{
		Name: addr.Resource.Name,
		Type: addr.Resource.Type,
	}
	if addr.Key != addrs.NoKey {
		switch tk := addr.Key.(type) {
		case addrs.IntKey:
			ret.CountIndex = int(tk)
		default:
			panic(fmt.Errorf("resource instance with key %#v is not supported", addr.Key))
		}
	}
	return ret
}
type ResourceFlag byte
type InstanceInfo struct {
	Id string
	ModulePath []string
	Type string
	uniqueExtra string
}