Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tfe_registry_module support for subdirectory of package #518

Closed
evilensky opened this issue Jun 14, 2022 · 1 comment
Closed

tfe_registry_module support for subdirectory of package #518

evilensky opened this issue Jun 14, 2022 · 1 comment

Comments

@evilensky
Copy link

Use-cases

I would like to publish to private registry multiple modules from within the same private GitHub repository. According the the documentation for packages this is supported, including specific refs, via this nomenclature: github.com/hashicorp/example//modules/vpc?ref=v1.2.0

Attempted Solutions

None

Proposal

Bring this resource in-line with documented behaviors of module publishing, specifically the double forward slash to:

When the source of a module is a version control repository or archive file (generically, a "package"), the module itself may be in a sub-directory relative to the root of the package.

A special double-slash syntax is interpreted by Terraform to indicate that the remaining path after that point is a sub-directory within the package. For example:

@nfagerlund
Copy link
Member

@evilensky Hello! Thank you for sending feedback.

I'm closing this ticket for the time being, because unfortunately the tfe provider just can't do this!

What you're requesting sounds useful, but it would be a significant new feature in the Terraform Cloud/Terraform Enterprise private registry itself; it's not something the tfe provider could implement on its own. The registry as it exists today is designed to expect a single module per repository when publishing via VCS. (Details: Preparing a Module Repository, from the Terraform Cloud module publishing docs)

I've passed your request on to the Registry maintainers as a feature request, since like I said, it does sound useful. If they ever decide to add this feature to Terraform Cloud and Terraform Enterprise, we'll add it to the tfe provider right away.

This limitation also affects the public Terraform Registry; note that the Terraform language docs you linked to make a distinction between "packages" (random archives that Terraform downloads directly from VCS or blob storage) and modules from the Terraform Registry, and that the double-slash address syntax can only be used with module sources that involve Terraform downloading a whole tarball from somewhere that doesn't make guarantees about the structure of the contents.

If you want to publish multiple private modules out of a single repo today, you'll need to use the non-VCS-backed publishing flow. You'll need to use the Terraform Cloud API directly (API docs: create a module with no VCS connection), because that publishing flow doesn't fit the tfe provider's view of the world — it's not possible to represent those publishing API calls as a resource, the way we can represent a VCS connection as one.

If you decide to go that route, you'll want to build some kind of repeatable integration that packages the modules and publishes them to your registry via the API; you could do this with GitHub Actions, or some other CI service, or possibly even a chat-ops bot of some kind. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants