Terraform 源 Gitlab 模块

Terraform 源 Gitlab 模块

我需要帮助从包含多个模块(如 ec2、vpc 等)的 gitlab 存储库中获取 terraform 模块。我在模块存储库中有两个分支 - 开发和主分支。我尝试了以下所有方法,但出现错误。我获取了类似下面的内容。我只需要 ssh,不需要 https。

source = "git::ssh://[email protected]:repo_name/modules.git//ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules.git//ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules.git/ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules/ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules//ec2?ref=develop"
"git::ssh://[email protected]/repo_name/modules//ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules.git//ec2"
"git::ssh://[email protected]:repo_name/modules.git?ref=ec2"
"git::ssh://[email protected]:repo_name/modules.git?ref=develop//ec2"
"git::ssh://[email protected]:repo_name/modules.git/develop/ec2"
"git::ssh://[email protected]:repo_name/modules.git//ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules.git/develop/ec2"
"git::ssh://[email protected]:repo_name/modules/ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules//ec2"

这是我得到的错误


│ Module "ec2" (declared at compute/main.tf line 1)
│ has invalid source address
│ "git::ssh://[email protected]:repo_name/modules//ec2": Terraform
│ cannot detect a supported external module source type for

答案1

这是我的一个项目中的一个工作示例:

module "sql_cluster" {
  source = "git::ssh://[email protected]/foo/bar/tf-modules.git//data/database-cluster?ref=main"

这里,分支名称是“main”,但请注意它可以是标签或其他参考。

相关内容