Terraform-provider-google: authorized_networks definition for google_sql_database_instance breaks in 0.12.1 x 2.5.1+ of provider

Created on 6 Jun 2019  ·  7Comments  ·  Source: hashicorp/terraform-provider-google


Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • If an issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version

$ terraform -v
Terraform v0.12.1

Affected Resource(s)


google_sql_database_instance

Terraform Configuration Files

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}"
}

Debug Output

n/a

Panic Output

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"?

Expected Behavior


Non breaking changes. Or noted in changelog clearly. Or documentation updated here https://www.terraform.io/docs/providers/google/r/sql_database_instance.html

Actual Behavior

Error as above

Steps to Reproduce

  1. terraform plan

Important Factoids

We 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

References

  • #0000
bug

Most helpful comment

Oh, it does.

Thank you!

All 7 comments

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!

Was this page helpful?
0 / 5 - 0 ratings