diff --git a/internal/addrs/module_instance.go b/internal/addrs/module_instance.go index 2eb57948d..21afcb077 100644 --- a/internal/addrs/module_instance.go +++ b/internal/addrs/module_instance.go @@ -275,6 +275,14 @@ func (m ModuleInstance) String() string { return buf.String() } +type moduleInstanceKey string + +func (m ModuleInstance) UniqueKey() UniqueKey { + return moduleInstanceKey(m.String()) +} + +func (mk moduleInstanceKey) uniqueKeySigil() {} + // Equal returns true if the receiver and the given other value // contains the exact same parts. func (m ModuleInstance) Equal(o ModuleInstance) bool { diff --git a/internal/addrs/resource.go b/internal/addrs/resource.go index f22db05cb..a7b7ee308 100644 --- a/internal/addrs/resource.go +++ b/internal/addrs/resource.go @@ -292,6 +292,14 @@ func (r AbsResourceInstance) Less(o AbsResourceInstance) bool { } } +type absResourceInstanceKey string + +func (r AbsResourceInstance) UniqueKey() UniqueKey { + return absResourceInstanceKey(r.String()) +} + +func (r absResourceInstanceKey) uniqueKeySigil() {} + func (r AbsResourceInstance) absMoveableSigil() { // AbsResourceInstance is moveable } diff --git a/internal/addrs/unique_key_test.go b/internal/addrs/unique_key_test.go index 416899ca4..0926a0c37 100644 --- a/internal/addrs/unique_key_test.go +++ b/internal/addrs/unique_key_test.go @@ -46,6 +46,14 @@ func TestUniqueKeyer(t *testing.T) { }, Key: IntKey(1), }, + RootModuleInstance, + RootModuleInstance.Child("foo", NoKey), + RootModuleInstance.ResourceInstance( + DataResourceMode, + "boop", + "beep", + NoKey, + ), Self, }