This tutorial teaches managing Terraform state locally and migrating it to a remote S3-compatible backend using MinIO.
Welcome to the OpenTofu Remote State lab! In this tutorial, you’ll learn how to manage Terraform state locally and then migrate it to a remote S3-compatible backend using MinIO. We’ll walk through creating local state, switching variables, configuring S3 backend, and migrating your state seamlessly.
Error: Backend initialization required, please run "tofu init"
Run:
Copy
Ask AI
tofu init
You’ll be prompted:
Copy
Ask AI
Pre-existing state was found while migrating the previous "local" backendto the newly configured "s3" backend.Do you want to copy this state to the new "s3" backend? Enter "yes" to copy...Enter a value: yes
After migration, remove the local state:
Copy
Ask AI
rm terraform.tfstate
Deleting the local terraform.tfstate is irreversible. Ensure the remote copy is present before removal.