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

Resources treated as deleted even when it's not #2055

Closed SerhiiSokolov closed 1 month ago

SerhiiSokolov commented 7 months ago

Community Note

Terraform Version and Provider Version

Terraform v1.6.6 on darwin_arm64

Affected Resource(s)

oci_objectstorage_bucket

Terraform Configuration Files

resource "oci_objectstorage_bucket" "this" {
    access_type           = "NoPublicAccess"
    approximate_count     = "0"
    approximate_size      = "0"
    auto_tiering          = "Disabled"
    bucket_id             = "***"
    compartment_id        = "***"
    defined_tags          = {
        *****
    }
    freeform_tags         = {
        "terraformed" = "Please do not edit manually"
    }
    name                  = "123"
    namespace             = "****"
    object_events_enabled = false
    replication_enabled   = false
    storage_tier          = "Standard"
    versioning            = "Enabled"
}

Debug Output

Panic Output

Expected Behavior

When run terraform destroy without enough permissions to delete the bucket error occure

Actual Behavior

terraform reports that resources is deleted and resources is removed from the state

Steps to Reproduce

  1. terraform apply
  2. Remove permissions for deleting buckets from the entity that works with terraform, keep read-only access for tenancy
  3. terraform destroy

Important Factoids

2024-03-04T09:47:29.051+0100 [INFO]  provider.terraform-provider-oci_v5.31.0: 2024/03/04 09:47:29 [DEBUG] the ignored error is
 Error returned by ObjectStorage Service. Http Status Code: 404. Error Code: BucketNotFound. Opc request id:****. Message: Either the bucket named '123' does not exist in the namespace '****' or you are not authorized to access it
Operation Name: DeleteBucket
Timestamp: 2024-03-04 08:47:29 +0000 GMT
Client Version: Oracle-GoSDK/65.60.0
Request Endpoint: DELETE https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/******/b/123
Troubleshooting Tips: See https://docs.oracle.com/iaas/Content/API/References/apierrors.htm#apierrors_404__404_bucketnotfound for more information about resolving this error.
Also see https://docs.oracle.com/iaas/api/#/en/objectstorage/20160918/Bucket/DeleteBucket for details on this operation's requirements.
To get more info on the failing request, you can set OCI_GO_SDK_DEBUG env var to info or higher level to log the request/response details.
If you are unable to resolve this ObjectStorage issue, please contact Oracle support and provide them this full error message.: timestamp="2024-03-04T09:47:29.051+0100"
2024-03-04T09:47:29.051+0100 [DEBUG] State storage *remote.State declined to persist a state snapshot
2024-03-04T09:47:29.051+0100 [DEBUG] State storage *remote.State declined to persist a state snapshot
oci_objectstorage_bucket.this: Destruction complete after 0s
2024-03-04T09:47:29.052+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-03-04T09:47:29.055+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/oracle/oci/5.31.0/darwin_arm64/terraform-provider-oci_v5.31.0 pid=83018
2024-03-04T09:47:29.055+0100 [DEBUG] provider: plugin exited
2024-03-04T09:47:29.055+0100 [DEBUG] states/remote: state read serial is: 8; serial is: 8
2024-03-04T09:47:29.055+0100 [DEBUG] states/remote: state read lineage is: bd2b6dd8-c987-7afe-6e49-9bd7c7eaf6b1; lineage is: bd2b6dd8-c987-7afe-6e49-9bd7c7eaf6b1
2024-03-04T09:47:29.056+0100 [INFO]  backend-s3: Uploading remote state: tf_backend.operation=Put tf_backend.req_id=**** tf_backend.s3.bucket=****terraform-state tf_backend.s3.path=****/eu-frankfurt-1/bucket/terraform.tfstate

References

tf-oci-pub commented 7 months ago

Thank you for reporting the issue. We have raised an internal ticket to track this. Our service engineers will get back to you.

sanne-bunnings commented 6 months ago

Any update on this @tf-oci-pub ?

sagarp337 commented 1 month ago

issue is addressed in https://github.com/oracle/terraform-provider-oci/releases/tag/v6.10.0