diff --git a/command/jsonstate/state.go b/command/jsonstate/state.go index ab1b29683..24eba59b5 100644 --- a/command/jsonstate/state.go +++ b/command/jsonstate/state.go @@ -259,6 +259,7 @@ func marshalResources(resources map[string]*states.Resource, module addrs.Module current := resource{ Address: r.Addr.Instance(k).String(), + Index: k, Type: resAddr.Type, Name: resAddr.Name, ProviderName: r.ProviderConfig.Provider.String(), @@ -276,10 +277,6 @@ func marshalResources(resources map[string]*states.Resource, module addrs.Module ) } - if r.EachMode != states.NoEach { - current.Index = k - } - schema, _ := schemas.ResourceTypeConfig( r.ProviderConfig.Provider, resAddr.Mode, diff --git a/command/jsonstate/state_test.go b/command/jsonstate/state_test.go index f5b47fe05..55d3c47f6 100644 --- a/command/jsonstate/state_test.go +++ b/command/jsonstate/state_test.go @@ -193,7 +193,6 @@ func TestMarshalResources(t *testing.T) { Name: "bar", }, }, - EachMode: states.NoEach, Instances: map[addrs.InstanceKey]*states.ResourceInstance{ addrs.NoKey: { Current: &states.ResourceInstanceObjectSrc{ @@ -237,7 +236,6 @@ func TestMarshalResources(t *testing.T) { Name: "bar", }, }, - EachMode: states.EachList, Instances: map[addrs.InstanceKey]*states.ResourceInstance{ addrs.IntKey(0): { Current: &states.ResourceInstanceObjectSrc{ @@ -281,7 +279,6 @@ func TestMarshalResources(t *testing.T) { Name: "bar", }, }, - EachMode: states.EachMap, Instances: map[addrs.InstanceKey]*states.ResourceInstance{ addrs.StringKey("rockhopper"): { Current: &states.ResourceInstanceObjectSrc{ @@ -325,7 +322,6 @@ func TestMarshalResources(t *testing.T) { Name: "bar", }, }, - EachMode: states.NoEach, Instances: map[addrs.InstanceKey]*states.ResourceInstance{ addrs.NoKey: { Deposed: map[states.DeposedKey]*states.ResourceInstanceObjectSrc{ @@ -371,7 +367,6 @@ func TestMarshalResources(t *testing.T) { Name: "bar", }, }, - EachMode: states.NoEach, Instances: map[addrs.InstanceKey]*states.ResourceInstance{ addrs.NoKey: { Deposed: map[states.DeposedKey]*states.ResourceInstanceObjectSrc{ diff --git a/states/statemgr/testing.go b/states/statemgr/testing.go index d36c35b99..5ebc40f2f 100644 --- a/states/statemgr/testing.go +++ b/states/statemgr/testing.go @@ -154,6 +154,6 @@ func TestFullInitialState() *states.State { Provider: addrs.NewLegacyProvider(rAddr.ImpliedProvider()), Module: addrs.RootModule, } - childMod.SetResourceMeta(rAddr, states.EachList, providerAddr) + childMod.SetResourceProvider(rAddr, providerAddr) return state }