$ terraform -v
Terraform v0.12.1
google_sql_database_instance
provider "google" {
project = "x"
region = "x"
}
variable "gcp_mysql_databasename" {}
resource "google_sql_database_instance" "mysql-master" {
database_version = "MYSQL_5_7"
region = "x"
settings {
# Second-generation instance tiers are based on the machine
# type. See argument reference below.
tier = "db-f1-micro"
ip_configuration {
ipv4_enabled = true
authorized_networks = [
{
name = "<redacted>"
value = "<redacted>"
},
{
name = "<redacted>"
value = "<redacted>"
}
]
}
}
}
resource "google_sql_database" "mysql" {
instance = "${google_sql_database_instance.mysql-master.name}"
name = "${var.gcp_mysql_databasename}"
}
output "gcp_mysql_endpoint" {
value = "${google_sql_database_instance.mysql-master.first_ip_address}"
}
output "gcp_mysql_instance_name" {
value = "${google_sql_database_instance.mysql-master.name}"
}
n/a
Error: Unsupported argument
on gcp_mysql.tf line 13, in resource "google_sql_database_instance" "mysql-master":
13: authorized_networks = [
An argument named "authorized_networks" is not expected here. Did you mean to
define a block of type "authorized_networks"?
Non breaking changes. Or noted in changelog clearly. Or documentation updated here https://www.terraform.io/docs/providers/google/r/sql_database_instance.html
Error as above
terraform planWe know our config is older, but we did not expect a breaking change in a minor version. It could also be the new terraform version.
provider version 2.5.1 - 2.8.0 causes the same issue
It seems more likely that it's a syntax difference, and perhaps 2.8.0 isn't as resilient to differing block syntax.
Docs show with equals sign https://www.terraform.io/docs/providers/google/r/sql_database_instance.html
Now I'm unsure what this error is really saying above. What is the correct syntax for authorized_networks in 2.8.0?
Resolved:
Terraform 0.12.x introduced the changes to syntax. Running terraform 0.12upgrade solved the issue. We only detected the provider change, hence this bug report.
I'm having the same problem, but I have already migrated to terraform 0.12 and ran that command before. I'm using google-beta provider.
@h4xnoodle is the syntax the same as it was before for authorized_networks?
@nklops the syntax ended up changing from an array to duplicate blocks:
authorized_networks = [
{
name = "<redacted>"
value = "<redacted>"
},
{
name = "<redacted>"
value = "<redacted>"
}
]
to
authorized_networks {
name = "<redacted>"
value = "<redacted>"
}
authorized_networks {
name = "<redacted>"
value = "<redacted>"
}
hope that helps!
Oh, it does.
Thank you!
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!
Most helpful comment
Oh, it does.
Thank you!