Ignoring database flags in GCP CloudSQL using Terraform
Sometimes you just need to ignore database flags in your Terraform code because it changes outside your control, e.g. some other process dinamically adjusting settings. Or sometimes you just have to cope with a bug or limitation in the provider, just like this one:
So, to ignore database flags when applying your code against a Cloud SQL instance, you can use the lifecycle block with the ignore_changes attribute in your Terraform configuration file.
Here’s an example of how to do this:
With this configuration, Terraform will not update the database_flags when applying the configuration, even if the values change in your code. This can be useful if you want to manage flags outside of Terraform, or if you want to avoid unnecessary updates to your Cloud SQL instance.
Keep in mind that this configuration will completely ignore changes to the database_flags setting, so if you want to update those flags in the future, you will need to remove or modify the ignore_changes attribute.