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 should not support source_details updates #2133

Open
lra opened this issue Jun 5, 2024 · 0 comments
Open

oci_core_instance should not support source_details updates #2133

lra opened this issue Jun 5, 2024 · 0 comments
Labels

Comments

@lra
Copy link

lra commented Jun 5, 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.8.5
on darwin_arm64
+ provider registry.terraform.io/oracle/oci v5.45.0

Affected Resource(s)

core_instance

Terraform Configuration Files

resource "oci_core_instance" "sdm_gateways" {
  count = local.gateway_count

  availability_domain = var.availability_domains[count.index]
  compartment_id      = oci_identity_compartment.this.id
  defined_tags        = local.labels
  display_name        = "${local.gateway_name}-${count.index}"
  shape               = local.shape
  shape_config {
    memory_in_gbs = 4
    ocpus         = 1
  }

  create_vnic_details {
    assign_public_ip       = true
    display_name           = "${local.gateway_name}-vnic-${count.index}"
    subnet_id              = oci_core_subnet.public[count.index].id
    hostname_label         = "${local.gateway_name}-${count.index}"
    skip_source_dest_check = true
    nsg_ids                = [oci_core_network_security_group.this.id]
  }

  source_details {
    source_id               = data.oci_core_image.this.id
    source_type             = "image"
    boot_volume_size_in_gbs = 50
  }

  metadata = {
    user_data = base64encode(templatefile("${path.module}/templates/gateway_install.sh.tpl", {
      SDM_GATEWAY_TOKEN = sdm_node.sdm_gateways[count.index].gateway[0].token
    }))
  }
}

Debug Output

Panic Output

Expected Behavior

When the source_details.source_id of the VM is changed, terraform should replace the whole oci_core_instance resource.

Actual Behavior

Instead, it tries to update the oci_core_instance resource and the API fails with this 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.us-phoenix-1.oraclecloud.com/20160918/instances/ocid1.instance.oc1.phx.anyhqljrp4o7ruacplfc63r45qkhzeni4ydkywifmqhn6cdu2d6ubf2lupna 
│ Provider version: 5.45.0, released on 2024-06-05.  
│ Service: Core Instance 
│ Operation Name: UpdateInstance 
│ OPC request ID: 38ccc413c5e45f32dfd7d06e71ba1eb6/53508B2F886A98DA289B961D079B4237/538001672CEE97C9422F7567958EC45C 
│ 
│ 
│   with module.strongdm_gateway_oci_seismic_us_phoenix.oci_core_instance.sdm_gateways[0],
│   on ../../modules/oci-strongdm-gateway/main.tf line 84, in resource "oci_core_instance" "sdm_gateways":
│   84: resource "oci_core_instance" "sdm_gateways" {
│ 
╵

Steps to Reproduce

  1. terraform apply

Important Factoids

A workaround is to create a fake resource bound to the source_id image data, and to state it in the lifecycle.replace_triggered_by block of the oci_core_instance resource:

resource "oci_core_instance" "sdm_gateways" {
  [...]
  lifecycle {
    replace_triggered_by = [
      # This is to avoid this error when TF tries to modify an existing instance: "Error: 400-InvalidParameter, sourceDetails.kmsKeyId size must be between 1 and 255"
      terraform_data.sdm_gateway_image,
    ]
  }
}

resource "terraform_data" "sdm_gateway_image" {
  input = data.oci_core_image.this.id
}

References

@lra lra added the bug label Jun 5, 2024
@lra lra changed the title oci_core_instance should not support source_details update oci_core_instance should not support source_details updates Jun 5, 2024
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

1 participant