> ## 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.

# Terraform Provider

> Manage Control Plane resources as infrastructure-as-code using the official Terraform provider with HCL configuration.

The Control Plane Terraform provider lets you manage Control Plane resources as code using HashiCorp Configuration Language (HCL).

<Card title="Terraform Registry" icon="arrow-up-right-from-square" href="https://registry.terraform.io/providers/controlplane-com/cpln/latest">
  View the official Control Plane provider on the Terraform Registry for full documentation, resources, and data sources.
</Card>

## Setup

Add the Control Plane provider to your Terraform configuration:

```hcl theme={null}
terraform {
  required_providers {
    cpln = {
      source = "controlplane-com/cpln"
    }
  }
}

provider "cpln" {
  # Required
  # Can use CPLN_ORG Environment Variable
  org = var.org

  # Optional
  # Default Value: https://api.cpln.io
  # Can use CPLN_ENDPOINT Environment Variable
  endpoint = var.endpoint

  # Optional
  # Can use CPLN_PROFILE Environment Variable
  profile = var.profile

  # Optional
  # Can use CPLN_TOKEN Environment Variable
  token = var.token

  # Optional
  # Can use CPLN_REFRESH_TOKEN Environment Variable
  refresh_token = var.refresh_token
}
```

Then initialize your project:

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

<Note>Requires Terraform 0.13+</Note>

## Resources

* [Download Terraform CLI](https://www.terraform.io/downloads.html)
* [Terraform Documentation](https://www.terraform.io/docs/index.html)

## Upgrading Provider Version

After installing a new provider version, follow these steps to upgrade an existing installation:

1. Update the version property inside the HCL file that contains the `required_providers` declaration block for the `cpln` provider.

2. Run the command: `terraform init -upgrade` to upgrade the Terraform dependencies (state file, etc.). The Terraform commands (plan, apply, etc.) will now use the latest version.

<Note>
  If necessary, the provider version can be downgraded.
</Note>

## Examples

* [Terraform - Control Plane Examples](https://github.com/controlplane-com/examples/tree/main/terraform)
