terraform plan error : unsupported argument : An argument named "point_in_time_recovery_enabled" is not expected here

terraform plan error : unsupported argument : An argument named "point_in_time_recovery_enabled" is not expected here

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

错误:不支持的参数

在云上-sql.tf 第 39 行,在资源“google_sql_database_instance”“si_geny_postgres_logfaces”中: 39: point_in_time_recovery_enabled = 真

这里不需要名为“point_in_time_recovery_enabled”的参数。

这是我的地形文件 :

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
}

有什么想法吗?

通常当你得到这些时:

An argument named "..." is not expected here.

关于地形的问题。首先要检查的是您的文件是否正确,错误中的 属性 实际上已在文档中列出 (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
}