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

# Terraform Provider

The Nscale Terraform provider lets you define and provision Nscale infrastructure as code. Declare your resources in `.tf` files, run `terraform plan` to preview changes, and `terraform apply` to create them. Use it for repeatable, version-controlled provisioning of VPCs, instances, clusters, security groups, and filesystems.

<Note>
  **Prerequisite:** You need a [service token](/docs/manage/service-tokens) to authenticate the Terraform provider.
</Note>

## Quick Start

The provider is distributed via the Terraform Registry as `nscaledev/nscale`. Declare it in your `required_providers` block:

```hcl theme={null}
terraform {
  required_providers {
    nscale = {
      source = "nscaledev/nscale"
      # Check the Terraform Registry or GitHub Releases for the latest version.
      # version = "~> 0.0.8"
    }
  }
}
```

<Info>
  **Pin your provider version** in production to avoid unexpected changes when new versions are released. Use `version = "~> 0.0.8"` (or your current version) in the `required_providers` block.
</Info>

## Authentication

The provider authenticates with Nscale using a service token, which you can generate and rotate in the [Nscale Console](/docs/manage/service-tokens).

### Environment Variables

The recommended way to configure the provider is via environment variables. This avoids hard-coding credentials in your `.tf` files:

```bash theme={null}
export NSCALE_REGION_ID="<your-region-id>"
export NSCALE_ORGANIZATION_ID="<your-organization-id>"
export NSCALE_PROJECT_ID="<your-project-id>"
export NSCALE_SERVICE_TOKEN="<your-service-token>"
```

Alternatively, you can configure the provider block directly (not recommended for production):

```hcl theme={null}
provider "nscale" {
  # Recommended: supply these values via environment variables, not hard-coded here.

  # region_id       = "<your-region-id>"
  # organization_id = "<your-organization-id>"
  # project_id      = "<your-project-id>"
  # service_token   = "<your-service-token>"
}
```

## Supported Resources

The following table maps Terraform resource types to their corresponding console pages:

| Terraform Resource        | Description           | Console Page                                     |
| ------------------------- | --------------------- | ------------------------------------------------ |
| `nscale_network`          | VPC networks          | [VPC Networks](/docs/network/vpc-networks)       |
| `nscale_security_group`   | Firewall rules        | [Security Groups](/docs/network/security-groups) |
| `nscale_file_storage`     | Shared NFS filesystem | [Filesystem](/docs/storage/file-storage)         |
| `nscale_compute_instance` | Virtual machines      | [Instances](/docs/compute/create-new-instances)  |
| `nscale_compute_cluster`  | GPU clusters          | [Clusters](/docs/compute/clusters)               |

More resources are planned for future releases.

<Warning>
  **`terraform destroy` deletes real infrastructure.** Always review the plan output before confirming a destroy operation. Resources deleted via Terraform are permanently removed just as if you deleted them in the console.
</Warning>

## Documentation

Full documentation for the provider is available on the [Terraform Registry](https://registry.terraform.io/providers/nscaledev/nscale/latest/docs), and you can find [examples](https://github.com/nscaledev/terraform-provider-nscale/tree/main/examples) in the GitHub repository.

***

## Related Resources

<CardGroup cols={2}>
  <Card title="Service Tokens" icon="key" href="/docs/manage/service-tokens">
    Generate the token used to authenticate the Terraform provider
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/instances/list-instances">
    The underlying API that the Terraform provider calls
  </Card>

  <Card title="Terraform Registry" icon="cube" href="https://registry.terraform.io/providers/nscaledev/nscale/latest/docs">
    Full provider documentation and resource reference
  </Card>

  <Card title="GitHub Examples" icon="github" href="https://github.com/nscaledev/terraform-provider-nscale/tree/main/examples">
    Example Terraform configurations
  </Card>
</CardGroup>
