# Terraform configuration file (~/.terraformrc)
# Documentation: https://www.terraform.io/docs/commands/cli-config.html

# Enable plugin cache to avoid downloading the same providers repeatedly
# This significantly speeds up 'terraform init' across different projects.
plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"

# Disable checkpoint to prevent Terraform from calling home for version checks
checkpoint_disable = false

# Disable
disable_checkpoint_signature = false

provider_installation {
  "filesystem_mirror" {
    include = ["hashicorp/*"]
    exclude = ["registry.terraform.io/*/*", "registry.opentofu.org/*/*"]
    path    = "$HOME/.terraform.d/mirror"
  }
  "filesystem_mirror" {
    include = ["registry.terraform.io/*/*", "registry.opentofu.org/*/*"]
    path    = "$HOME/.terraform.d/plugin-cache"
  }
  "direct" {
    exclude = ["registry.terraform.io/*/*", "registry.opentofu.org/*/*"]
  }
}

# terraform providers mirror ${HOME}/.terraform.d/mirror
host "registry.terraform.io" {
  services = {
    "modules.v1"   = "https://registry.terraform.io/v1/modules/"
    "providers.v1" = "http://127.0.0.1:52008/v1/providers//registry.terraform.io/"
  }
}
host "registry.opentofu.org" {
  services = {
    "modules.v1"   = "https://registry.opentofu.org/v1/modules/"
    "providers.v1" = "http://127.0.0.1:52008/v1/providers//registry.opentofu.org/"
  }
}

# Optional: Credential helpers or provider mirrors can be configured below
# credentials "app.terraform.io" {
#   token = "xxxxxx"
# }
