【问题标题】:terraform plan error : unsupported argument : An argument named "point_in_time_recovery_enabled" is not expected hereterraform 计划错误:不支持的参数:此处不应使用名为“point_in_time_recovery_enabled”的参数
【发布时间】:2021-01-09 16:11:17
【问题描述】:

我正在尝试通过 terraform 创建一个谷歌云 sql 实例,我必须启用时间点恢复选项,但出现以下错误:

错误:不支持的参数

在 cloud-sql.tf 第 39 行,资源“google_sql_database_instance”“si_geny_postgres_logfaces”中: 39: point_in_time_recovery_enabled = true

此处不应使用名为“point_in_time_recovery_enabled”的参数。

这是我的 terraform 文件

resource "google_sql_database_instance" "si_geny_postgres_logfaces" {

  project          = google_project.current_project.project_id
  region           = var.region
  name             = "si-sql-instance"
  database_version = "POSTGRES_12"

  lifecycle {
    prevent_destroy  = true
    ignore_changes = [
      settings[0].disk_size, name
    ]
  }

  settings {

    tier = "db-custom-2-7680"
    availability_type = "REGIONAL"

    ip_configuration {
      ipv4_enabled    = false
      private_network = data.google_compute_network.si_shared_vpc.self_link
    }

    location_preference {
      zone = var.gce_zone
    }

    #disk
    disk_type       = "PD_SSD"
    disk_autoresize = true
    disk_size       = 10 #GB

    backup_configuration {
      binary_log_enabled = false
      point_in_time_recovery_enabled = true
      enabled    = true
      start_time = "00:00"    // backup at midnight (GMT)
      location   = var.region // Custom Location for backups => BACKUP REGION
    }

    maintenance_window {
      day = 1
      hour = 3
      update_track = "stable"

    }
  }
}

main.tf

terraform {
  required_version = ">0.12.18"
}

provider "google" {
  version = "=3.20.0"
  project = var.project_id
  region = var.region
  zone = var.gce_zone
}

provider "google-beta" {
  version = "=3.20.0"
  project = var.project_id
  region = var.region
  zone = var.gce_zone
}

有什么想法吗?

【问题讨论】:

  • 我想您需要将您的 terraform 提供程序更新到最新版本。通常这些错误是因为此属性的引入晚于您使用的提供者
  • 貌似最新的版本是3.40.0
  • 说我在发行说明中看不到有关此属性的任何内容,因此它可能是一个错误
  • 感谢@Liam,你说得对,它现在可以工作了

标签: terraform terraform-provider-gcp


【解决方案1】:

通常当你得到这些时:

此处不应使用名为“...”的参数。

关于 terraform 的问题。首先要检查的是您的文件是否正确,并且错误中的属性实际上已列在文档中 (which this one is)。

接下来是检查您是否使用了最新版本的提供程序。随着属性的引入,它们被添加到文档中,但并不总是很明显它们添加了哪个版本的提供程序。您可以查看release notes 中的最新提供者。

因此,您应该在撰写本文时将您的提供程序版本升级到最新 (3.40.0):

provider "google" {
  version = "=3.40.0"
  project = var.project_id
  region = var.region
  zone = var.gce_zone
}

【讨论】: