Search code examples
terraformminio

How to initialize remote state in Terraform?


I am trying to configure a Minio/S3 backend for remote_state. However, I receive the error message No stored state was found for the given workspace in the given backend. and I fail to understand why. Of course there is no state found as I haven't created one yet.

I run terraform init, then terraform plan -input=false -out=myplan which works if I don't use remote_state but shows the above error when I do.

EDIT: I was able to get through the first steps by using -refresh=false. But this doesn't seem to be a solution. If no state file is available I expect Terraform to treat it as a new deployment and create one.


Solution

  • You need to run terraform init to migrate the local state file to the remote host.

    For a step by step guide you can follow the example in the official docs, with step #6 being the actual step that migrates the local tfstate to the remote host.