0.11.13
variable "authorized_networks" {
description = "The networks that can connect to cloudsql"
type = "list"
default = [
{
name = "Manchester (DC1)"
value = "193.1.1.1/32"
},
{
name = "Manchester (DC2)"
value = "193.0.0.0/32"
}
]
}
#Create the instance
resource "google_sql_database_instance" "master" {
count = "${var.create_master}"
name = "${var.instancename}"
database_version = "${var.dbtype}"
project = "${var.project}"
region = "${var.region}"
settings {
tier = "${var.instance_tier}"
disk_size = "${var.initial_disk_size_gb}"
disk_type = "PD_SSD"
location_preference {
zone = "${var.zone}"
}
ip_configuration {
require_ssl = true
ipv4_enabled = true
authorized_networks = "${var.authorized_networks}"
}
backup_configuration {
binary_log_enabled = "${var.binlog_enabled}"
enabled = "${var.backup_enabled}"
start_time = "${var.start_time_hour}"
}
maintenance_window {
day = "${var.maint_window_day}"
hour = "${var.maint_window_hour}"
}
database_flags = "${var.flags}"
user_labels {
app = "${var.instancename}"
}
}
timeouts {
create = "30m"
delete = "60m"
update = "24h"
}
}
If there are no changes to authorized networks, then the terraform plan or apply should not show authorized networks that need updating.
every time a plan or apply is run, terraform shows authorized networks need updating. eg:
~ module.cloud-sql-mos-sandbox.google_sql_database_instance.master
settings.0.ip_configuration.0.authorized_networks.1271356474.expiration_time: "" => ""
settings.0.ip_configuration.0.authorized_networks.1271356474.name: "" => "My DC (DC2)"
settings.0.ip_configuration.0.authorized_networks.1271356474.value: "" => "193.0.0.0/32"
settings.0.ip_configuration.0.authorized_networks.1583501150.expiration_time: "" => ""
settings.0.ip_configuration.0.authorized_networks.1583501150.name: "" => "My DC (DC1)"
settings.0.ip_configuration.0.authorized_networks.1583501150.value: "" => "193.1.1.1/32"
settings.0.ip_configuration.0.authorized_networks.2376941909.expiration_time: "1970-01-01T00:00:00Z" => ""
settings.0.ip_configuration.0.authorized_networks.2376941909.name: "Manchester (DC1)" => ""
settings.0.ip_configuration.0.authorized_networks.2376941909.value: "193.1.1.1/32" => ""
settings.0.ip_configuration.0.authorized_networks.2550682161.expiration_time: "1970-01-01T00:00:00Z" => ""
settings.0.ip_configuration.0.authorized_networks.2550682161.name: "Manchester (DC2)" => ""
settings.0.ip_configuration.0.authorized_networks.2550682161.value: "193.0.0.0/32" => ""
Plan: 0 to add, 1 to change, 0 to destroy.
terraform applyCan confirm the same behavior with Terraform v0.11.8; we first noticed it on Tue, 2 Apr 2019.
I opened a ticket with Google Support yesterday. It appears to be a Google Cloud SDK or CloudSQL issue, given that we can reproduce the behavior by repeatedly running the following command against any of our CloudSQL instances:
gcloud sql instances describe cloudsql_instance_name \
--project google_project_name \
--format=value\(settings.ipConfiguration.authorizedNetworks[0].expirationTime\)
The response should be an empty string. However, ~20-30% of the time, the response is the epoch time in ISO 8601 format: 1970-01-01T00:00:00Z
Thats very reassuring to know - i thought i was going mad because its only happening intermittently so sometimes the plan is fine, and you run it again after 5 minutes and its an update even though nothing has changed.
I'd agree that we also first noticed it on Tuesday 2nd.
~20-30% of the time
This is just anecdotal but we're seeing this too and it feels a heck of a lot more frequent then just 20-30% of the time. I'm having to run terraform apply ~10-15 times before it reports no changes.
hi,
as a workaround while google work on a bug fix - i tried to add the following to my cloudsql module:
lifecycle {
ignore_changes = [
"settings.0.ip_configuration.0.authorized_networks.%"
]
}
but doesnt seem to have the desired impact. Has anyone else tried this or have a workaround?
Also tried at more granular level:
lifecycle {
ignore_changes = [
"settings.0.ip_configuration.0.authorized_networks.%.expiration_time"
]
}
Hi,
FYI from Google.
Thank you for contacting Google Cloud Platform Support.
I did try to reproduce your issue on my project, and I got the same results as for your instance. It means that it is an API issue.
The issue was previously known to our engineers. I did noticed our engineers about your issue. I did also create public issue for you.
For the time being, I do not know any workaround for your issue. Also please note that there is no ETA to resolve it.
the issue can be tracked here: https://issuetracker.google.com/130014385
Thanks
Mos
FYI, received this from our Google Support rep last night:
We have a consensus! I will be consulting with the SQL API developers since this has been confirmed as an API issue instead of Terraform, good catch. I will keep you updated as I know more.
One additional note : I tried setting expiration_time = 1970-01-01T00:00:00Z in a TF CloudSQL instance config authorized_networks stanza, but the result was the same behavior in the opposite manner: 20-30% of the time, the defined value would be stripped by Google and replaced with an empty string. ๐
Admittedly, the above was a punt. Had hoped setting the value to the epoch might act as a -1 equivalent (common for a 'never expire' value in many things), but nooooope.
This should be resolved; there was an error in the the API caused by a partial rollout of a bad deployment that's now been rolled back. I'll leave this issue open for a few hours in case anyone is seeing this problem still, and close it out if not.
Ran a wrapper script that executes the gcloud command I posted above, and ran Terraform plan several times. The reported issue appears to have been resolved.
#COMPUTE_PROJ,#TOTAL_PASSES,#COUNT_WITH_EXPIRATION,#COUNT_WITHOUT_EXPIRATION
redacted,300,0,300
Thanks! I'll close this out in that case, if anyone experiences it still feel free to comment.
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
This should be resolved; there was an error in the the API caused by a partial rollout of a bad deployment that's now been rolled back. I'll leave this issue open for a few hours in case anyone is seeing this problem still, and close it out if not.