Terraform-provider-google: Lost parameters from request for Google API when create or update google_sql_database_instance.

Created on 24 Jan 2019  ยท  4Comments  ยท  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.

Summary

Unable setting option that the settings.ipconfiguration.ipv4_enabled to false when create or update google_sql_database_instance by terraform.
Maybe, the reason is that the parameter is lost when reqeust to Google API.
I want to set the option on reqeust for Google API.

Terraform Version

Terraform v0.11.11
+ provider.google v1.20.0

Affected Resources(s)

  • google_sql_database_instance

Terraform Configuration Files

// Create Cloud SQL for xxx
resource "google_sql_database_instance" "db-instance-hogehoge" {
  name = "hogehoge"

  region           = "asia-northeast1"
  database_version = "POSTGRES_9_6"

  settings {
    tier            = "db-custom-2-8192"
    disk_type       = "PD_SSD"
    disk_size       = "${lookup(var.disk_size_xxx, "${terraform.workspace}")}"
    disk_autoresize = "true"

    availability_type = "REGIONAL"

    maintenance_window = {
      day  = "7"
      hour = "21"
    }

    ip_configuration {ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€//โ†ใ€€
      ipv4_enabled = "false"                                         //โ†
      private_network = "projects/pjname/global/networks/hogehoge"   //โ†
    }
  }
}

// Set postgres Password
resource "google_sql_user" "hogehoge-postgres-user" {
  name     = "postgres"
  instance = "${google_sql_database_instance.db-instance-hogehoge.name}"
  password = "postgres"
}

Debug Output(gist)

Expected Behavior

  • I expecting to configuration the ipv4_enabled to false in the Google API Request.

    • I expecting to removing public ip address from SQL instance.

Actual Behavior

  • The Terraform able to read configuration and create or update instance, but the parameter(ipv4_enabled) is lost when request to Google API.(Please see the Debug Output and Terraform Configuration file)
  • So, Even if not change configuration, the log output "update in-place" when run command "terraform plan" after run command "terraform apply".

``` :example
terraform apply
[...]

terraform plan

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place

Terraform will perform the following actions:

~ google_sql_database_instance.db-instance-hogehoge
settings.0.ip_configuration.0.ipv4_enabled: "true" => "false"

Plan: 0 to add, 1 to change, 0 to destroy.


```

Steps to Reproduce

  1. Set two parameter in a terraform configuration file, fisrt value is the ipv4_enable, it change to false, and second value is the private_network, set any value in it.
  2. Create google_sql_databse_instance or update it. (terraform apply)
  3. Check difference (terraform plan)

Important Factoids

When any instance create, the ipv4_enabled is lost from request for Google API.(Please see Debug Output "case created instance" line 20.)
When any instance update, the private_network and the ipv4_enabled (or all ip_configration option?) is lost from request for Google API.(Please see Debug Output "case updated instance" line 54.)

References

bug

Most helpful comment

This should be fixed in 2.0.0, once that's released please feel free to comment on this issue / open a new one.

All 4 comments

I think I am seeing this as well. After enabling Private IP, and future updates cause this error:

Error, failed to update instance xxx: googleapi: Error 400: This operation isn"t valid for this instance., invalidOperation

Are you using the google-beta provider?

This should be fixed in 2.0.0, once that's released please feel free to comment on this issue / open a new one.

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