Skip to content

oci_core_instance - capacity_reservation_id: additions, removals and updates are broken #2495

@eigrobert

Description

@eigrobert

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.5.7
on darwin_arm64
+ provider registry.terraform.io/oracle/oci **v7.27.0

Affected Resource(s)

oci_core_instance

Terraform Configuration Files

resource "oci_core_instance" "example" {
  compartment_id       = var.compartment_id
  availability_domain  = "Frzi:US-ASHBURN-AD-1"
  shape                = "VM.Standard.E6.Flex"
  preserve_boot_volume = false
  source_details {
    source_id   = var.image_id
    source_type = "image"
  }
  shape_config {
    memory_in_gbs = 6
    ocpus         = 2
  }
  create_vnic_details {
    subnet_id = oci_core_subnet.example.id
  }
  capacity_reservation_id = oci_core_compute_capacity_reservation.example.id
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

updates to capacity_reservation_id should be reflected appropriately within OCI

updates within OCI to the capacity-reservation-id should be detected and treated the same as any other instance attribute that gets updated (defined_keys, freeform_keys, display_name, etc)

Actual Behavior

Creation of an instance starting with a capacity_reservation_id, the capacity_reservation_id is applied appropriately within OCI.

Creation of an instance without a capacity reservation: state and OCI properly reflect that case

Removal of capacity_reservation_id from an oci_core_instance that had it on creation: Terraform does not register this as a change

Changing capacity_reservation_id on instance that had it on creation: terraform recognizes as change, and attempts modification and indicates success.... but changes are not reflected in state nor OCI

Addition of capacity_reservation_id onto instance that didn't have one initially: terraform recognizes as change, and attempts modification and indicates success.... changes are reflected in state, but OCI indicates no capacity reservation on the instance

terraform does not react to changes to capacity_reservation_id outside of terraform. (instance created with ccd via terraform, instance shape modified which breaks capacity reservation relationship within OCI, terraform refresh/plan/apply, no changes detected)

Steps to Reproduce

removal of CCR after creation scenario 1

  1. create oci_core_instance with CCR via terraform
  2. remove capacity_reservation_id from oci_core_instance
  3. terraform apply shows no changes detected

update CCR after creation

  1. create oci_core_instance with CCR via terraform
  2. update oci_core_instance capacity_reservation_id value to different CCR
  3. terraform apply
  4. see modification completed messages
  5. query state file: terraform state show oci_core_instance.example |grep capacity_reservation_id indicates CCR changed
  6. query OCI via cli: oci compute instance get --instance-id ocid1.instance.... |grep capacity-reservation-id instance CCR attribute not changed

add CCR after creation

  1. create oci_core_instance without CCR via terraform
  2. add capacity_reservation_id on oci_core_instance within terraform
  3. terraform apply
  4. see modification completed messages
  5. query state file: terraform state show oci_core_instance.example |grep capacity_reservation_id indicates CCR changed
  6. query OCI via cli: oci compute instance get --instance-id ocid1.instance.... |grep capacity-reservation-id instance is not acced to CCR properly
  7. get billed for both CCR and instance because they are not properly linked in OCI even though terraform reports that they are

Instance modified outside of terraform

  1. create oci_core_instance with CCR via terraform
  2. change shape of vm which automatically breaks CCR relationship, or modify attribute some other way
  3. terraform refresh, terraform plan nor terraform apply detect anything as changed
  4. get billed for both CCR and instance because they are not properly linked in OCI even thogh terraform reports that they are

Important Factoids

if I am reading this code correctly: internal/service/core/core_instance_resource.go
capacity_reservation_id is referenced in Create()
but not in Update()

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions