Skip to content
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

import oci_database_database forces replacement when database_management_config is in place #2254

Open
jaspers123 opened this issue Dec 17, 2024 · 2 comments
Labels
bug In-Progress Terraform Team is working on the reproduce & fix

Comments

@jaspers123
Copy link

Importing OCI (DRCC) Database forces replacement of the Database when database_management_config block is in place in imported resource. Even when database management is disabled.
Ignoring more or less options does not help.

Import of Database is needed to update "Defined_Tags" after Database has been created using different terraform code.

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

Terraform Version and Provider Version

terraform -v
Terraform v1.10.2
on darwin_arm64

  • provider registry.terraform.io/hashicorp/oci v6.20.0

Affected Resource(s)

oci_database_database
oci_database_db_home

Terraform Configuration Files

  # oci_database_database.database_cloud_vm_clusters[7] must be replaced
  # (imported from "ocid1.database.xxxxxxx")
  # Warning: this will destroy the imported resource
-/+ resource "oci_database_database" "database_cloud_vm_clusters" {
      ~ character_set                                    = "EE8ISO8859P2" -> (known after apply)
      ~ compartment_id                                   = "ocid1.compartment.xxxxxxxx" -> (known after apply)
      ~ connection_strings                               = [
          - {
              - all_connection_strings = {
                  - "cdbDefault"   = "xxxxxxx"
                }
              - cdb_default            = "xxxxxxx"
            },
        ] -> (known after apply)
      ~ database_management_config                       = [
          - {
              - management_status = "DISABLED"
              - management_type   = "ADVANCED"
            },
        ] -> (known after apply)
      + database_software_image_id                       = (known after apply)
      ~ db_backup_config                                 = [
          - {
              - auto_backup_enabled        = false
                auto_backup_window         = null
                auto_full_backup_day       = null
                auto_full_backup_window    = null
                backup_deletion_policy     = null
              - backup_destination_details = []
              - recovery_window_in_days    = 30
              - run_immediate_full_backup  = false
            },
        ] -> (known after apply)
        db_home_id                                       = "ocid1.dbhome.xxxxxxx"
      ~ db_name                                          = "xxxxxx" -> (known after apply)
      + db_system_id                                     = (known after apply)
      ~ db_unique_name                                   = "xxxxxxxxx" -> (known after apply)
      + db_version                                       = (known after apply)
      ~ db_workload                                      = "OLTP" -> (known after apply)
      ~ defined_tags                                     = {
          - "Oracle-Tags.CreatedBy"    = "x"
          - "Oracle-Tags.CreatedOn"    = "x"
          - "drcc-Tags.BS_Company"     = "xxxxxx"
          - "drcc-Tags.BS_ServiceName" = "xxxxxxx"
          - "drcc-Tags.DRCCOffering"   = "xxxxxx"
          - "drcc-Tags.IDMGroup"       = "xx"
          - "drcc-Tags.LocalMarket"    = "xxxx"
          - "drcc-Tags.SupportGroup"   = "xxxxxxx"
          - "drcc-Tags.region"         = "xxxxxx"
          - "drcc-Tags.resource"       = "database"
        } -> (known after apply)
      ~ freeform_tags                                    = {} -> (known after apply)
      ~ id                                               = "ocid1.database.xxxxxxxxx" -> (known after apply)
      ~ is_cdb                                           = false -> (known after apply)
      + key_store_id                                     = (known after apply)
      + key_store_wallet_name                            = (known after apply)
      + kms_key_id                                       = (known after apply)
      + last_backup_duration_in_seconds                  = (known after apply)
      ~ last_backup_timestamp                            = "+0000 UTC" -> (known after apply)
      + last_failed_backup_timestamp                     = (known after apply)
      + lifecycle_details                                = (known after apply)
      ~ ncharacter_set                                   = "AL16UTF16" -> (known after apply)
      + pdb_name                                         = (known after apply)
      ~ sid_prefix                                       = "XXXXXX" -> (known after apply)
      + source                                           = "NONE"
      + source_database_point_in_time_recovery_timestamp = (known after apply)
      ~ state                                            = "AVAILABLE" -> (known after apply)
      ~ time_created                                     = "+0000 UTC" -> (known after apply)
      + vault_id                                         = (known after apply)
      ~ vm_cluster_id                                    = "ocid1.cloudvmcluster.xxxxxxxxx" -> (known after apply)

      + database {
          # Warning: this attribute value will be marked as sensitive and will not
          # display in UI output after applying this change. The value is unchanged.
            admin_password             = (sensitive value)
          + character_set              = (known after apply)
          + database_software_image_id = (known after apply)
          + db_name                    = "XXXXXXXX" # forces replacement
          + db_unique_name             = (known after apply)
          + db_workload                = (known after apply)
          + defined_tags               = {
              + "drcc-Tags.BS_ServiceName" = "XXXXXXXXX"
            }
          + freeform_tags              = (known after apply)
          + kms_key_id                 = (known after apply)
          + kms_key_version_id         = (known after apply)
          + ncharacter_set             = (known after apply)
          + pdb_name                   = (known after apply)
          + pluggable_databases        = (known after apply) # forces replacement
          + sid_prefix                 = (known after apply)
          + tde_wallet_password        = (sensitive value)
          + vault_id                   = (known after apply)

          + db_backup_config (known after apply)
        }
    }

import {
  for_each = local.all_databases_cloud_vm_clusters.*.id
  # ID of the cloud resource
  # Check provider documentation for importable resources and format
  id = each.value
 
  # Resource address
  to = oci_database_database.database_cloud_vm_clusters[each.key]
}

resource "oci_database_database" "database_cloud_vm_clusters" {
    count = length(local.all_databases_cloud_vm_clusters)
    #Required
    db_home_id = local.all_databases_cloud_vm_clusters[count.index].db_home_id
    source = "NONE"
    database {
        #Required
        admin_password = ""
        db_name = local.all_databases_cloud_vm_clusters[count.index].db_name
        #Optional
         
            #Optional
         defined_tags = {
          "drcc-Tags.BS_ServiceName"     = "xxxxxx"
          }
     }

    #Optional

    lifecycle {
      ignore_changes = [source, 
        database[0].defined_tags["Oracle-Tags.CreatedBy"], 
        database[0].defined_tags["Oracle-Tags.CreatedOn"],
      ]
    }
}

Debug Output

Panic Output

Expected Behavior

Actual Behavior

Steps to Reproduce

  1. configure data resources to collect the data for databases to be imported
  2. configure import and resource block to import the databases
  3. run 'terraform init' and 'terraform plan' to get a plan that forces the replacement of the database to be imported when the plan would be applied.

Important Factoids

Database with problems happen to be ExaCS Databases that have to be imported with oci_database_db_home or oci_database_database.
DBCS databases that are imported as oci_database_db_system do not seem to have this problem, but not 100% sure if database_management_config block is in place for DBCS.

References

@jaspers123 jaspers123 added the bug label Dec 17, 2024
@tf-oci-pub tf-oci-pub added the In-Progress Terraform Team is working on the reproduce & fix label Dec 17, 2024
@tf-oci-pub
Copy link
Member

Thank you for reporting the issue. We have raised an internal ticket to track this. Our service engineers will get back to you.

@jaspers123
Copy link
Author

jaspers123 commented Dec 18, 2024

I can confirm that the issue is only when importing oci_database_database or oci_database_db_home.
oci_database_db_system can be imported with database_management_config block in place without the "forces replacement"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug In-Progress Terraform Team is working on the reproduce & fix
Projects
None yet
Development

No branches or pull requests

2 participants