Cache with PVC

This page explains how to enable plugin caching for OpenTofu (also applies to Terraform and Terragrunt) when using a Self-Hosted Kubernetes Agent with Persistent Volume Claims (PVC). This feature is available for SHAG (Self-Hosted Agent on Kubernetes) customers only.

Overview

To improve performance in infrastructure-as-code environments, env0 supports an optional plugin cache. This cache stores previously downloaded provider plugins on a persistent volume, allowing reuse across runs within the same environment. The plugin cache can reduce run times and avoid redundant downloads when enabled.

This caching mechanism is opt-in and requires specific environment variables. It is supported only for environments running with a self-hosted Kubernetes agent that uses PVC.

Enabling Plugin Cache

To enable the plugin cache, set the following environment variable:

ENV0_USE_TF_PLUGIN_CACHE=true

When this variable is set, env0 will use a persistent volume to cache provider plugins used by OpenTofu, Terraform, or Terragrunt. These plugins will then be reused in subsequent runs within the same environment

Wiping the Cache

If you need to wipe the plugin cache before a run (for example, to force re-downloading of providers or resolve potential cache issues), set the following additional environment variable:

ENV0_WIPE_TF_PLUGIN_CACHE=true

📘

Note: This variable only takes effect if ENV0_USE_TF_PLUGIN_CACHE is also set.

When both variables are set, the plugin cache will be cleared before the run begins.

🚧

Requirements

  • Self-Hosted Kubernetes Agent (SHAG)
  • Use of Persistent Volume Claims (PVC) for storage
  • Applies to environments using OpenTofu, Terraform, or Terragrunt