oracle / terraform-provider-oci

Terraform Oracle Cloud Infrastructure provider
https://www.terraform.io/docs/providers/oci/
Mozilla Public License 2.0
760 stars 683 forks source link

Adding backup_destination_details to existing database triggers replacement #1962

Open jeliker opened 1 year ago

jeliker commented 1 year ago

Community Note

Terraform Version and Provider Version

Terraform v1.5.3
on darwin_amd64
+ provider registry.terraform.io/oracle/oci v5.13.0

Affected Resource(s)

affected_resources = oci_database_database

Terraform Configuration Files

This first . . .

resource "oci_database_database" "the_database" {
    #Required
    database {
        #Required
        admin_password = var.admin_password
        db_name = var.db_name
    }
    db_home_id = var.db_home_id
    source = "NONE"

    #Optional
    db_version = "19.20.0.0.0"
}

. . . then this change (adding backup details) . . .

resource "oci_database_database" "the_database" {
    #Required
    database {
        #Required
        admin_password = var.admin_password
        db_name = var.db_name

        #Optional
        db_backup_config {

            #Optional
            auto_backup_enabled = true
            backup_destination_details {

                #Optional
                type = "OBJECT_STORE"
            }
            recovery_window_in_days = 30
            run_immediate_full_backup = true
        }
    }
    db_home_id = var.db_home_id
    source = "NONE"

    #Optional
    db_version = "19.20.0.0.0"
}

Debug Output

Terraform will perform the following actions:

  # oci_database_database.the_database must be replaced
-/+ resource "oci_database_database" "the_database" {

 . . . 

     ~ database {

. . .

          ~ db_backup_config {
              ~ auto_backup_enabled       = false -> true
              + auto_backup_window        = (known after apply)
              + auto_full_backup_window   = (known after apply)
              + backup_deletion_policy    = (known after apply)
                # (3 unchanged attributes hidden)

              + backup_destination_details { # forces replacement
                  + dbrs_policy_id = (known after apply)
                  + id             = (known after apply)
                  + type           = "OBJECT_STORE" # forces replacement
                }
            }

        # (1 unchanged block hidden)
        }

Panic Output

Expected Behavior

Adding backup_destination_details to existing database should not trigger replacement. API docs show that this is updatable value.

Actual Behavior

Adding backup_destination_details to existing database that does not have backups enabled should update (not replace) the DB. Further note that direct API call does succeed i.e.:

POST https://database.us-phoenix-1.oraclecloud.com/20160918/databases/ocid1.database.oc1.phx.anzffkdqwiwhkduljrx4fujxiabobk73ry2j2bpy6zj4jux5g46aqcm43yta
{
  "dbBackupConfig": {
    "autoBackupEnabled": true,
    "recoveryWindowInDays": 30,
    "runImmediaeFullBackup": true,
    "backupDestinationDetails": [
      {
        "type": "OBJECT_STORE"
      }
    ]
  }
}

. . .

"status": "200 OK"

After above direct API call the update succeeds. If, after I update via direct API call, I apply the second config above then it does not signal a replacement since the backup_destination_details is now set properly.

Steps to Reproduce

  1. terraform apply the first config
  2. Change to second config above then terraform apply
  3. Note error
  4. Update backup_destination_details via API call
  5. terraform apply the second and now it succeeds

Important Factoids