Versioning Modules Outside of the Registry

I am working on Terraform modules for a disconnected environment. How can I version the modules, since version pinning is highly advised? I have not been able to find anywhere in a module to set a version.

Hi @ziondef,

The only way to fully replicate the version constraint behavior of registry modules is to run your own private registry, which you can achieve either by using Terraform Cloud (which has a private registry service built in) or by running an separate unofficial implementation of the module registry protocol. There are a few community implementations of that protocol, though I don’t have direct experience with them so I can’t recommend any one in particular. Someone else in this forum might be able to share their experiences and make a recommendation.

Otherwise, you can use one of the other module source types that Terraform supports for module installation. They don’t directly support versioning in the same sense that the registry does – the registry serves as an indirection over these other source types that handles the version constraint resolution – but you can get a similar effect by publishing the different versions of your module at different locations that include the version number, and then you’d change version by updating the source argument to refer to a different versioned source. That could either mean including the version number as part of the path to the object, such as an S3 object key path, or using one of the supported version control system sources and specifying the ref argument to select a particular branch or tag from the repository.

1 Like

That definitely answers the question. I was missing a piece, but fortunately not an obvious one I guess I should have known as a newby. Thanks @apparentlymart