Reputation: 71
I'am trying to create a google cloud sql instance via terraform and i have to enable point in time recovery option but I have the following error :
Error: Unsupported argument
on cloud-sql.tf line 39, in resource "google_sql_database_instance" "si_geny_postgres_logfaces": 39: point_in_time_recovery_enabled = true
An argument named "point_in_time_recovery_enabled" is not expected here.
here is my terraform file :
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
}
Any idea please?
Upvotes: 1
Views: 10081
Reputation: 1
When I want to use availability_type to create a multi-region high-availability instance, the following error occurs:
│ Error: Unsupported argument
│ on main.tf line 35, in resource "google_sql_database_instance" "mysql613ha":
│ 35: availability_type = "REGIONAL"
│ An argument named "availability_type" is not expected here.
Terraform version:
Terraform v1.4.6
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v4.67.0
main.tf:
provider "google" {
project = "yzh-test-358106"
region = "asia-southeast1"
}
#https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance
resource "google_sql_database_instance" "mysql613" {
name = "my613tftest"
database_version = "MYSQL_5_7"
region = "asia-southeast1"
availability_type = "REGIONAL"
#https://registry.terraform.io/providers/hashicorp/google/latest/docs
settings {
# Second-generation instance tiers are based on the machine
# type. See argument reference below.
tier = "db-custom-2-6144"
disk_size = 100
backup_configuration{
enabled = true
binary_log_enabled = true
location = "us"
}
}
}
Have you ever encountered this problem?
Upvotes: 0
Reputation: 29714
Typically when you get these:
An argument named "..." is not expected here.
issues on terraform. First thing to check is that your file is correct and the property in the error is actually listed in the docs (which this one is).
Next thing is to check that your using the latest version of the provider. As properties are introduced they get added to the documentation but it's not always obvious which version of the provider they were added. You can check to see whichever is the latest provider from the release notes.
So you should upgrade your provider version to the latest (3.40.0) as of time of writing:
provider "google" {
version = "=3.40.0"
project = var.project_id
region = var.region
zone = var.gce_zone
}
Upvotes: 4