Skip to content

Specify a module version when using terraform init -from-module and a private registry module source #38041

@bminahan73

Description

@bminahan73

Terraform Version

1.9.8

Use Cases

I want to fully automate creation of new terraform configurations, starting from a module in a private module registry, saving developers time with initial project setup in a scaled org.

Attempted Solutions

-from-module seemed like the best way to do this, as I could simply run terraform init -from-module=<my module> in a new git repo as a starting point for a new configuration. I was also evaluating terragrunt scaffold for this automation use case, but would like to stick with Terraform only if possible.

-from-module works great for my modules in a private module registry (gitlab), but ONLY for the latest version of the module. If I wanted to deploy a previous module version, I don't think there is a way to do that.

Proposal

terraform init -from-module="gitlab.com/foo/my-module/local"

works, but pulls only latest version of the module.

Add a version specification:

terraform init -from-module="gitlab.com/foo/my-module/local?version=1.0.1"

Currently this gives an Invalid module source address error. Instead it should pull version 1.0.1 of the module.

References

terragrunt scaffold

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions