From 9c246e9a013536baf39e2f6b18fb2fc02ff3eb78 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 20 Aug 2020 17:27:54 -0700 Subject: [PATCH] addrs: Resource.InModule, similar to Resource.Absolute The Resource.Absolute function is there to conveniently construct an AbsResource from a Resource by providing a module instance. Likewise, this new InModule method allows conveniently constructing a ConfigResource from a Resource by providing a module. --- addrs/resource.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addrs/resource.go b/addrs/resource.go index d2592c2a64..f0a4f79e12 100644 --- a/addrs/resource.go +++ b/addrs/resource.go @@ -50,6 +50,15 @@ func (r Resource) Absolute(module ModuleInstance) AbsResource { } } +// InModule returns a ConfigResource from the receiver and the given module +// address. +func (r Resource) InModule(module Module) ConfigResource { + return ConfigResource{ + Module: module, + Resource: r, + } +} + // ImpliedProvider returns the implied provider type name, for e.g. the "aws" in // "aws_instance" func (r Resource) ImpliedProvider() string {