opentelekomcloud / terraform-provider-opentelekomcloud

Terraform OpenTelekomCloud provider
https://registry.terraform.io/providers/opentelekomcloud/opentelekomcloud/latest
Mozilla Public License 2.0
88 stars 77 forks source link

opentelekomcloud_dds_instance_v3 chaging backupstrategy forces recreation #2615

Closed bbung closed 3 months ago

bbung commented 3 months ago

Terraform provider version

Terraform v1.9.1 on darwin_arm64

Affected Resource(s)

opentelekomcloud_dds_instance_v3

Terraform Configuration Files

resource "opentelekomcloud_kms_key_v1" "mdb" {
  key_alias       = "mdb"
  pending_days    = "7"
  key_description = "database encryptionkey"
  realm           = "eu-de"
  is_enabled      = true

  lifecycle {
    prevent_destroy = true
  }
}

resource "opentelekomcloud_dds_instance_v3" "mdb" {
  name   = "mdb"
  region = "eu-de"
  datastore {
    type           = "DDS-Community"
    version        = "4.0"
    storage_engine = "wiredTiger"
  }

  availability_zone = "eu-de-01,eu-de-02,eu-de-03"
  vpc_id            = data.opentelekomcloud_vpc_v1.workload-vpc.id
  subnet_id         = one(data.opentelekomcloud_vpc_subnet_ids_v1.subnet_ids.ids)
  security_group_id = data.opentelekomcloud_networking_secgroup_v2.nodes-to-documentdb.id
  password          = "CHANGEME_PLS"
  mode              = "ReplicaSet"
  flavor {
    type      = "replica"
    num       = 1
    storage   = "ULTRAHIGH"
    size      = 10                               // divisible by 10
    spec_code = "dds.mongodb.s2.medium.4.repset" # 1vCPU 4Gi RAM
    # terraform state show data.opentelekomcloud_dds_flavors_v3.replica_flavors

  }
  disk_encryption_id = opentelekomcloud_kms_key_v1.mdb.id

### ADDED AFTER FIRST APPLY vvvvv
  backup_strategy {
    start_time = "02:00-03:00"
    keep_days  = "30"
  }
### ADDED AFTER FIRST APPLY ^^^^

  ssl = true

  lifecycle {
    // API for passwordchange is not available
    ignore_changes = [
      password
    ]
    prevent_destroy = true
  }

  depends_on = [
    opentelekomcloud_kms_key_v1.mdb
  ]
}

Debug Output/Panic Output

Steps to Reproduce

  1. terraform apply without backup strategy config
  2. `terraform apply' with backup strategy

or

  1. Remove or change backup strategy through OTC Console
  2. `terraform apply' with backup strategy

Expected Behavior

The backup strategy should change according to the configuration.

Actual Behavior

  ~ backup_strategy {
          ~ keep_days  = 7 -> 8 # forces replacement
          ~ start_time = "22:00-23:00" -> "02:00-03:00" # forces replacement
        }

So changing the backup strategy will destroy the database. 🙅

Important Factoids

References

anton-sidelnikov commented 3 months ago

Depends-On: https://github.com/opentelekomcloud/gophertelekomcloud/pull/709

anton-sidelnikov commented 3 months ago

Hi @bbung please check the latest v1.36.17

bbung commented 3 months ago

Working as expected. Thanks for the quick fix!