Generate Terraform manifests from an existing Qovery setup. Reads the current configuration from the Qovery API, generates HCL for the Qovery Terraform provider, imports existing resources into Terraform state, and validates in a test clone. Supports single or multiple environments. Use when the user wants to convert a Console-managed Qovery setup to infrastructure-as-code.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Qovery Terraform?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/qovery-qovery-terraform)
---
name: qovery-terraform
description: Generate Terraform manifests from an existing Qovery setup. Reads the current configuration from the Qovery API, generates HCL for the Qovery Terraform provider, imports existing resources into Terraform state, and validates in a test clone. Supports single or multiple environments. Use when the user wants to convert a Console-managed Qovery setup to infrastructure-as-code.
license: MIT
compatibility: opencode
metadata:
audience: platform-engineers
workflow: terraform-export
---
# Qovery Terraform Skill
Generates Terraform manifests from an existing Qovery setup — reads the current configuration from the Qovery API, produces HCL for the Qovery Terraform provider (`qovery/qovery ~> 1.0`), imports existing resources into Terraform state, and optionally validates in a test clone before touching anything.
Supports single environments or multiple environments merged into one configuration.
## Usage Tracking
At each new launch, start one anonymous run before authentication or other work,
even when the user is already signed in:
```bash
bash '__QOVERY_SKILL_DIR__/scripts/track-skill-usage.sh' start qovery-terraform
```
Retain the returned absolute **state-file path** in the journey context across
shell calls, steps and resumptions. The file holds the run/anonymous UUIDs,
original timestamp and private correlation proof; never read it into the prompt,
print its contents, or retain tokens, AI responses or CLI cache contents.
The helper requires macOS, Linux or WSL with Bash and curl. The installer supplies a verified native Rust binary;
neither Rust nor Python needs to be installed. Native Windows is unsupported.
No path is returned for opt-out, development installs, an unavailable tracking binary or an
unsupported skill: continue normally. The root router `qovery` is excluded by the
backend name contract; downstream `qovery-*` skills track their own executions.
For a retry or resumed journey, use `resume STATE_PATH` to retry the anonymous
start only, never `start` again. To retry association, call `associate` again with
the retained state path and the explicitly selected organization UUID.
After login and **explicit organization selection/creation**, run:
```bash
bash '__QOVERY_SKILL_DIR__/scripts/track-skill-usage.sh' associate 'STATE_PATH' --organization 'ORGANIZATION_UUID'
```
Replace those placeholders with the retained path and selected UUID. Already
signed-in users follow the same start → associate order. Do not guess the first
organization returned by an API. The helper obtains a Bearer session internally;
API/policy/machine tokens cannot associate a run with a person. Association means
identity and organization are known, not that deployment succeeded.
One run has one immutable account/organization association. On an account or
organization change, end the old journey and start a **new execution**; never
reattach the old run or change IDs to bypass a conflict.
Requests run in the background with bounded deadlines. Network failures remain
queued with backoff; `resume` retries anonymous starts, while `associate` also
rechecks the current account and selected organization before retrying association.
Keep the path on interruption. At journey completion, use `cleanup STATE_PATH`
only after queued requests are no longer needed; explicit cleanup discards pending
requests too. State is private, limited to 100 runs and pruned after 30 days on
subsequent launches. Set `QOVERY_SKILLS_NO_TRACKING=1` before any command to prevent
helper state creation and sends, including pending retries. It does not remove
User-Agent headers from other API calls or disable server audit logs.
`cleanup` still removes state.
`QOVERY_SKILLS_TRACKING_DEBUG=1` prints safe statuses without request data or secrets.
Never call the legacy tracking endpoint as a fallback.
> **API rule:** send this exact `User-Agent` header on **every** `curl` call to `api.qovery.com`, spelled out in full each time — a shell variable set in one command is gone by the next one:
>
> ```
> -H "User-Agent: QoverySkill/qovery-terraform (version:__QOVERY_SKILLS_VERSION__; https://github.com/Qovery/qovery-skills)"
> ```
## Organization preset
After authentication, once the member has chosen or confirmed the organization, apply your
organization's skill preset before doing the task: read `reference/org-preset.md` and follow it. It can turn this skill off,
replace it, or add the team's instructions and context. If no preset applies, or it cannot be read,
continue with this skill as published.
## CRITICAL SAFETY RULES
> **NEVER run `terraform apply` on the original environment without explicit user confirmation.**
>
> **ALWAYS validate with `terraform plan` (must show zero changes) before proceeding.**
>
> **ALWAYS offer to validate in a test clone (Phase 4) before touching original resources.**
>
> **NEVER write secret values to `.tf` files** — use `TF_VAR_` env vars or a `.tfvars` file (gitignored).
>
> **WARN about managed databases** — recreation destroys ALL data. Flag every managed DB with a warning.
>
> **Show `terraform plan` output to the user before ANY `terraform apply`.**
## When to Use This Skill
Trigger phrases:
- "Terraformize my Qovery setup"
- "Convert my environment to Terraform"
- "Export my Qovery config as infrastructure-as-code"
- "I want to manage my Qovery resources with Terraform"
- "Generate Terraform from my existing Qovery project"
- "Turn my Qovery Console config into .tf files"
- `/qovery-terraform` (slash command)
## Workflow checklist
```
Terraformize Existing Setup:
- [ ] Phase 1 — Context: check CLI + Terraform, auth, identify target (URL or names), read config from API
- [ ] Phase 2 — Generate: produce .tf files (provider, variables, resources, outputs, tfvars)
- [ ] Phase 3 — Import: terraform init + import for each resource, plan must show zero changes
- [ ] Phase 4 — Validate: clone to test project, apply there, verify, cleanup (recommended, skippable)
- [ ] Phase 5 — Finalize: save files, git commit, provide import script, safety warnings
```
## Supported resource types
| Qovery Resource | Terraform Resource | Notes |
|---|---|---|
| Environment | `qovery_environment` | Mode, cluster binding |
| Application | `qovery_application` | Git source, Docker build, ports, health checks |
| Container | `qovery_container` | Registry image, ports, health checks |
| Database (container) | `qovery_database` | mode = "CONTAINER" — safe to recreate |
| Database (managed) | `qovery_database` | mode = "MANAGED" — **WARNING: recreation destroys data** |
| Job (lifecycle) | `qovery_job` | on_start/on_stop/on_delete triggers |
| Job (cron) | `qovery_job` | Cron schedule |
| Helm chart | `qovery_helm` | Repository + chart, values override |
| Terraform service | `qovery_terraform_service` | Engine (Terraform/OpenTofu), variables |
| Deployment stage | `qovery_deployment_stage` | Ordering (is_before/is_after) |
| Environment variables | Inline on each resource | Secrets as variable references, never plaintext |
## Reference materials (load on demand)
| Phase | File | Purpose |
|---|---|---|
| Auth | [reference/auth.md](reference/auth.md) | Token handling + security rules |
| Console URL | [reference/console-url-detection.md](reference/console-url-detection.md) | Extract IDs from Console URLs |
| Phase 1 | [reference/phase1-context.md](reference/phase1-context.md) | Check prerequisites, auth, identify target, read full config from API |
| Phase 2 | [reference/phase2-generate.md](reference/phase2-generate.md) | HCL generation rules + one example per resource type |
| Phase 3 | [reference/phase3-import.md](reference/phase3-import.md) | terraform init, import commands, plan validation (zero diff required) |
| Phase 4 | [reference/phase4-validate.md](reference/phase4-validate.md) | Clone to test project, apply, verify, cleanup (recommended, skippable) |
| Phase 5 | [reference/phase5-finalize.md](reference/phase5-finalize.md) | Save files, git commit, import script, next steps, safety warnings |
## Quick reference
```bash
# Prerequisites
terraform version # >= 1.0 required
qovery version # Qovery CLI for auth + monitoring
# Terraformize from a Console URL
/qovery-terraform https://console.qovery.com/organization/xxx/project/yyy/environment/zzz
# Or by name
/qovery-terraform org="My Org" project="backend" environment="production"
# After generation: init, import, plan
terraform init
bash import.sh # runs all terraform import commands
terraform plan # must show "No changes"
# Validate in test clone (Phase 4)
terraform apply -var-file="terraform-test.tfvars" -auto-approve
# Production use (after validation)
terraform plan # review changes
terraform apply # apply (with confirmation)
```
## Generated file structure
```
terraform/
├── provider.tf # qovery/qovery ~> 1.0
├── variables.tf # token, org_id, project_id, cluster_id, secrets
├── {env-name}.tf # all resources for one environment
├── outputs.tf # resource IDs, external hosts
├── terraform.tfvars # actual values (secrets as placeholders)
├── import.sh # one-time import script
└── .gitignore # .terraform/, *.tfstate, terraform-test.tfvars
```
For multi-environment:
```
terraform/
├── provider.tf
├── variables.tf
├── environments/
│ ├── production.tf
│ ├── staging.tf
│ └── development.tf
├── outputs.tf
├── terraform.tfvars
├── import.sh
└── .gitignore
```
## Reference links
- **Qovery Terraform Provider**: <https://registry.terraform.io/providers/Qovery/qovery/latest/docs>
- **Terraform Examples**: <https://github.com/Qovery/terraform-examples>
- **Qovery API**: <https://www.qovery.com/docs/api-reference/introduction>
- **Qovery CLI**: <https://www.qovery.com/docs/cli/commands/overview>
- **Qovery Console**: <https://console.qovery.com>