Terraform provider to manage providers and modules published to the registry


are there plans to provide an API and/or a terraform provider to manage providers and modules that are published to the registry?

We are already managing all of our Github projects for our public modules using terraform, and having the ability to automatically publish them with terraform itself would be awesome.

Best regards,

Hi @pdecat,

The public Terraform Registry is built around GitHub, reacting to events in your repository to trigger publishing actions. Creating a new tag in your repository whose name is a version number will cause Terraform Registry to publish the content of that tag as a new version of your module package.

Because the registry is just an index of content on GitHub, it doesn’t have any APIs for publishing directly itself. A mechanism for automated publishing would, I think, be best built as something that automates the creation of a tag in your GitHub repository.

Terraform is designed to manage long-lived infrastructure that will be modified in place or completely replaced over time, and isn’t typically a good fit for “build and publish”-type situations, which create immutable artifacts and then immediately “forget” them. Therefore I’m not sure that publishing new versions of a module would be a use-case within Terraform’s typical scope; I’d generally recommend using build automation tools for that sort of thing.

Hi @apparentlymart, thanks for the prompt reply.

I’m not talking about publishing new versions using terraform, but about automating only the initial process of publishing modules which can only be done from the web UI AFAICT, e.g.:

That only has to be done once and for all, and will persist over time, doesn’t it?

Hi @pdecat,

Indeed, I imagine in principle there could be an API for that operation, though as far as I know there isn’t a publicly-committed one right now.

It is still a bit tricky in that it’s interacting with GitHub repositories, but you’re right that registering a repository as being a Terraform module package could in principle be represented as creating a Terraform resource instance, though after that I’m not sure it would do anything useful during update or destroy because there aren’t really any settings to change for a provider directly in the registry, and deleting a previously-registered repository isn’t allowed.

As an alternative to an API, maybe the terraform registry could automatically publish providers and modules of an already registered Github organization that have an explicit tag (e.g. terraform-registry) or file (.terraform-registry).