【问题标题】:Terraform Error: Extraneous label for module when running terraform initTerraform 错误:运行 terraform init 时模块的无关标签
【发布时间】:2021-01-20 17:08:19
【问题描述】:

我在运行 terraform init 时收到此错误:

Error: Extraneous label for module

  on rds.tf line 22, in module "rds" "app":
  22: module "rds" "app" {

Only 1 labels (name) are expected for module blocks.

我创建了两个模块“rds”和“app”,在创建数据库实例时我都会引用它们:

# PostgreSQL RDS App Instance
module "rds" "app" {

如何解决这个错误?

【问题讨论】:

  • module "module_name" {} 应该是语法,我不认为你可以用两个名字调用模块,如果你想调用模块两次,分别调用它们 module "rds" {} 和 module "app " {}

标签: amazon-web-services syntax-error terraform terraform-provider-aws terraform-modules


【解决方案1】:

如果使用 TF 0.13,另一种选择是使用计数设置为 2 的单个模块,然后使用 count.index 从预定义的列表 [] 变量中获取该迭代的特定名称。

https://blog.ktz.me/terraform-0-13-count-modules/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-20
    • 2018-11-28
    • 2021-01-16
    • 2018-11-21
    • 1970-01-01
    • 2019-07-05
    • 1970-01-01
    • 2021-01-30
    相关资源
    最近更新 更多