code: 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
  }
docs: // NewResource constructs a legacy Resource object from an
  // addrs.ResourceInstance value.
  //
  // This is provided to shim to old codepaths that haven't been updated away
  // from this type yet. Since this old type is not able to represent instances
  // that have string keys, this function will panic if given a resource address
  // that has a string key.