State Migration
Learn how to migrate your infrastructure state into Harness workspaces using the IaCM migration tool.
- Harness project with configured connectors
- OpenTofu backend configuration
Process Overview
- Local Setup - Configure workspace settings
- Workspace Creation - Create Harness workspaces
- State Import - Import infrastructure state
Phase 1: Local Setup
Get the Migration Tool
Clone the IaCM migration repository:
git clone git@github.com:harness/iacm-migration.git
Alternatively, you can fork the repository if you prefer.
Configure Your Variables
Create a new <filename>.tfvars
file in your local repository. This file will define:
- Your Harness account details
- Workspace configurations
- Provider settings
See the example below for reference:
Sample tfvars file
Apply Your Configuration
Run the following command in your repository directory:
terraform apply -refresh=true -var-file=<filename>.tfvars
When prompted, review the proposed changes and type yes to proceed.
This will generate an out
folder containing:
- Your new
main.tf
file listing your Harness workspaces - A migration pipeline configured to import your state
Phase 2: Create Workspaces
Now that your configuration is ready:
-
Set Up Authentication
cd out
export HARNESS_PLATFORM_API_KEY=<your-harness-api-key> -
Create the Workspaces
terraform init && terraform apply
-
Verify Creation: Check your Harness account to confirm the new workspaces are created.
Phase 3: Import Your State
-
Run Migration Pipeline
- Navigate to your new migration pipeline in Harness
- Select the target workspace for state import
- Start the pipeline
-
Verify State Import
- Go to your workspace
- Open the State tab
- Confirm your infrastructure state is imported correctly
-
Complete Migration Repeat the import process for each workspace you created.