Interview Prep/Terraform/Authentication and Cloud API Errors

`BucketNotEmpty: The bucket you tried to delete is not empty` during `terraform destroy`.

BeginnerTroubleshootingAuthentication and Cloud API Errors
Answer

Likely causes → Objects (or object versions/delete markers in a versioned bucket) remain.

Diagnose → aws s3api list-object-versions --bucket logs --max-items 5

Fix → For disposable buckets set force_destroy = true, apply, then destroy. For important buckets, empty them deliberately or keep them.

Prevent → force_destroy = true only in ephemeral environments.

All Terraform questions

More on Authentication and Cloud API Errors