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

Cannot update shape and capacity reservation at the same time #2313

Open
b-dean opened this issue Mar 4, 2025 · 0 comments · May be fixed by #2314
Open

Cannot update shape and capacity reservation at the same time #2313

b-dean opened this issue Mar 4, 2025 · 0 comments · May be fixed by #2314
Labels

Comments

@b-dean
Copy link

b-dean commented Mar 4, 2025

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.11.0
OCI Provider v6.28.0

Affected Resource(s)

  • oci_core_instance
  • oci_core_compute_capacity_reservation (related, but the bug is in the the instance resource)

Terraform Configuration Files

variable "compartment_id" {}
variable "availability_domain" {}
variable "fault_domain" {}

variable "shape_index" {
  type    = number
  default = 0
}

variable "shapes" {
  type = list(string)

  default = [
    "VM.Standard.E4.Flex",
    "VM.Standard.E5.Flex",
  ]
}

resource "oci_core_compute_capacity_reservation" "example" {
  count = length(var.shapes)

  compartment_id      = var.compartment_id
  availability_domain = var.availability_domain
  display_name        = "example-${count.index}"

  instance_reservation_configs {
    instance_shape = var.shapes[count.index]
    reserved_count = 1
    fault_domain   = var.fault_domain

    instance_shape_config {
      memory_in_gbs = 4
      ocpus         = 1
    }
  }
}

resource "oci_core_instance" "example" {
  compartment_id          = var.compartment_id
  availability_domain     = var.availability_domain
  fault_domain            = var.fault_domain
  capacity_reservation_id = oci_core_compute_capacity_reservation.example[var.shape_index].id
  display_name            = "example"
  shape                   = var.shapes[var.shape_index]

  shape_config {
    memory_in_gbs = 4
    ocpus         = 1
  }

  # ...
}

Full working example:
https://gist.github.com/b-dean/0cccde387e8dcc57167b08e5e45ef80c

Debug Output

Will include in an Oracle SR if needed.

Expected Behavior

The compute instance should modify its shape and capacity reservation in a single request. This is how it works when you change them in the OCI website. You can change both simultaneously.

Actual Behavior

│ Error: 400-InvalidParameter, Invalid Shape Config: No valid reservation configs in the reservation to move the resize to.
│ Suggestion: Please update the parameter(s) in the Terraform config as per error message Invalid Shape Config: No valid reservation configs in the reservation to move the resize to.
│ 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.us-ashburn-1.oraclecloud.com/20160918/instances/ocid1.instance.oc1.iad.xxxxxxxxxxxxxxxx
│ Provider version: 6.28.0, released on 2025-03-02.
│ Service: Core Instance
│ Operation Name: UpdateInstance
│ OPC request ID: xxxxxxxxxxxxxxxx
│
│
│   with oci_core_instance.example,
│   on main.tf line 46, in resource "oci_core_instance" "example":
│   46: resource "oci_core_instance" "example" {
│

Steps to Reproduce

Using the code in the gist, https://gist.github.com/b-dean/0cccde387e8dcc57167b08e5e45ef80c

run the following:

# this one works
terraform apply -var shape_index=0

# this one will fail
terraform apply -var shape_index=1

It will ask you for compartment_id and subnet_id variables, which you can put in a .tfvars file if you like.

References

I previously created #2209 for this, but it was closed for some reason. I'm logging this as a bug, for which I will create a new PR.

I also logged a SR 4-0000144019 which was closed without a solution.

@b-dean b-dean added the bug label Mar 4, 2025
b-dean added a commit to b-dean/terraform-provider-oci that referenced this issue Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant