oxid sync
Sync state from a Terraform remote backend into Oxid. Supports local .tfstate files and S3 backends.
Usage
oxid sync [flags]
The sync command reads a Terraform state source and synchronizes all resources into the Oxid state database. It performs an upsert - existing resources are overwritten with the latest state, and resources that no longer exist in the source are removed from Oxid state.
How It Works
- Upsert behavior - Resources found in the Terraform state are inserted or updated in the Oxid database. Attributes are fully replaced with the latest values.
- Stale resource removal - Resources that exist in Oxid state but are absent from the Terraform state source are removed. This keeps the two systems in sync.
- Non-destructive - No infrastructure is created, modified, or destroyed. Only the local Oxid state database is updated.
Sync from Local .tfstate
Sync from a local Terraform state file:
$ oxid sync --state-file terraform.tfstate Syncing state from terraform.tfstate... Upserted: aws_vpc.main Upserted: aws_subnet.public[0] Upserted: aws_subnet.public[1] Upserted: aws_instance.api Removed: aws_s3_bucket.deprecated (stale) Sync complete. 4 upserted, 1 removed.
Sync from S3 Remote Backend
If your configuration includes an S3 backend block, Oxid reads the remote state directly:
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "prod/terraform.tfstate"
region = "us-east-1"
}
}$ oxid sync Reading remote state from s3://my-terraform-state/prod/terraform.tfstate... Syncing 47 resources... Sync complete. 45 upserted, 2 removed.
Flags
| Flag | Description | Default |
|---|---|---|
| --state-file <path> | Path to a local Terraform .tfstate file. If omitted, Oxid reads the backend configuration from your .tf files. | - |
Use Cases
Migrating from Terraform
Use sync as part of a gradual migration from Terraform to Oxid. Continue running Terraform for some resources while managing others with Oxid, and periodically sync to keep state aligned:
# After Terraform apply, sync state into Oxid terraform apply oxid sync --state-file terraform.tfstate
Disaster recovery
If your Oxid state database is lost or corrupted, re-sync from the Terraform remote backend to rebuild it:
rm .oxid/oxid.db oxid init oxid sync
Multi-tool workflows
Teams that use both Terraform and Oxid can sync periodically to ensure Oxid has the latest state for operations like blast-radius analysis and drift detection.