Migrating existing infra
Adopt existing, running cloud resources into Facets-managed Terraform state without recreating or destroying them, using a staged import flow Praxis can guide.
Overview
Migrating existing infrastructure to Facets means bringing cloud resources - already provisioned and running - under Facets-managed Terraform state without destroying or recreating them. Once under management, Facets handles all future drift detection, planning, and deployment through its standard release workflow.
This guide covers the end-to-end migration process and describes how Praxis, the Facets AI assistant, can guide and execute each stage.
Critical distinction: This is not a lift-and-shift. Resources remain running throughout. The goal is to make Terraform "adopt" existing resources so Facets can manage them going forward.
Migration Flow
Migration follows nine stages. Praxis can execute or guide each stage interactively.
Step 1: Identify the Target Resource
Understand what you are migrating and where it lives. Provide Praxis with:
- Cloud account which AWS/GCP/Azure account holds the resource
- Region where the resource is deployed
- Cloud resource identifier the actual ID as seen in the cloud console (e.g., EKS cluster name, RDS instance ID, GKE cluster name)
- and any other extra information that Praxis should know before discovery.
Step 2: Discover Cloud Resources
Collect the cloud IDs for every Terraform resource in the module.
Praxis queries the cloud account using read-only CLI commands to build a complete mapping of Terraform resource address → Cloud resource ID / ARN.
Step 3: Prepare the Module
After Step 2, Praxis maps the discovered modules to the modules present in the Facets Module Registry.
Incase the module is not present in the registry, Praxis makes production ready custom terraform modules and registers them in the control plane for usage across projects.
Step 4: Run a Targeted Plan
Once all the required infrastructure modules are available in the control plane, Praxis creates a project with a blueprint that mirrors the existing infrastructure, based on the discovery carried out in the previous step.
With the blueprint in place, Praxis launches an environment using the selected resources and runs a targeted Terraform plan scoped only to the resource being migrated, ensuring no interference with other modules.
Praxis then fetches the full plan logs and extracts the resource addresses, which are used directly in the import blocks during the next stage.
Step 5: Build Imports Incrementally
Construct Terraform import blocks for every resource and verify each batch with a plan.
Recommended Import Order (Bottom-Up): Import dependencies before the resources that depend on them:
- Security group rules, IAM policy attachments, IAM policies
- Security groups, IAM roles
- CloudWatch log groups (only if they exist), OIDC providers, Addons / extensions
- Main resource (cluster, database, etc.)
A zero-change import sends imports.tf to an import release. A standard import, with in-place changes you approve, still uses a custom release.
Praxis adds resources in batches, verifying each batch before proceeding. Logs are analyzed with targeted grep patterns.
Step 6: Reconcile Drifts
For each imported resource, resolve all plan diffs until the plan is clean.
After importing, the Terraform plan will often show differences between what Facets expects and what exists in the cloud. For each diff, Praxis presents three choices:
- Ignore drift: Add the field to lifecycle in the module
- Allow the change: Let Terraform update the field on apply (Praxis explains risk)
- Make it configurable: Add a spec field to facets.yaml, wire it through the module, and update the blueprint to match the existing cloud value, so the plan becomes a no-op
After each module change, republish and re-plan. Repeat until: Plan: 0 to add, 0 to change, 0 to destroy.
Step 7: Apply
Import all resources into Terraform state. This is the irreversible step. Praxis will always present a full summary and require explicit user approval before proceeding.
Pre-apply checklist Praxis validates:
- Zero forces replacement diffs remaining. All in-place updates have been reviewed and approved
- No unexpected destroy operations. Plan summary shows 0 to destroy
The apply performs two operations atomically: Imports each resource into Terraform state and applies any remaining approved in-place updates
For a zero-change import, run an import release instead.
Step 8: Update Blueprint Spec
Align the blueprint configuration with what actually exists in the cloud.
After the import, the blueprint may still describe features that were never provisioned, such as addons that are not installed or node groups that are not present. Praxis reads the current resource configuration, edits it to match reality, and applies it back:
raptor get resources -p <project> <type>/<name> -o json > resource.json
raptor apply resource <type>/<flavor>/<version> -p <project> -n <name> --spec-file resource.json -y--spec-file replaces the whole spec, so anything missing from resource.json is dropped, and -y skips the confirmation prompt it would otherwise raise. To change one field instead, use --set KEY=VALUE, which merges into the existing spec.
Step 9: Final Verification
Confirm that the environment is in a clean, no-change state.
raptor create release -p <project> -e <environment> --plan --target <type>/<name> -w--plan runs the plan only, without applying, and -t/--target targets specific resources. -w waits for the release to complete and tails its logs; without it the release is still triggered, but the command neither waits nor tails, so you get no plan output in the terminal.
On a CRD-driven environment, --plan starts a Plan and apply release instead. Read the plan, then reject it so nothing is applied.
Check the tailed plan output. If it still reports changes, repeat Steps 6 through 8 until it does not.
To read the logs of a release you already triggered, find its ID with raptor get releases -p <project> -e <environment>, then run raptor logs release -p <project> -e <environment> <release-id>. By default that writes the log content to a tempfile and prints only the file path plus the final status, so add --stream to also tee every log line to stdout. raptor download plan <release-id> -p <project> -e <environment> downloads the Terraform plan zip for a plan release.
Zero-change import with an import release
An import release adopts existing resources into Terraform state and applies only if nothing else changes.
Using prompt
Import the existing RDS instance orders-db into postgres/orders in prod without changing anything.or
Using command
raptor create import-release -p PROJECT -e ENVIRONMENT -t postgres/orders --imports-file ./imports.tf -wRepeat -t for each resource to adopt. --imports passes the blocks inline instead of from a file. There's no --plan or --allow-destroy.
New to the CLI? Install it first.
The web UI can't start an import release. It lists them in the environment's release history with type IMPORT.
imports.tf holds only Terraform import blocks, up to 256 KB and 500 blocks. Each block's to must sit inside a resource passed with -t, such as module.level2.module.<intent>_<name>.<type>.<name>.
Facets refuses to apply if the plan would create, change, destroy or replace anything, or if an address in imports.tf is missing from it, such as one outside the -t targets. Two things are exempt: the bookkeeping record every release writes, and data-source reads. A refused release fails with nothing applied; fix the module or blueprint and run it again. A passing one applies exactly the saved plan. Re-running a succeeded import is safe and does nothing.
Starting one needs the Import Release permission, which only the Admin role has by default. It can't change or destroy anything, so it's safe to add to custom roles.
Praxis can find, map and import your resources for you (Adopt and migrate infrastructure).
Critical Resources
Mark resources as critical in Facets to restrict who can delete, disable, or edit sensitive infrastructure, backed by RBAC permissions and audit logs.
Environment
Environments in Facets are the clusters where blueprints deploy, with per-environment config, runtime variables, and isolation across dev, test, and prod.