in order to maintain your tfstate file properly, you must have versioning enabled on your s3 bucket.
here is the code i used to create the <code>backend.tf</code> file. you'll need to update it with the name of your s3 bucket and the path to your <code>terraform.tfstate</code> file.
here is the code for terraform.tf used to create the s3 backend. you can model yours off my example, or be creative and create your own- just make sure you destroy any infrastructure you create!
save your <code>backend.tf file</code> with your <code>terraform.tf</code> (or <code>main.tf</code> file) in a working directory under your terraform root directory.