Terraform state rm command unsetting s3 backend

I want to remove a resource from tfstate file which is on s3 backend. When I execute ‘terraform state rm command’, s3 backend gets unsetted. Similar output comes from state pull and push commands. I dont want s3 bucket to be present in state file so that it does not get destroyed while destroying resources. Any suggestions will be very helpful. Thanks. Steps I am following :

  1. terraform init -reconfigure -backend-config="DEV/stack.tfbackend" layers/DEV

  2. terraform apply -var-file="DEV/stack.tfvars" layers/DEV

  3. terraform state rm module.aws_s3_bucket.bucket_name

Following output is returned on ‘state rm’ command:

Reason: Unsetting the previously set backend "s3"

The "backend" is the interface that Terraform uses to store state,
perform operations, etc. If this message is showing up, it means that the
Terraform configuration you're using is using a custom configuration for
the Terraform backend.

Changes to backend configurations require reinitialization. This allows
Terraform to setup the new configuration, copy existing state, etc. This is
only done during "terraform init". Please run that command now then try again.

If the change reason above is incorrect, please verify your configuration
hasn't changed and try again. At this point, no changes to your existing
configuration or state have been made.

Error loading the state: Initialization required. Please see the error message above.

Please ensure that your Terraform state exists and that you've
configured it properly. You can use the "-state" flag to point
Terraform at another state file.```
1 Like