Delete a non-empty COS bucket using Terraform

I am working on a use-case where I use Cloud Object Storage(COS) bucket to store a lot of files. The cloud service provisioning for the use-case happens using Terraform scripts. The tough part was to delete the COS bucket using terraform destroy. The destroy fails if the bucket is not empty.

Use this workaround if and only if your terraform resource doesn't support force-delete=true attribute or if don't want to use the attribute.