> ## 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](https://docs.nscale.com/docs/manage/service-tokens.md) to authenticate the Terraform provider.

## 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"
    }
  }
}
```

> [!NOTE]
>
> **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.

## Authentication

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

### 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](https://docs.nscale.com/docs/network/vpc-networks.md) |
| `nscale_security_group` | Firewall rules | [Security Groups](https://docs.nscale.com/docs/network/security-groups.md) |
| `nscale_file_storage` | Shared NFS filesystem | [Filesystem](https://docs.nscale.com/docs/storage/file-storage.md) |
| `nscale_compute_instance` | Virtual machines | [Instances](https://docs.nscale.com/docs/compute/create-new-instances.md) |
| `nscale_compute_cluster` | GPU clusters | [Clusters](https://docs.nscale.com/docs/compute/clusters.md) |

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.

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

> [card] [Service Tokens](https://docs.nscale.com/docs/manage/service-tokens.md)
>
> Generate the token used to authenticate the Terraform provider

> [card] [API Reference](https://docs.nscale.com/api-reference/instances/list-instances.md)
>
> The underlying API that the Terraform provider calls

> [card] [Terraform Registry](https://registry.terraform.io/providers/nscaledev/nscale/latest/docs)
>
> Full provider documentation and resource reference

> [card] [GitHub Examples](https://github.com/nscaledev/terraform-provider-nscale/tree/main/examples)
>
> Example Terraform configurations
