> ## Documentation Index
> Fetch the complete documentation index at: https://docs.envzero.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Private registry

> Host and manage private Terraform modules and providers in the env zero registry, with automated authorization during deployments and API key access.

env zero offers a private registry solution for both your Terraform [modules](https://docs.envzero.com/guides/admin-guide/private-registry/modules.md) and [providers](https://docs.envzero.com/guides/admin-guide/private-registry/providers.md).

You can access your organization's registry by clicking on the `Registry` link on the side navigation bar:

![Interface screenshot showing configuration options](https://mintcdn.com/envzero-b61043c8/pcx_nh6zT3at7dYL/images/guides/admin-guide/9923c0d-registry.png?fit=max\&auto=format\&n=pcx_nh6zT3at7dYL\&q=85\&s=42fc58173c5bd732e32dcb8aa403f6af)

## Authorization

When running private modules or providers, Terraform will have to authorize you to ensure you have read access to them. When deploying through env zero, we will take care of this authorization for you.

### Local Usage

If you’d like to run Terraform code that uses a private registry, you will need to supply the authentication details to Terraform.

These must be supplied in a file called `terraform.rc` (for Windows) or `~/.terraformrc` (other systems).

#### Manually setting the token

##### Option 1 - Terraform rc file

You can use an API Key (obtained from your [organization's Settings page](https://docs.envzero.com/guides/admin-guide/organizations.md#organization-settings)). The API key must be entered into the terraform rc file like this:

```hcl theme={null}
credentials "api.env0.com" {
  # A valid Basic authentication header value, using your env zero API Key ID and Secret
  token = "Basic base64-encoded(api-key-id:api-key-secret)"
}
```

Here's an example of how to generate your token (in a Mac terminal)

```bash theme={null}
export ENV0_API_KEY={replace with your key}
export ENV0_API_SECRET={replace with your secret}
echo -n $ENV0_API_KEY:$ENV0_API_SECRET | base64 
```

Your \~/.terraformrc should look something like this.

> [!NOTE]
>
> ```bash theme={null}
> cat ~/.terraformrc
> credentials "api.env0.com" {
>   # A valid Basic authentication header value, using your env zero API Key ID and Secret
>   token = "Basic <base64 of API_KEY_ID:API_KEY_SECRET>"
> }
> ```

> [!WARNING]
>
> The .terraformrc file must be stored in the home directory (\~/)

These instructions are also available in the Instructions tab of the module or provider page.

##### Option 2 - TF\_TOKEN\_api\_env0\_com

> [!WARNING]
>
> This setting is only supported for Terraform Version 1.2+

Use an environment variable named `TF_TOKEN_api_env0_com`. You can retrieve the encoded token when you [create a new API key](https://docs.envzero.com/guides/admin-guide/user-role-and-team-management/api-keys.md#how-to-create-an-api-key), or you can generate and assign the API with the following example.  See: [Terraform - Environment Variable Credentials](https://developer.hashicorp.com/terraform/cli/config/config-file#environment-variable-credentials)

```bash theme={null}
export TOKEN=$(echo -n "$ENV0_API_KEY:$ENV0_API_SECRET" | base64)
export TF_TOKEN_api_env0_com=$TOKEN
```

#### Terragrunt Authentication

When using [Terragrunt](https://docs.envzero.com/guides/admin-guide/templates/terragrunt.md), you will also need to set the `TG_TF_REGISTRY_TOKEN` environment variable to the encoded authentication value:

```bash theme={null}
export TOKEN=$(echo -n "$ENV0_API_KEY:$ENV0_API_SECRET" | base64)
export TG_TF_REGISTRY_TOKEN=$TOKEN
```

## Next steps

After you publish modules, [track their adoption](https://docs.envzero.com/guides/admin-guide/private-registry/modules/module-usage.md) across your environments.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.