linode / terraform-provider-linode

Terraform Linode provider
https://www.terraform.io/docs/providers/linode/
Mozilla Public License 2.0
197 stars 94 forks source link

add `obj_bucket_force_delete` config option to delete buckets with objects #1465

Closed jriddle-linode closed 3 months ago

jriddle-linode commented 4 months ago

📝 Description

What does this PR do and why is this change necessary?

Allows users to set a obj_bucket_force_delete flag which will purge a bucket deleted by Terraform of all its objects.

✔️ How to Test

How do I run the relevant unit/integration tests?

make int-test PKG_NAME="linode/objbucket" ARGS="-run TestAccResourceBucket_forceDelete"
  1. In a sandbox environment create the following file
    
    terraform {
    required_providers {
    linode = {
      source  = "linode/linode"
      version = "2.6.0"
    }
    }
    }

provider "linode" { obj_use_temp_keys = true obj_bucket_force_delete = true }

resource "linode_object_storage_bucket" "test" { cluster = "us-mia-1" label = "test-obj-bucket"

lifecycle_rule {
    prefix = "tf"
    enabled = true

    abort_incomplete_multipart_upload_days = 5

    expiration {
        date = "2024-03-21"
    }
}

}

resource "linode_object_storage_object" "test" { bucket = linode_object_storage_bucket.test.label cluster = "us-mia-1" key = "foobar" content = "cool" }

2. Run `terraform apply`
3. Confirm the bucket/object was created
4. Using another tool add more Objects
```bash
linode-cli obj put ./Makefile test-obj-bucket --cluster us-mia-1
  1. Comment out or delete the bucket and object resources from your terraform file
    
    terraform {
    required_providers {
    linode = {
      source  = "linode/linode"
      version = "2.6.0"
    }
    }
    }

provider "linode" { obj_use_temp_keys = true obj_bucket_force_delete = true }

6. Confirm that the action deleted the bucket and all objects
```bash
linode-cli obj ls test-obj-bucket --cluster us-mia-1

resolves #1129

tchinmai7 commented 3 months ago

amazing QoL improvement!. Love seeing this effort coming in!.