【问题标题】:Terraform cloud failing when referencing module using relative local path使用相对本地路径引用模块时,Terraform 云失败
【发布时间】:2021-02-21 18:59:16
【问题描述】:

我有一个包含几个单独配置的存储库,这些配置共享一些模块,并使用看起来像 ../../modules/rabbitmq 的相对路径引用这些模块。目录设置如下:

tf/
  configs/
    thing-1/
    thing-2/
  modules/
    rabbitmq/
    cluster/
    ...

使用远程后端设置配置以使用 TF Cloud 进行运行和状态:

terraform {
  backend "remote" {
    hostname     = "app.terraform.io"
    organization = "my-org"

    workspaces {
      prefix = "config-1-"
    }
  }
}

运行terraform init 工作正常。当我尝试在本地运行 terrform plan 时,它给了我一个错误提示:

Initializing modules...
- rabbitmq in 

Error: Unreadable module directory

Unable to evaluate directory symlink: lstat ../../modules: no such file or
directory

...好像模块目录没有上传到 TF Cloud 或其他东西。什么给了?

【问题讨论】:

    标签: terraform terraform-cloud


    【解决方案1】:

    原来问题是(惊喜,惊喜!)没有将模块目录上传到 TF Cloud。这是因为配置和 TF Cloud 工作区设置都不包含任何表明此配置文件夹是更大文件系统的一部分的迹象。默认情况下仅上传运行 terraform 的目录(及其所有内容)。

    要解决此问题,我必须访问 Terraform Cloud 中给定工作区的“设置 > 常规”页面,并更改 Terraform Working Directory 设置以指定配置的路径,相对于相关根目录 - 在此案例:tf/configs/config-1

    之后,运行terraform plan 会显示一条消息,指示它将上传哪个父目录,以传达与工作区相关的整个上下文。 ?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-14
      • 1970-01-01
      • 2011-01-29
      • 1970-01-01
      • 2016-10-27
      • 2011-05-09
      相关资源
      最近更新 更多