我正在尝试使用terraform的一种方式,这是在Terraform启动和运行的书的末尾描述的。描述的模式说,您可以通过对每个环境(例如prod、dev、ad开发人员环境等)使用*.tfvars文件来定义您的活动环境。这些*.tfvars文件引用另一个回购中的模块,如下所示:
source = "git::https://github.com/github-user/my-module.git?ref=v0.0.1"
# required variables for `my-module` defined here
foo="bar"
这种模式对我来说很有意义
我不知道如何解决这个错误,尝试了各种版本的组合,但无法做到这一点;
在我的模块中:
terraform {
required_version = "~> 1.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 2.98.0". #or 2.62.1 ,1.6.0 depending on the what resource the module is for
}
}
}
我对terraform很陌生,当我将其中一个资源提取到一个模块中时,我得到了以下内容:
Error: Inconsistent dependency lock file
│
│ The following dependency selections recorded in the lock file are inconsistent with the current
│ configuration:
│ - provider registry.terraform.io/hashicorp/heroku: required by this configuration but no versi
我有一个terraform的module a,它创建了一个text文件,我需要在另一个module b中使用这个文本文件,我使用locals来提取文本文件的内容,如下所示,在module b中
locals {
ports = split("\n", file("ports.txt") )
}
但是terraform希望这个文件在开始时出现,抛出错误如下所示
Invalid value for "path" parameter: no file exists at
path/ports.txt; this function works
我克隆了,以便在地形中使用IaC定义的CI/CD管道。
然而,当我运行terraform 时,在所有子目录的每个"main.tf“中都会收到以下警告。下面的示例将取自子文件夹modules/iam-role/
TFLint in src/infrastructure/modules/iam-role/:
2 issue(s) found:
Warning: terraform "required_version" attribute is required (terraform_required_version)
on line 0:
(source c