# Terraform Repositories

Terraform is an infrastructure-as-code (IaC) tool that builds, changes, and versions Cloud and On-Prem resources. For more information, see [Terraform documentation](https://developer.hashicorp.com/terraform/intro).

Nexus Repository provides proxy, hosted (including GPG-signed provider binaries) and group repository support for Terraform modules and providers. This support is available in both Community Edition and Pro. Community Edition uses an H2 database, and Pro uses PostgreSQL. You can publish and retrieve Terraform modules using the Terraform CLI.

## Getting Started

Explore the following topics to know how to configure and use Terraform with Nexus.

1. [Nexus for Terraform](https://help.sonatype.com/en/terraform-repositories.html#nexus-for-terraform "Nexus for Terraform")
2. [Create a Terraform Repository](https://help.sonatype.com/en/create-a-terraform-repository.html "Create a Terraform Repository")
3. [Configure Terraform with Nexus](https://help.sonatype.com/en/configure-registry.html "Configure Terraform with Nexus")
4. [Terraform CLI Usage](https://help.sonatype.com/en/cli-usage-and-options.html "Terraform CLI Usage")

## Nexus for Terraform

### Asset Classification

Nexus Repository classifies Terraform content into two types. This is done to apply right validation, indexing and processing rules.

- **Module**: Versioned source archives retrieved via module registry endpoints such as `versions`, `download`, and `archive.

- **Providers**: Platform-specific binaries, served with checksums and signatures via provider registry endpoints.

Nexus repository classifies Terraform assets using path patterns.

- Paths containing `/modules/` are classified as Module
- Paths containing `/providers/` are classified as Provider

Path-based detection is complemented by extension and location checks. The .zip file under a `/modules/` directory is classified as Module and the .zip file under a `/providers/` directory is classified as Provider.

If an item cannot be classified confidently, the system surfaces a warning or an error to protect repository integrity.

### Capabilities

#### Proxy Capabilities

- New in 3.94 Proxy Terraform providers and modules from [registry.opentofu.org](http://registry.opentofu.org/)
- New in 3.94 Compatible with OpenTofu CLI
- New in 3.94 Proxy Terraform modules from [registry.coder.com](http://registry.coder.com/)
- Proxy Terraform providers and modules from [registry.terraform.io](https://registry.terraform.io/)
- Cache provider binaries (.zip), checksums, signatures and module source archives
- Rewrite upstream metadata so download URLs point to Nexus repository
- Support authentication using URL tokens
- Compatible with Terraform CLI v0.13+ and all 1.x releases

#### Hosted Capabilities

New in 3.89

- Publish Terraform modules as versioned source archives (.tar.gz, .tgz, .txz, .xz, .tar.xz, tar.tbz2, tar.bz2) and platform-specific binaries (.zip)
- Publish Terraform providers as .zip
- Automatically generate provider metadata, checksum files, and GPG signatures
- Support multiple versions and incremental platform uploads for providers
- Control access using repository-level permissions
- Manage repositories and content using the REST API

#### Group Capabilities

New in 3.90

- Aggregate multiple Terraform repositories (hosted/proxy) into one endpoint
- Intelligent caching with configurable TTL for module and provider versions
- Multiple conflict resolution strategies when versions exist in multiple members
- Request deduplication to prevent duplicate queries
- Member health tracking and automatic unhealthy member handling
- Comprehensive metrics for monitoring cache performance and member health
