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

Document how to specify versions for -from-module with the registry #25409

Open
chilversc opened this issue Jun 26, 2020 · 3 comments
Open

Document how to specify versions for -from-module with the registry #25409

chilversc opened this issue Jun 26, 2020 · 3 comments

Comments

@chilversc
Copy link

The current documentation for init -from-module does not explain how to create a valid MODULE-SOURCE for use with the terraform registry.

For example, when looking at the module terraform-google-modules/network, it lists the following:

module "network" {
  source  = "terraform-google-modules/network/google"
  version = "2.4.0"
  # insert the 3 required variables here
}

It's not documented how you would use this with the registry, the obvious solutions of terraform init --from-module=terraform-google-modules/network/google?ref=2.4.0 and ?version=2.4.0 both fail with the error:

Error: Module not found

The module address "terraform-google-modules/network/google?ref=2.4.0" could
not be resolved.

Further more, its not clear how to handle version constraints such as version = "~> 2.4".

@apparentlymart
Copy link
Member

Hi @chilversc,

The -from-module feature is intended as an aid to getting started quickly using an existing module as a template, and so selecting a particular version of that module (rather than just taking the latest version) is not part of its featureset.

Therefore I think this issue is not really a documentation issue so much as a feature request for using a particular non-latest module version with -from-module. In that case, I'd be curious to hear more about what you are doing that requires that feature; the use-cases that motivated -from-module originally didn't require that, but perhaps you are aiming to do something a little different with the feature and we could see if extending the scope of -from-module to meet that use-case is desirable.

Thanks!

@apparentlymart apparentlymart added cli waiting-response An issue/pull request is waiting for a response from the community labels Jun 29, 2020
@chilversc
Copy link
Author

In this particular instance the project is using terragrunt, which makes use of the -from-module flag, so I was trying to figure out how to create a valid way to pass in a version constraint.

@ghost ghost removed waiting-response An issue/pull request is waiting for a response from the community labels Jun 30, 2020
@apparentlymart
Copy link
Member

Ahh yes... Terragrunt is using -from-module in a slightly different way than it was intended: as a way to obtain a module to execute directly rather than to use it as a basis for creating a new configuration to be published elsewhere.

At the moment there is no way to achieve that with Terragrunt. Modules from module registries are usually modules to be called from other modules rather than to be used directly, so using directly using a registry module from Terragrunt is not a use-case the registry mechanism is anticipating; it's more common for root modules to be obtained directly from git using git clone (or some other VCS) and for the registry protocol to be used only for shared child modules that root module uses.

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