首页 > 解决方案 > 带有 GCP 模块的 Terraform

问题描述

我开始使用带有 GCP 模块的 terraform,我是 Terraform 的新手。

我在 Terraform 中下载并放置了 GCP 模块(如“ Google VM ”)以使用它。

我在 google VM 模块之外创建了 main.tf 文件,我将这个模块称为“示例”文件夹中提供的 示例我将此示例复制/粘贴到我的带有 var.tfvars 的 main.tf 文件中(我放变量的地方)

当我执行“地形计划”时,我遇到了类似的错误

│ Error: Reference to undeclared input variable│
│   on main.tf line 31, in module "instance_template":
│   31:   project_id      = var.project_id│
│   An input variable with the name "project_id" has not been declared. This variable can be declared with a variable "project_id" {} block.

我想我忘记了一些东西....变量必须在模块中设置,而不是在根模块(tfvars)中?

感谢您的帮助

标签: google-cloud-platformmoduleterraform

解决方案


推荐阅读