Fix sql_database_instance to include backup_configuration in create request #13092
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes b/257534640 (TF plan allows google_sql_database_instance.replica to define a backup configuration)
SQL database instances do not allow replicas to enable backups. For example, the following config will fail:
Problem
Previously, config like this would correctly result in an error, but the replica would still be created with the
backup_configuration
omitted. This caused issues with consecutiveterraform apply
calls where the first succeeded, but the second failed with no changes to the config.Root cause
We were using some custom behavior for
backup_configuration.binary_log_enabled
that removed it from the initial create request, and then added it back to the instance with a subsequent patch request. This behavior had a bug that caused the entirebackup_configuration
to be removed and not get patched ifbinary_log_enabled
wasfalse
for a replica.Resolution
This PR proposes fixing the issue by leaving the
backup_configuration
on the create request, so that the server can validate the full configuration before creating any entities. The one exception isbinary_log_enabled
, which cannot be set totrue
until after a replica is created. In that case, we make the initial create request withbinary_log_enabled = false
, and then use the subsequent patch call to set it totrue
like before.If this PR is for Terraform, I acknowledge that I have:
make test
andmake lint
to ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)
Derived from GoogleCloudPlatform/magic-modules#6836