Cloud-Temple / terraform-provider-cloudtemple

Cloud Temple CSP Terraform Provider
https://cloud-temple.com
Mozilla Public License 2.0
8 stars 1 forks source link

Issue with the backup policies update #99

Closed JoshDelPaso closed 8 months ago

JoshDelPaso commented 8 months ago

Hello,

I had an issue with the following code :

resource "cloudtemple_compute_virtual_machine" "VM-TEST3" {
  name = "VM-TEST3"

  memory                 = 2 * 1024 * 1024 * 1024
  cpu                    = 2
  num_cores_per_socket   = 1
  cpu_hot_add_enabled    = false
  cpu_hot_remove_enabled = false
  memory_hot_add_enabled = false

  datacenter_id   = data.cloudtemple_compute_virtual_datacenter.DC-PAR7S.id
  host_cluster_id = data.cloudtemple_compute_host_cluster.clu001-prod1.id
  host_id         = data.cloudtemple_compute_host.esx001.id
  datastore_id    = data.cloudtemple_compute_datastore.live_prod_flash3K-011.id

  content_library_id      = data.cloudtemple_compute_content_library.pa7s.id
  content_library_item_id = data.cloudtemple_compute_content_library_item.ubuntujammy.id

  boot_options {
    efi_secure_boot_enabled = false
    firmware                = "bios"
  }
  os_disk {
    capacity = 16 * 1024 * 1024 * 1024
  }
  os_network_adapter {
    network_id = data.cloudtemple_compute_network.vlan-DATABASE-PA7S.id
  }

  power_state = "off"

  tags = local.common_tags

  backup_sla_policies = [
    data.cloudtemple_backup_sla_policy.no-backup.id
  ]

  lifecycle {
    ignore_changes  = all
    prevent_destroy = true
  }
}

resource "cloudtemple_compute_virtual_controller" "VM-TEST3-SCSI1" {
  virtual_machine_id = cloudtemple_compute_virtual_machine.VM-TEST3.id
  type               = "SCSI"
  sub_type           = "ParaVirtual"
}

resource "cloudtemple_compute_virtual_disk" "VM-TEST3-dd2-flash3K" {
  virtual_machine_id = cloudtemple_compute_virtual_machine.VM-TEST3.id
  provisioning_type  = "staticImmediate"
  disk_mode          = "persistent"
  capacity           = 5 * 1024 * 1024 * 1024
  datastore_id       = data.cloudtemple_compute_datastore.live_prod_flash3K-011.id
  controller_id      = cloudtemple_compute_virtual_controller.VM-TEST3-SCSI1.id

  backup_sla_policies = [
    data.cloudtemple_backup_sla_policy.no-backup.id
  ]
  depends_on = [cloudtemple_compute_virtual_controller.VM-TEST3-SCSI1]
}

resource "cloudtemple_compute_network_adapter" "VM-TEST3-adapter" {
  virtual_machine_id = cloudtemple_compute_virtual_machine.VM-TEST3.id
  network_id         = data.cloudtemple_compute_network.vlan-ADMIN-PA7S.id
  type               = "VMXNET3"
  mac_type           = "GENERATED"
  auto_connect       = true
  lifecycle {
    ignore_changes = [ mac_type ]
  }
}

I deployed it with success, but after I wanted to change my backup to a daily one.

Therefore, I changed :

  backup_sla_policies = [
    data.cloudtemple_backup_sla_policy.no-backup.id
  ]

to

  backup_sla_policies = [
    data.cloudtemple_backup_sla_policy.daily-th3s.id
  ]

On the vm and the disk ressources.

My apply showed :

Screenshot 2023-11-09 164615

But on the GUI :

Screenshot 2023-11-09 164749

I looked into the state file, this one showed : For the datadisk :

Screenshot 2023-11-09 163934

For the vm :

Screenshot 2023-11-09 164036

The new policy is not applied on the vm, but only on the disk.

I tried to delete the controller and the disk --> didn't change anything, the policy stayed the same on the vm. I tried to comment the SLA policy block code in the vm ressource and apply --> didn't change anything (no changes).

It's like this block is ignored in the virtual machine.

Thanks,

Cheers,

JoshDelPaso commented 8 months ago

I close this issue. The reason comes from the lifecycle parameter. The ignore_changes is set to "all".