> ## Documentation Index
> Fetch the complete documentation index at: https://docs.controlplane.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Install and Manage using Terraform

> Install, upgrade, and manage Control Plane Template Catalog releases using the Terraform provider. Covers prerequisites, cpln_catalog_template resource configuration, and lifecycle management.

## Prerequisites

<AccordionGroup>
  <Accordion title="Terraform installed">
    Install [Terraform](https://www.terraform.io/downloads.html) (v0.13+).
  </Accordion>

  <Accordion title="Control Plane provider configured">
    Add the [Control Plane provider](https://registry.terraform.io/providers/controlplane-com/cpln/latest/docs/resources/catalog_template) to your Terraform configuration. See [Terraform Provider](/iac/terraform) for setup instructions.
  </Accordion>
</AccordionGroup>

## Install a Template

Use the `cpln_catalog_template` resource to install a template from the catalog.

<Steps>
  <Step title="Choose a Template">
    Browse the available templates in the [Template Catalog](/template-catalog/overview#available-templates) and identify the template name and version you want to install.
  </Step>

  <Step title="Add a Values File">
    Create a `values.yaml` file in your Terraform project directory with the template's configuration. Refer to the specific template's documentation for available options.
  </Step>

  <Step title="Define the Resource">
    Add a `cpln_catalog_template` resource to your Terraform configuration, referencing the values file:

    ```hcl main.tf theme={null}
    resource "cpln_catalog_template" "example" {
      name     = "my-release"
      template = "postgres"
      version  = "1.0.0"
      gvc      = "my-gvc"
      values   = file("${path.module}/values.yaml")
    }
    ```

    Arguments:

    * **name** — A unique release name for this installation.
    * **template** — The name of the catalog template (e.g., `cockroachdb`).
    * **version** — The template version to install.
    * **gvc** — The GVC to deploy to. Leave empty if the template creates its own GVC.
    * **values** — YAML-formatted string to customize the template configuration.
  </Step>

  <Step title="Apply">
    Initialize and apply the configuration:

    ```bash theme={null}
    terraform init
    terraform plan
    terraform apply
    ```

    Terraform will provision the required Control Plane resources based on your configuration.
  </Step>
</Steps>

### Outputs

After applying, the resource exposes a `resources` attribute containing a list of all Control Plane resources created by the release. Each entry includes:

* **kind** — The resource type (e.g., `workload`, `secret`, `gvc`).
* **name** — The resource name.
* **link** — The full Control Plane URL for the resource.

## Manage a Template

### Upgrade

To upgrade a release with new values or a new template version, update the `version` argument and/or your `values.yaml` file and re-apply:

```bash theme={null}
terraform plan
terraform apply
```

<Note>
  Any workloads affected by the change will roll out new deployments. Unchanged items will not be redeployed.
</Note>

### Preview Changes

Use `terraform plan` to preview the changes that will be applied before upgrading:

```bash theme={null}
terraform plan
```

## Uninstall a Template

Remove the `cpln_catalog_template` resource from your configuration and apply:

```bash theme={null}
terraform plan
terraform apply
```

Alternatively, destroy the specific resource:

```bash theme={null}
terraform destroy -target=cpln_catalog_template.example
```
