-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
bugforward/reviewIn review; remove label to forwardIn review; remove label to forwardservice/sqladmin-cpwaiting-response
Description
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 a user, that user is claiming responsibility for the issue.
- Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.
Terraform Version & Provider Version(s)
Terraform v1.14.4
on darwin_arm64
- provider registry.terraform.io/hashicorp/google v7.20.0
- provider registry.terraform.io/hashicorp/google-beta v7.20.0
Affected Resource(s)
google_sql_database_instance
Terraform Configuration
resource "google_sql_database_instance" "this" {
name = "my-instance"
project = "my-project-123456"
region = "us-east1"
database_version = "POSTGRES_13"
deletion_protection = true
settings {
tier = "db-custom-1-3840"
ip_configuration {
ipv4_enabled = true
private_network = "projects/my-project-123456/global/networks/my-network"
ssl_mode = "ALLOW_UNENCRYPTED_AND_ENCRYPTED"
dynamic "authorized_networks" {
for_each = {
"NAT Gateway East" = "123.45.100.1/32"
}
content {
name = authorized_networks.key
value = authorized_networks.value
}
}
"psc_config" {
for_each = var.psc_enabled ? [1] : []
content {
# Problematic: when toggling this value
psc_enabled = true
allowed_consumer_projects = []
}
}
}
}
}
Debug Output
No response
Expected Behavior
When changing psc_enabled from false to true (or vice versa), Terraform should:
- Either make multiple sequential API calls (PSC change first, then other settings)
- Or handle this as a single atomic operation
Actual Behavior
Plan shows:
- psc_config {
- allowed_consumer_projects = [] -> null
- psc_enabled = false -> null
}
+ psc_config {
+ allowed_consumer_projects = []
+ psc_enabled = true
}
Error: Error, failed to update instance settings for : googleapi: Error 400: Invalid request: Enabling or disabling Private Service Connect and changing other fields at the same time is not allowed., invalid
with module.this.google_sql_database_instance.this[0],
on ../../modules/signal/sql.tf line 2, in resource "google_sql_database_instance" "this":
2: resource "google_sql_database_instance" "this" {
Steps to reproduce
- Create a Cloud SQL instance with psc_enabled = false (or omit PSC config entirely)
- Change psc_enabled
- Run terraform apply
Important Factoids
The Google Cloud SQL API has a restriction that prevents enabling/disabling PSC alongside other field changes in the same request. Terraform treats the change as:
Remove the old psc_config block (with psc_enabled = false)
Add a new psc_config block (with psc_enabled = true)
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugforward/reviewIn review; remove label to forwardIn review; remove label to forwardservice/sqladmin-cpwaiting-response