# Terraform mirror (pkg.shecan.ir)

> Mirror for Terraform and HashiCorp tools: a provider network mirror for registry.terraform.io providers (/providers/, provider_installation network_mirror), releases.hashicorp.com (Terraform, Vault, Packer, Consul, Nomad, ... zips, SHA256SUMS and signatures) at the host root with the same paths, and the HashiCorp apt (/apt) and dnf (/rpm) repositories.

- Upstream: registry.terraform.io, releases.hashicorp.com, apt.releases.hashicorp.com, rpm.releases.hashicorp.com
- Mirror URLs: <https://mirror-hashicorp.pkg.shecan.ir/providers/>, <https://mirror-hashicorp.pkg.shecan.ir/terraform/>, <https://mirror-hashicorp.pkg.shecan.ir/apt>, <https://mirror-hashicorp.pkg.shecan.ir/rpm/RHEL/hashicorp.repo>
- Clients: terraform, curl, apt, dnf
- Service status: <https://pkg.shecan.ir/status.json> (key `hashicorp`; up/down, refreshed every minute)
- Guide (Persian, HTML): <https://pkg.shecan.ir/mirrors/hashicorp/>
- JSON: <https://pkg.shecan.ir/api/v1/mirrors/hashicorp.json>
- Integrity comparison with the official source (audit.shecan.ir, also run by Shecan, open source; group `hashicorp`, mirror `shecan`): <https://audit.shecan.ir/#hashicorp>

## Limitations

- Providers only: modules from the public Terraform registry (registry.terraform.io module sources) are not served.
- Archives of hashicorp/* providers come from the mirror; third-party providers whose archives are published on GitHub releases are downloaded from GitHub directly, checked against the registry's SHA-256.
- Through a network mirror Terraform records only the current platform's checksum in .terraform.lock.hcl; add other platforms with terraform providers lock -net-mirror=https://mirror-hashicorp.pkg.shecan.ir/providers/ -platform=....
- OpenTofu does not need this mirror (registry.opentofu.org and its GitHub downloads are reachable); the mirror answers for registry.opentofu.org providers too.
- Read-only. HCP Terraform (app.terraform.io), api.releases.hashicorp.com and checkpoint-api.hashicorp.com are not proxied; the all-products /index.json is not served.

## Setup

Every block below is the exact text of the Persian guide. Unless marked otherwise it is run against the live mirror in a disposable container on every catalog change; "checked by hand" blocks cannot run in a container. Change a machine only with its owner's permission: back up existing configuration first, merge into existing files instead of overwriting them, and keep the "Undo" step at hand.

### terraform: persistent (user- or system-wide configuration)

Configuration file (linux, macos): `~/.terraformrc`

```hcl
provider_installation {
  network_mirror {
    url     = "https://mirror-hashicorp.pkg.shecan.ir/providers/"
    include = ["registry.terraform.io/*/*"]
  }
  direct {
    exclude = ["registry.terraform.io/*/*"]
  }
}
```

Undo / restore the default (linux, macos)

```sh
mv ~/.terraformrc ~/.terraformrc.shecan-off
```

Configuration file (windows): `%APPDATA%\terraform.rc` (checked by hand)

```hcl
provider_installation {
  network_mirror {
    url     = "https://mirror-hashicorp.pkg.shecan.ir/providers/"
    include = ["registry.terraform.io/*/*"]
  }
  direct {
    exclude = ["registry.terraform.io/*/*"]
  }
}
```

### terraform: project (files inside the project)

Run

```sh
terraform providers lock -net-mirror=https://mirror-hashicorp.pkg.shecan.ir/providers/ -platform=linux_amd64 -platform=darwin_arm64 -platform=windows_amd64
```

### curl: persistent (user- or system-wide configuration)

Run (linux)

```sh
curl -fLO https://mirror-hashicorp.pkg.shecan.ir/terraform/1.17.0/terraform_1.17.0_linux_amd64.zip
curl -fLO https://mirror-hashicorp.pkg.shecan.ir/terraform/1.17.0/terraform_1.17.0_SHA256SUMS
sha256sum -c --ignore-missing terraform_1.17.0_SHA256SUMS
unzip -o terraform_1.17.0_linux_amd64.zip terraform
sudo install -m 755 terraform /usr/local/bin/terraform
```

### apt: persistent (user- or system-wide configuration)

Run, Ubuntu or Debian (linux)

```sh
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSLo /etc/apt/keyrings/hashicorp.asc https://mirror-hashicorp.pkg.shecan.ir/apt/gpg
. /etc/os-release
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/hashicorp.asc] https://mirror-hashicorp.pkg.shecan.ir/apt $VERSION_CODENAME main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt install -y terraform
```

Undo / restore the default, Ubuntu or Debian (linux)

```sh
sudo rm -f /etc/apt/sources.list.d/hashicorp.list /etc/apt/keyrings/hashicorp.asc
sudo apt update
```

### dnf: persistent (user- or system-wide configuration)

Run, EL 8/9/10 (linux)

```sh
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://mirror-hashicorp.pkg.shecan.ir/rpm/RHEL/hashicorp.repo
sudo dnf -y install terraform
```

Undo / restore the default, EL 8/9/10 (linux)

```sh
sudo rm -f /etc/yum.repos.d/hashicorp.repo
sudo dnf clean all
```

Run, Fedora 43 (linux)

```sh
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager addrepo --from-repofile=https://mirror-hashicorp.pkg.shecan.ir/rpm/fedora/hashicorp.repo
sudo dnf -y install terraform
```

Undo / restore the default, Fedora 43 (linux)

```sh
sudo rm -f /etc/yum.repos.d/hashicorp.repo
sudo dnf clean all
```
