Exporting to Terraform
Exporting to Terraform
Section titled “Exporting to Terraform”Sencai can generate Terraform configuration (HCL) for the cloud instances it manages — the mirror operation to importing existing infrastructure. Where import brings your existing resources into Sencai, export lets you take Sencai-tracked resources back out as plain, human-readable .tf text you can review, adapt, and apply yourself.
What export does — and doesn’t do
Section titled “What export does — and doesn’t do”- Export generates text only. It never runs
terraform apply, never contacts your cloud provider on your behalf as part of the export itself, and never modifies any live resource. - The generated file never contains credentials or secrets — no access keys, API tokens, or passwords. You add your own provider authentication before running Terraform yourself.
- Every exported file starts with a header comment noting when it was generated and reminding you to review before apply — treat it as a starting point, not a drop-in replacement for infrastructure you already manage elsewhere.
Supported providers and resources
Section titled “Supported providers and resources”| Supported | |
|---|---|
| Providers | AWS, GCP, Azure, Hetzner |
| Resources | Cloud instances (always); cloud networks (optional, if included) |
If a selected instance uses a provider outside this list (for example DigitalOcean), it is skipped, not silently dropped — the export still completes for the supported instances, and the skipped ones are listed with the reason so you know exactly what’s missing from the output.
Step-by-step: exporting instances
Section titled “Step-by-step: exporting instances”Step 1: Select instances
Section titled “Step 1: Select instances”- Go to Cloud Instances
- Use the checkboxes to select one or more instances you want to export
- Click Export as Terraform (only enabled once at least one instance is selected)
Step 2: Configure the export
Section titled “Step 2: Configure the export”In the dialog that opens:
- Toggle include network if you also want associated cloud networks included in the output
- Optionally narrow by provider if your selection spans more than one
Step 3: Wait for the job to finish
Section titled “Step 3: Wait for the job to finish”Export runs as a background job, same as import — you’ll see a live status (submitting → running → completed/failed) while it works. This typically takes only a few seconds for a handful of instances.
Step 4: Review, copy, or download
Section titled “Step 4: Review, copy, or download”Once the job completes, you’ll see:
- A preview of the generated
.tftext - Copy — copies the full text to your clipboard
- Download — saves it as a
.tffile (namedsencai-export-<timestamp>.tf) - A list of any skipped instances and why (e.g. “provider not supported for export”), if applicable
What to do with the exported file
Section titled “What to do with the exported file”The exported .tf file is a starting point for bringing these resources under your own Terraform workflow:
- Add a
providerblock with your own credentials (never included in the export) - Add a state backend of your choice
- Run
terraform initandterraform planto review what Terraform would do — since the resources already exist, you may need toterraform importthem into your state before applying, or adjust the generated blocks to match your existing module structure - Review carefully before
terraform apply— the file is generated from Sencai’s records of the resource, not a live read of the provider, so double-check anything you’ve changed outside Sencai recently
Export vs. import
Section titled “Export vs. import”| Import | Export | |
|---|---|---|
| Direction | Existing cloud resources → Sencai | Sencai-tracked resources → Terraform text |
| Input | Your cloud account credentials | Cloud instances you’ve selected |
| Output | Resources adopted into Sencai management | A downloadable .tf file |
| Modifies anything? | No — read-only scan | No — text generation only |
Troubleshooting
Section titled “Troubleshooting”Q: My export finished, but some instances are missing from the output.
A: Check the skipped-instances list shown after the job completes — an instance using an unsupported provider (currently anything other than AWS, GCP, Azure, or Hetzner) is skipped with a reason, not silently omitted.
Q: The export job failed entirely.
A: This usually indicates a transient backend issue rather than anything about your specific instances. Retry the export; if it keeps failing, contact support.
Q: Can I export networks without instances?
A: Networks are exported alongside the instances you select (via the “include network” option) — export currently works from an instance selection, not a standalone network picker.
Q: Does exporting affect the live resource in any way?
A: No. Export only reads Sencai’s own records and generates text — it never contacts your cloud provider or changes the resource.