CodexBloom - Programming Q&A Platform

OCI Resource Manager Not Applying Changes for Terraform Configuration on OCI 3.0

👀 Views: 31 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-08
terraform oracle-cloud infrastructure-as-code HCL

I've hit a wall trying to I've looked through the documentation and I'm still confused about I'm working with an scenario with Oracle Cloud Infrastructure's Resource Manager when trying to apply changes to my Terraform configuration..... I'm using OCI version 3.0 and Terraform 1.0.0. My configuration involves creating a new compartment and a few compute instances, but when I run `terraform apply`, it returns the behavior: `behavior: behavior creating compartment: BadRequest: invalid request: compartment name is already taken`. I've double-checked that the compartment name is unique across my tenancy and the code is structured correctly. Here's a snippet of my Terraform configuration: ```hcl provider "oci" { region = "us-ashburn-1" } resource "oci_identity_compartment" "my_compartment" { name = "my-unique-compartment-name" description = "A compartment for testing purposes" compartment_id = var.tenancy_ocid } resource "oci_core_instance" "my_instance" { availability_domain = data.oci_identity_availability_domains.ad.names[0] compartment_id = oci_identity_compartment.my_compartment.id display_name = "MyInstance" shape = "VM.Standard2.1" source_details { source_type = "image" image_id = data.oci_core_images.my_image.id } } ``` Despite the compartment name being unique, the `terraform apply` command fails with the same behavior every time. I've tried to refresh the state with `terraform refresh`, and I also attempted to destroy the existing resources to start fresh, but it still fails at the same point when creating the compartment. Is there something I'm potentially overlooking, or is there a known scenario with OCI Resource Manager at this version? Any help would be greatly appreciated! This is for a application running on Linux. I've been using Hcl for about a year now.