oracle / terraform-provider-oci

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

ERROR while creating resources in a newly created compartment (Error: 400-InvalidParameter, compartment Ocid not found in Compartment Tree!) #1901

Open shengjun-zh opened 1 year ago

shengjun-zh commented 1 year ago

I am using Resource Manager to create some resources in OCI, and there was an error says "Compartment OCID not found in Compartment Tree". But the log shows this compartment has been created before.(please refer the log below)

Compartment Created at 2023/06/29 07:21:44:

2023/06/29 07:21:44[TERRAFORM_CONSOLE] [INFO] oci_identity_compartment.security_compartment: Creation complete after 6s [id=ocid1.compartment.oc1..aaaaaaaaknmstnvl3bcweyyzgi5zphhnolzix5ghumdr5dkqobbxmis2giia]
2023/06/29 07:21:44[TERRAFORM_CONSOLE] [INFO] oci_cloud_guard_security_recipe.gov_security_recipe: Creating...
2023/06/29 07:21:44[TERRAFORM_CONSOLE] [INFO] oci_sch_service_connector.audit_connector_tokyo: Creating...

ERROR occurred at 2023/06/29 07:23:22:

2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Error: 400-InvalidParameter, Ocid 'ocid1.compartment.oc1..aaaaaaaaknmstnvl3bcweyyzgi5zphhnolzix5ghumdr5dkqobbxmis2giia' not found in Compartment Tree!
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Suggestion: Please update the parameter(s) in the Terraform config as per error message Ocid 'ocid1.compartment.oc1..aaaaaaaaknmstnvl3bcweyyzgi5zphhnolzix5ghumdr5dkqobbxmis2giia' not found in Compartment Tree!
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Documentation: https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/cloud_guard_security_recipe 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] API Reference: https://docs.oracle.com/iaas/api/#/en/cloud-guard/20200131/SecurityRecipe/CreateSecurityRecipe 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Request Target: POST https://cloudguard-cp-api.ap-tokyo-1.oci.oraclecloud.com/20200131/securityRecipes 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Provider version: 4.122.0, released on 2023-05-24. This provider is 5 Update(s) behind to current. 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Service: Cloud Guard Security Recipe 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Operation Name: CreateSecurityRecipe 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] OPC request ID: 0fb988a25b6b87b771c36bc3bc6b3807/DB9FAFAE976056EEF38AFDE5F1FA1557/AFE80C6EDDDB5F97E18FCE55E636B57F 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO]   with oci_cloud_guard_security_recipe.gov_security_recipe,
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO]   on security_zone.tf line 41, in resource "oci_cloud_guard_security_recipe" "gov_security_recipe":
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO]   41: resource "oci_cloud_guard_security_recipe" "gov_security_recipe" {
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Error: 400-InvalidParameter, Ocid 'ocid1.compartment.oc1..aaaaaaaaknmstnvl3bcweyyzgi5zphhnolzix5ghumdr5dkqobbxmis2giia' not found in Compartment Tree!
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Suggestion: Please update the parameter(s) in the Terraform config as per error message Ocid 'ocid1.compartment.oc1..aaaaaaaaknmstnvl3bcweyyzgi5zphhnolzix5ghumdr5dkqobbxmis2giia' not found in Compartment Tree!
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Documentation: https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/sch_service_connector 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] API Reference: https://docs.oracle.com/iaas/api/#/en/serviceconnectors/20200909/ServiceConnector/CreateServiceConnector 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Request Target: POST https://service-connector-hub.ap-tokyo-1.oci.oraclecloud.com/20200909/serviceConnectors 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Provider version: 4.122.0, released on 2023-05-24. This provider is 5 Update(s) behind to current. 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Service: Sch Service Connector 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] Operation Name: CreateServiceConnector 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] OPC request ID: 16066110cc37af504a28d91be8140316/0E6A8476DFD994BFD0879DF918040F62/0598AFE1FCC5292EB08D43228E63BA92 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] 
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO]   with oci_sch_service_connector.audit_connector_tokyo,
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO]   on service_connect_hub_audit_log.tf line 41, in resource "oci_sch_service_connector" "audit_connector_tokyo":
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO]   41: resource "oci_sch_service_connector" "audit_connector_tokyo" {
2023/06/29 07:23:22[TERRAFORM_CONSOLE] [INFO] 
2023/06/29 07:23:23[TERRAFORM_CONSOLE] [INFO] 

In terraform config file, these error resources are configured to refer the created compartment id, so terraform could handle the dependence automatically.

resource "oci_cloud_guard_security_recipe" "gov_security_recipe" {
  compartment_id = oci_identity_compartment.security_compartment.id

resource "oci_sch_service_connector" "audit_connector_tokyo" {
  compartment_id = oci_identity_compartment.security_compartment.id

I tested several times, this error didn't happen every time. And even this error happened, the related resources changes. (Not always sch_service_connector and cloud_guard_security_recipe as in the log above.

Please help on this, thanks a lot!

affected_resources = oci_identity_compartment , oci_cloud_guard_security_recipe, oci_sch_service_connector

tf-oci-pub 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.

shengjun-zh commented 1 year ago

affected_resources = oci_identity_compartment , oci_cloud_guard_security_recipe, oci_sch_service_connector