Skip to content

Unable to Import Existing OCI User Group Membership Resource Despite Correct OCID and Region #2466

@pradeep4ref

Description

@pradeep4ref

Impacted Resources

affected_resources = oci_identity_user_group_membership

Summary

Reference: https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/identity_user_group_membership

Unable to import existing oci_identity_user_group_membership resources using the import block, even when providing accurate and verified membership OCIDs.

Resource Type: oci_identity_user_group_membership

Terraform Configuration

Resource Definition:

resource "oci_identity_user_group_membership" "example" {
  user_id  = "ocid1.user.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  group_id = "ocid1.group.oc1..bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
}

Import Block:

import {
  to = oci_identity_user_group_membership.example
  id = "ocid1.groupmembership.oc1..cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
}

Expected Behavior
The import should succeed when providing a valid membership OCID as the import ID. The resource should be imported into the Terraform state with the corresponding user_id and group_id attributes matching the existing OCI membership.

Actual Behavior
The import fails with the following error message

│ Error: Cannot import non-existent remote object

│ While attempting to import an existing object to
│ "oci_identity_user_group_membership.identity_user_group_membership,
│ the provider detected that no object exists with the given id. Only
│ pre-existing objects can be imported; check that the id is correct and that
│ it is associated with the provider's configured region or endpoint, or use
│ "terraform apply" to create a new remote object for this resource.

even when:
The membership OCID exists and is verified in the OCI console
The user_id and group_id in the configuration match the actual membership
All OCIDs are accurate and valid

Steps to Reproduce

  1. Create an existing user group membership in OCI (or identify an existing one)
  2. Note the membership OCID, user OCID, and group OCID
  3. Define an oci_identity_user_group_membership resource with the matching user_id and group_id
  4. Create an import block using the membership OCID as the import ID
  5. Run terraform plan or terraform apply
  6. Observe the import failure

Import ID Format Used
According to the provider documentation, the import ID format should be:
terraform import oci_identity_user_group_membership.example <user_group_membership_id>

Where user_group_membership_id is the membership OCID (e.g., ocid1.groupmembership.oc1..cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc)

Request
Please help us to understand why the import functionality for oci_identity_user_group_membership fails despite providing accurate and verified OCIDs. Is there an issue with the import implementation for this resource type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting-affected-resourcesPlease Provide the affected resource name in description. ex. Affected resource - oci_core_instancebug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions