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.
This commit is contained in:
Martin Atkins 2020-08-20 17:27:54 -07:00
parent d26ee0ea37
commit 9c246e9a01
1 changed files with 9 additions and 0 deletions

View File

@ -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 {