Reputation: 717
I usually prefer storing my statefiles to remote i.e. S3. This time I'm having a nightmare recovering the state as somehow the S3 bucket got deleted. Although, I have the statefile locally but it's of no use. I get this error:
$ terraform init -reconfigure
Initializing modules...
- module.ca
- module.etcd
- module.master
- module.network
- module.node
- module.output-store
- module.rds
Initializing the backend...
Error inspecting states in the "s3" backend:
NoSuchBucket: The specified bucket does not exist
status code: 404, request id: 30937B3sdfsd16F978120, host id: 3lOPzk8+Me+7NHgmC+YCTJBNXH34t0rLUdm9lYU/mkuDsdAWFEp+zbwUZzOL4wgXnREY4OFTDpbv69cwk=
Prior to changing backends, Terraform inspects the source and destination
states to determine what kind of migration steps need to be taken, if any.
Terraform failed to load the states. The data in both the source and the
destination remain unmodified. Please resolve the above error and try again.
Is there a way in terraform to force the backend to local again without the reconfigure option, so that it starts considering the statefile in local ? Please advise.
Upvotes: 1
Views: 2613
Reputation: 774
Even when you are using the remote state option there is still a little bit of state that is saved locally. It is stored in the .terraform/terraform.tfstate
file. You can either delete the whole directory(that will reaquire downloading all the modules and providers) or just delete the backend
key from state or the whole file.
Upvotes: 1
Reputation: 345
Create the s3 bucket and upload your state file from your local
Upvotes: 3