-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to reflect the change in cloudsql using the terraform refresh but terraform plan identity the changes in between remote state and the terraform state file #6496
Comments
Hi @ops18! Thanks for reporting this issue. Can you clarify where the issue you're seeing is? I created the instance with terraform When I come back to look at the plan it shows It's possible I'm misunderstanding the steps to reproduce or your expected behavior, if so, please let me know and I can re-run and re-test. |
Yah its working fine with change the tier but I am warried about when I am running the terraform refresh it is not idenity the changes between the remote state and the terraform state file.
(just check the terraform refresh) Coreect me If I am missing any steps or configuration |
Hi @ops18! Thank you for clarifying your steps. I've done the same steps and saw that |
yes, it works now, its due to custom-tier for database, now when i changed the configuration it works. |
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! |
Community Note
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 tohashibot
, a community member has claimed the issue already.Terraform Version
Terraform v0.12.25
Affected Resource(s)
resource "google_sql_database_instance" "master"
Terraform Configuration Files
main.tf
resource "google_sql_database_instance" "default" {
provider = google
project = var.project_id
name = var.name
database_version = var.database_version
region = var.region
settings {
tier = var.tier
activation_policy = var.activation_policy
availability_type = var.availability_type
authorized_gae_applications = var.authorized_gae_applications
dynamic "backup_configuration" {
for_each = [var.backup_configuration]
content {
binary_log_enabled = false
enabled = lookup(backup_configuration.value, "enabled", null)
start_time = lookup(backup_configuration.value, "start_time", null)
}
}
dynamic "ip_configuration" {
for_each = [local.ip_configurations[local.ip_configuration_enabled ? "enabled" : "disabled"]]
content {
ipv4_enabled = lookup(ip_configuration.value, "ipv4_enabled", null)
private_network = lookup(ip_configuration.value, "private_network", null)
require_ssl = lookup(ip_configuration.value, "require_ssl", null)
var.tf
variable "project_id" {
type = string
description = "The project ID to manage the Cloud SQL resources"
default = "test-proj"
}
variable "name" {
type = string
description = "The name of the Cloud SQL resources"
default = "shpsqll2"
}
// required
variable "database_version" {
description = "The database version to use"
type = string
default = "POSTGRES_9_6"
}
// required
variable "region" {
type = string
description = "The region of the Cloud SQL resources"
default = "europe-west4"
}
variable "tier" {
description = "The tier for the master instance."
type = string
default = "db-f1-micro"
version.tf
terraform {
required_version = "
> 0.12.6"> 2.18.0"required_providers {
google = "
}
}
Debug Output
Panic Output
Expected Behavior
As the terraform is configure with the tier: db-f1-micro
Change the configureation from cloud console to db-custom-2-7680 and when run the terraform plan
a terraform plan should pick up the out of band change:
~ settings {
activation_policy = "ALWAYS"
authorized_gae_applications = []
availability_type = "REGIONAL"
crash_safe_replication = false
disk_autoresize = true
disk_size = 10
disk_type = "PD_SSD"
pricing_plan = "PER_USE"
replication_type = "SYNCHRONOUS"
~ tier = "db-custom-2-7680" -> "db-f1-micro"
Actual Behavior
But The terraform refresh does not pick up the out of band change:
test# terraform refresh
random_id.instance_name_suffix: Refreshing state... [id=9paedzw]
module.postgresql-db.null_resource.module_depends_on: Refreshing state... [id=3423931886575952786]
module.postgresql-db.google_sql_database_instance.default: Refreshing state... [id=tf-ha-sh-f6969e773c]
module.postgresql-db.random_id.user-password: Refreshing state... [id=BVaFKJvthfA]
module.postgresql-db.google_sql_database.default: Refreshing state... [id=tf-ha-sh-f6969e773c:tf-ha-sh]
module.postgresql-db.google_sql_user.default: Refreshing state... [id=tftest//tf-ha-sh-f6969e773c]
Outputs:
private_ip_address = 172.22.32.29
psql_conn = xxxxxx:europe-west4:tf-ha-sh-f6969e773c
It should not refresh the state with remote state and terraform statefile.
terraform plan pick up the changes but when run the terraform refresh to Update local state file against real resources it shoes nothings has been
test# terraform refresh
module.postgresql-db.null_resource.module_depends_on: Refreshing state... [id=3423931886575952786]
random_id.instance_name_suffix: Refreshing state... [id=9paedzw]
module.postgresql-db.google_sql_database_instance.default: Refreshing state... [id=tf-ha-sh-f6969e773c]
module.postgresql-db.google_sql_database.default: Refreshing state... [id=tf-ha-sh-f6969e773c:tf-ha-sh]
module.postgresql-db.random_id.user-password: Refreshing state... [id=BVaFKJvthfA]
module.postgresql-db.google_sql_user.default: Refreshing state... [id=tftest//tf-ha-sh-f6969e773c]
Outputs:
private_ip_address = 172.22.32.xx
psql_conn = xxxxxxxx:europe-west4:tf-ha-sh-f6969e773c
Steps to Reproduce
Create a New CloudSQL DB Instnace with the HCL conf provided above.
upgrade the instance's tier to any custom configuration like "db-custom-2-7680" through the Google Cloud console or gcloud CLI.
run terraform plan on the same HCL configuration.
terraform apply
Enter a value: yes
module.postgresql-db.google_sql_database_instance.default: Modifying... [id=tf-ha-sh-f6969e773c]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 10s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 20s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 30s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 40s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 50s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 1m0s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 1m10s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 1m20s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 1m30s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 1m40s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 1m50s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 2m0s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 2m10s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 2m20s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 2m30s elapsed]
module.postgresql-db.google_sql_database_instance.default: Still modifying... [id=tf-ha-sh-f6969e773c, 2m40s elapsed]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
Outputs:
private_ip_address = 172.22.32.29
psql_conn = xxxxxx:europe-west4:tf-ha-sh-f6969e773c
Important Factoids
References
The text was updated successfully, but these errors were encountered: