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

oci_core_instance incorrectly identify destroy action as in-place-change #2136

Open
luckeyca opened this issue Jun 7, 2024 · 2 comments
Open
Labels

Comments

@luckeyca
Copy link

luckeyca commented Jun 7, 2024

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 v1.5.4
on linux_amd64

  • provider registry.terraform.io/oracle/oci v5.45.0

Affected Resource(s)

oci_core_instance

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. 
# Please remove any sensitive information from configuration files before sharing them. 

resource "oci_core_instance" "vm" {
  for_each            = var.vm-info
  availability_domain = var.availability_domain_name
  compartment_id      = var.compute_compartment_ocid
  display_name        = each.value.vm_display_name
  shape               = each.value.vm_compute_shape
  fault_domain        = data.oci_identity_fault_domains.fds.fault_domains[each.value.fault_domain - 1].name
  freeform_tags       = each.value.freeform_tags

  dynamic "shape_config" {
    for_each = reverse(split(".", each.value.vm_compute_shape))[0] == "Flex" ? [each.value.vm_flex_shape_params] : []

    content {
      ocpus         = shape_config.value.ocpu
      memory_in_gbs = shape_config.value.memory
    }
  }

  create_vnic_details {
    subnet_id        = each.value.subnet_id
    display_name     = format("%s-%s", each.value.vm_display_name, "nic1")
    assign_public_ip = each.value.assign_public_ip
    hostname_label   = lower(each.value.hostname_label)
    private_ip       = each.value.private_ip
    freeform_tags    = each.value.freeform_tags
    nsg_ids          = each.value.nsg_ids
  }

  source_details {
    source_type             = "image"
    source_id               = local.image_info[each.key].listing-resource-id
    boot_volume_size_in_gbs = each.value.boot_volume_size
  }

  metadata = {
    ssh_authorized_keys = each.value.ssh_public_key
    user_data           = try(base64encode(templatefile("${path.root}${each.value.user_data_file}", each.value.user_data_vars)), null)
  }

  timeouts {
    create = "60m"
  }

  lifecycle {
    ignore_changes = [
      metadata
    ]
  }

}

Debug Output

Panic Output

Expected Behavior

When changing the "source_id" under "source_details" from a windows OS OCID to a linux OS OCID, instance should be destroyed and recreated.

Actual Behavior

When changing the "source_id" under "source_details" from a windows OS OCID to a linux OS OCID, terraform plan shows the action was "in-place" update. Then terraform apply failed.

Steps to Reproduce

  1. create a windows vm using the oci_core_instance
  2. update the source_id under "source_details" from a Windows OS OCID to a linux OS OCID
  3. terraform plan. this will should in-place update
  4. terraform apply will fail with the following error.
    Error:
    │ Error: 400-InvalidParameter, sourceDetails.kmsKeyId size must be between 1 and 255
    │ Suggestion: Please update the parameter(s) in the Terraform config as per error message sourceDetails.kmsKeyId size must be between 1 and 255
    │ Documentation: https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_instance
    │ API Reference: https://docs.oracle.com/iaas/api/#/en/iaas/20160918/Instance/UpdateInstance
    │ Request Target: PUT https://iaas.ca-toronto-1.oraclecloud.com/20160918/instances/ocid1.instance.oc1.ca-toronto-1.an2g6ljr5xeuumqcftjnlo53qhjmj5itl32cjkh6dp2qakiz3g3gbi37y4ca
    │ Provider version: 5.45.0, released on 2024-06-05.
    │ Service: Core Instance
    │ Operation Name: UpdateInstance
    │ OPC request ID: 48eb77dc5e532530893008576ae02dd3/FA9861117E6117B45EFD917A903E3B9F/F3040076B4090E60147B679A97AAE6A6
    │ with module.vms_toronto.oci_core_instance.vm["GcDs-PSPC-Spoke1-hr2paypoc-p1-db-vm1"],
    │ on .terraform/modules/vms_toronto/main.tf line 103, in resource "oci_core_instance" "vm":
    │ 103: resource "oci_core_instance" "vm" {

Important Factoids

References

@luckeyca luckeyca added the bug label Jun 7, 2024
@12345ieee
Copy link

This also happens when changing the source_type from image to bootVolume or viceversa.

This is impeding several of our workflows, as now we have to manually taint the resource.

@cweeks72
Copy link

The problem seems to be related to this commit: f0edc48 - it seems that they wanted to support in-place replacement of the boot volume, but seem to have also broken without any bypass, image replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants