Can you get a module's declared name from within the module?

Is there a way to get a module’s name from within the module? For example, if you have

module "frontend" {
  ...
}

can you get the value “frontend” from within the module by accessing something like self.name?

Hi @squarebracket,

The label in the module block is a concern of the calling module rather than the called module, so that name isn’t directly visible to the called module. If you want to make a similar string available to the called module then you’ll need to pass it explicitly as an input variable:

module "frontend" {
  source = "..."

  name = "frontend"
}

Yeah, I just wanted to avoid it if possible. Thanks for taking the time to answer!