Skip to main content
The Terraform exporter generates the Terraform configuration of an environment set up from the Console. After you import the exported resources into a Terraform state, Terraform manages the environment. There are two ways to export:
  • From the Console: one environment at a time, as a zip file. You add the import blocks yourself. The rest of this page covers this path.
  • With a coding agent: the qovery-terraform skill reads one or more environments from the API, writes the configuration, imports the resources and checks that the plan shows no change.

What gets exported

The export contains a resource block for each of these:
  • The organization (qovery_organization), and all of its container registries, Helm repositories, labels groups and annotations groups.
  • The cluster of the environment (qovery_cluster) and its cloud credentials (qovery_aws_credentials, qovery_gcp_credentials, qovery_scaleway_credentials or qovery_eks_anywhere_vsphere_credentials). The provider has no resource for Azure credentials: an AKS cluster references its credentials through a qovery_azure_credentials data source.
  • The git tokens that the applications, jobs and Terraform services of the environment use (qovery_git_token).
  • The project, the environment and its deployment stages.
  • The services of the environment: applications, containers, jobs, Helm charts, Terraform services and databases, with their variables and secrets.
  • The services created from the service catalog, exported as the qovery_blueprint that manages them rather than as a Helm chart or a Terraform service. Each one comes with its own import block.
The export does not contain a qovery_deployment resource. Build settings are exported as build.* keys in advanced_settings_json, not as a build_settings block.

Export an environment

1

Open the export

In the Console, open the environment, click the Other actions menu (three dots) and select Export as Terraform. Only organization admins can export an environment.
2

Confirm the export

The confirmation dialog explains that secret values will not be exposed. There is no option to include them, including when exporting through the API.
3

Download

Click Export. The download is a zip file with two files:
  • main.tf: the provider configuration and the resources.
  • variables.tf: the input variables. qovery_access_token accepts the API token of the provider. The other variables accept the secrets of the project, the environment, the services and the blueprints, the cloud credentials, the registry and Helm repository credentials, and the git tokens. Service secret variables have an empty default marked # Redacted. Credential variables have no default. Supply their values before applying the configuration.
Secret aliases and external secret references are preserved. Their referenced secret values are not included.
Set all redacted secret values and required credentials before applying. Empty service secret values can overwrite existing secrets.

Import the exported resources

1

Set the input variables

The provider reads its token from the qovery_access_token variable:
Set the variables that have no default and override the empty defaults of redacted secrets the same way, or in a terraform.tfvars file that you keep out of version control.Terraform stores the supplied secret values in its state. Keep the state in a protected backend and out of version control.
2

Initialize

3

Add an import block for every resource

In a new file, such as imports.tf, add an import block for every resource of main.tf, except the blueprints: main.tf already imports them, and a second import block for the same resource is an error. import blocks need Terraform 1.5 or later. Each resource is named after its kind, followed by z and the first eight characters of its ID. For example, the environment a1b2c3d4-… is qovery_environment.environment_za1b2c3d4.
imports.tf
The import ID is the resource ID for the organization, the project, the environment, the services, and the labels and annotations groups. It is <organization_id>,<resource_id> for the cloud credentials, the cluster, the container registries, the Helm repositories and the git tokens, and <environment_id>,<stage_name> for the deployment stages. The Registry page of each resource gives its format.
4

Review the plan

The plan lists every import. The Qovery API never returns secret values or the spec_overrides of blueprints, so the plan also sets them once from the configuration. For a blueprint that has secret variables or spec overrides, that apply redeploys its service. Apart from that, a complete import plans no change. Review any other change before you apply it: it is a difference between the exported configuration and Qovery.
5

Apply

Terraform records the imported resources in its state. You can then remove the import blocks.

Export with a coding agent

The qovery-terraform agent skill does the export and the import for you, from Claude Code, Cursor, Codex or any other agent that supports Agent Skills.
1

Install the skills

2

Ask your agent

Ask in plain language, for example “Convert my production environment to Terraform”, or run the command with the Console URL of the environment:
To manage several environments in one configuration, name all of them.
3

Review the result

The skill:
  1. Reads the configuration of the environments from the Qovery API.
  2. Writes provider.tf, variables.tf and one .tf file per environment. Secret values go into TF_VAR_ variables or a git-ignored .tfvars file, never into the .tf files.
  3. Runs terraform init, imports every resource and runs terraform plan, which must show no change.
  4. Offers to apply the configuration to a clone of the environment in a test project first, then deletes the clone.
  5. Saves the files with an import script you can run again.
It never runs terraform apply on the original environment without your confirmation, and it flags every managed database, because recreating one deletes its data.
The skill exports services, databases, jobs, Helm charts, Terraform services, deployment stages and variables. Organization-level resources, such as container registries and Helm repositories, come only with the Console export.

After the import

Terraform now manages the exported resources: change them in the configuration, not in the Console. A change made from the Console shows up in the next terraform plan, and the next terraform apply reverts it. Secret values are the exception: the API never returns them, so a secret changed from the Console does not show up in the plan. See How the provider tracks changes. The export only describes the resources. To deploy the environment on terraform apply, add a qovery_deployment resource, as in the basic application example. Destroying that resource, or removing it from the configuration, deletes the environment and its services. Store the state in a remote backend so that your team shares it.

Next steps

Terraform Provider

Set up the provider

Basic Application

Deploy an environment with qovery_deployment

Terraform Registry

Reference of every resource and its import ID

Environment Variables

Variables and secrets

Agent Skills

Install qovery-terraform and the other Qovery skills

Start a New Project

Write the configuration from an empty cloud account instead