有没有办法用分支名称或 git 哈希调用 "Terraform init -from-module"?

Is there a way to call "Terraform init -from-module" with a branch name or git hash?

例如:

terraform init -from-module github.com/someone/some_repo@some_branch  

terraform init -from-module github.com/someone/some_repo@<some git hash>

指定 github url 作为您的模块源,terraform 应该完成剩下的工作。

module "consul" {
  source = "github.com/hashicorp/example"
}

有关详细信息,请参阅 this

添加到 shamanth 的回答:

文档仅提供模块示例:https://www.terraform.io/docs/modules/sources.html#parameters
但在使用 terraform init 时可以应用相同的格式。

例如,使用 https:

github.com/some_user/some_repo?ref=my_branch_or_SHA/sub_folder_containing_HCL_files