Terraform State Migration Guide
This guide provides a detailed, step-by-step process for migrating the Terraform state into Bluebricks. By following these instructions, you'll ensure a seamless and hassle-free migration of the old infrastructure state into Bluebricks managed state.
Migration Steps
Before beginning the migration, confirm the following:
Migration Workflow
Prepare the Current Terraform Environment
Open the terminal and navigate to the folder that contains the code to be migrated.
cd ~/path/to/terraformInitialize the Terraform Directory
Validate Current State
Ensures no pending changes exist in the current configuration. An exit code of 0 indicates no modifications are required.
Removes the
.terraformdirectory to facilitate a fresh initialization
Prepare State File for Migration
Exports the entire Terraform state file to a local JSON file for reference
Create a new
terraform.tfstatefile and copy the resources that match the module to be migrated fromterraform.json.
Migrating multiple resources of the same type/package is not supported.
Validate the created
terraform.tfstatefile by running the following command:
Confirm the output shows no planned changes.
Validate the syntax of the state
After copying and validation are complete, remove the
terraform.jsonfile
Convert Module to an Artifact
Navigate to the parent folder
Create an Artifact by running the following command:
Change directory to
artifactand publish the created Artifact
Validate Artifact
Test Artifact by initiate a plan-only installation
Cleanup Artifact
Remove temporary files
Delete the migrated
terraform.tfstatefileRemove
state_pathentry frombricks.json
Finalize Deployment
Increment Artifact version
Publish final changes
Last updated
Was this helpful?

