oracle / terraform-provider-oci

Terraform Oracle Cloud Infrastructure provider
https://www.terraform.io/docs/providers/oci/
Mozilla Public License 2.0
758 stars 676 forks source link

Error: 400-CannotParseRequest, Incorrectly formatted request while creating OCI instance #1714

Open suvsap opened 1 year ago

suvsap commented 1 year ago

Error: 400-CannotParseRequest, Incorrectly formatted request. Please refer to our documentation for help. │ Suggestion: Please retry or contact support for help with service: Core Instance │ 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/LaunchInstance │ Request Target: POST https://iaas.eu-frankfurt-1.oraclecloud.com/20160918/instances │ Provider version: 4.100.0, released on 2022-11-17.
│ Service: Core Instance │ Operation Name: LaunchInstance │ OPC request ID: 5ca8c83c6e5fc8d110d67efe04546868/B8DE09E6A04CC1E36C4ED12B8233FD85/D8B573C783A879F92A53BB93ECD12F60 │ │ │ with module.idm-server.oci_core_instance.idm-server, │ on terraform-modules-tvh/oci-instance/main.tf line 1, in resource "oci_core_instance" "idm-server": │ 1: resource "oci_core_instance" "idm-server" { │ ╵

I am getting the above error while creating OCi instance. Even though terraform plan and terraform validate is successfull

Terraform plan:- https://gist.github.com/suvsap/4cd6733382d66a5240d6a4d4e1d243e9

Terraform module:- https://gist.github.com/suvsap/970f279ec5afd2e542345538970e4b99

providers:-

terraform {
  required_providers {
    oci = {
      source  = "oracle/oci"
      version = ">=4.90.0"
    }
  }
}

terraform version:-

terraform {
  required_version = ">= 0.13.0"
}
mchum commented 1 year ago

I am experiencing the same in version 4.101.0 while attempting to create the resource below. I think it can be assumed that the API had changed, but the terraform module has not updated to match those changes.

resource "oci_core_instance" "instance" {
    # Required
    availability_domain = var.availability_domain
    compartment_id = var.compartment_ocid
    shape = "VM.Standard.A1.Flex"
    source_details {
        source_id = var.image_source_ocid
        source_type = "image"
        boot_volume_size_in_gbs = 50
    }

    # Optional
    display_name = "instance"
    shape_config {
        ocpus = 1
        memory_in_gbs = 4
    }
    create_vnic_details {
        assign_public_ip = true
        subnet_id = oci_core_subnet.public.id
    }
    preserve_boot_volume = false
    metadata = {
        ssh_authorized_keys = file(var.ssh_public_keypath)
    }
}

edit: Tested again with minimal configuration with the same error

resource "oci_core_instance" "instance" {
    # Required
    availability_domain = var.availability_domain
    compartment_id = var.compartment_ocid
    shape = "VM.Standard.A1.Flex"
    source_details {
        source_id = var.image_source_ocid
        source_type = "image"
        boot_volume_size_in_gbs = 50
    }
}
mchum commented 1 year ago

I've resolved my issue. The issue was with the availability_domain, I had previous set the value to NAhl:CA-TORONTO-1-AD-1 and it has now changed to yzZM:CA-TORONTO-1-AD-1.

ravinitp commented 1 year ago

Thank you for reporting the issue. We observed the affected resources are not provided in the description or it's incorrect. We request you to add it in issue description as mentioned in below format. Example: affected_resources = oci_core_instance , oci_core_instances

If it's not related to any particular resource then mention affected resource as terraform. Example: affected_resources = terraform

As this works through automation, request you to follow exact syntax.