【问题标题】:Terraform Error: Argument or block definition required when I run TF planTerraform 错误:运行 TF 计划时需要参数或块定义
【发布时间】:2021-02-18 13:17:32
【问题描述】:

我创建了 2 个 rds 实例,在运行 tf plan 时,我收到关于不支持的块类型的 terraform 错误:

Error: Unsupported block type

  on rds.tf line 85, in module "rds":
  85: resource "random_string" "rds_password_dr" {

Blocks of type "resource" are not expected here.

Error: Unsupported block type

  on rds.tf line 95, in module "rds":
  95: module "rds_dr" {

Blocks of type "module" are not expected here.

这是我的 rds.tf 文件中的代码:

# PostgreSQL RDS App Instance
module "rds" {
  source = "git@github.com:************"

  name           = var.rds_name_app
  engine         = var.rds_engine_app
  engine_version = var.rds_engine_version_app
  family         = var.rds_family_app
  instance_class = var.rds_instance_class_app

  # WARNING: 'terraform taint random_string.rds_password' must be run prior to recreating the DB if it is destroyed
  password                   = random_string.rds_password.result
  port                       = var.rds_port_app
  "
  "

# PostgreSQL RDS DR Password
resource "random_string" "rds_password_dr" {
  length           = 16
  override_special = "!&*-_=+[]{}<>:?"

  keepers = {
    rds_id = "${var.rds_name_dr}-${var.environment}-${var.rds_engine_dr}"
  }
}

# PostgreSQL RDS DR Instance
module "rds_dr" {
  source = "git@github.com:notarize/terraform-aws-rds.git?ref=v0.0.1"

  name           = var.rds_name_dr
  engine         = var.rds_engine_dr
  engine_version = var.rds_engine_version_dr
  family         = var.rds_family_dr
  instance_class = var.rds_instance_class_dr

  # WARNING: 'terraform taint random_string.rds_password' must be run prior to recreating the DB if it is destroyed
  password                   = random_string.rds_password.result
  port                       = var.rds_port_dr
  "
  "

我不知道我为什么会得到这个?有人请帮帮我。

【问题讨论】:

  • rds.tf 第 129 行的 ` 行中有什么内容,`?
  • @Marcin 请看问题,我把它改得更详细了

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


【解决方案1】:

您尚未关闭 module 块(module "rds"module "rds_dr")。在两个 module 块的末尾还有几个奇怪的双引号。

删除双引号并关闭块(使用})。

【讨论】:

  • @Ixop 我不认为这解决了问题,我试过了。你能再看一下代码吗?
  • @Myra “我认为这不能解决问题”是什么意思?更改后问题仍然存在还是不存在?您更新的代码末尾有一个额外的}。您在问题中列出的错误与更新后的代码不匹配,如果仍有错误,请也更新错误。
  • @Ixop 是的,我刚刚用我得到的新错误更新了问题。也很抱歉造成误解。
  • 这是一个新问题,需要一个新问题。我会回滚你的更改;请为新问题创建一个新问题。当您这样做时,请确保您显示相关代码 - 您显示的错误不属于您显示的代码
猜你喜欢
  • 2021-01-30
  • 2020-09-20
  • 2021-01-16
  • 2021-01-16
  • 2021-01-20
  • 1970-01-01
  • 2018-10-11
  • 2021-06-27
  • 1970-01-01
相关资源
最近更新 更多