Trying to get the source of a module

Hi everyone !

So we are right now in the proccess of developping a lot of module that will deploy our AWS infrastructure. One thing that i’m trying to do right now is a way to add a tag in each AWS ressources so it will show wich module it come from and more importatly, the git tag (ex the result of a git describe) or simply, the version of the module we are using.

One way would be to have acces to the source var of the module when call, but so far found no way to get it, and I d’ont want to set a seperte variable with the version number because it is too easy to pass over it…

Hi @wyldspyder,

Indeed, a Terraform module does not have access to its own source location or version number. In common with many other language ecosystems, we expect that a module can “know its own name” (hard-code it) and that if a version number is needed then it would be maintained as part of the source code of the module, perhaps updated automatically by tooling as part of publishing a new version of the module.

1 Like