Skip to content

Caching proxy for OpenTofu/Terraform providers - #454

Open
RustyRien wants to merge 1 commit into
mainfrom
tf_proxy
Open

RustyRien wants to merge 1 commit into
mainfrom
tf_proxy

Conversation

@RustyRien

Copy link
Copy Markdown
Member

Provider proxy: caching proxy for OpenTofu/Terraform providers

Every task runs tofu init in a new workspace, and on-demand workers start with an empty plugin cache, so the same providers are downloaded over and over. This adds a small caching proxy that downloads each provider version once and serves it to all workers.

Changes

  • provider-proxy/: a standalone app that doesn't depend on InfraKitchen (no database, no shared code). It implements the provider network mirror protocol and stores files on disk. If a file exists it is served; otherwise it is fetched from the registry, saved, then served. Zips are checked against the registry shasum. Includes tests and a README.
  • Workers: new TF_PROVIDER_MIRROR_URL setting, off by default. When set, each task writes a CLI config (TF_CLI_CONFIG_FILE) that installs registry.opentofu.org and registry.terraform.io providers through the proxy. Providers from other registries are installed directly. A TF_CLI_CONFIG_FILE already in the task env is kept.
  • CA certificates: SSL_CERT_FILE / SSL_CERT_DIR are passed to tofu, so workers can trust the proxy's internal CA. tofu accepts only HTTPS mirrors.
  • Kubernetes example: proxy Deployment, Service, PVC and a cert-manager Certificate. The proxy is reachable only through cluster DNS.
  • Dev: nix develop runs the proxy on https://localhost:8090 with a self-signed certificate. Set PROVIDER_PROXY_PORT=0 to turn it off.

Notes

  • With the proxy enabled, providers from the public registries are installed only through it, so init fails while the proxy is down.

Comment thread provider-proxy/app.py Fixed
Comment thread provider-proxy/app.py Fixed
Comment thread provider-proxy/app.py Fixed
Comment thread provider-proxy/app.py Fixed
Comment thread provider-proxy/app.py Fixed
Comment thread provider-proxy/app.py Fixed
Comment thread provider-proxy/app.py Fixed
Comment thread provider-proxy/app.py Fixed
Comment thread provider-proxy/app.py Fixed
Comment thread provider-proxy/app.py Fixed
@RustyRien
RustyRien force-pushed the tf_proxy branch 2 times, most recently from ac80792 to f8b50cb Compare November 13, 2026 17:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants