Terraform
Use a Terraform registry to host private Terraform modules and providers.
Before you begin
Ensure you have the Terraform CLI (
terraform) installed on your local machine.Access to a Harness account with appropriate permissions to create registries and connectors.
Create a Terraform artifact registry
Go to the Artifact Registry module in your Harness project.
Click New Artifact Registry.
In the Registry Type list, select Terraform.
Enter a Registry Name.
Optionally, add a Description and Labels for better organization.
Choose visibility between Public and Private. By default, the visibility is set to Private.
Select Create Registry to finalize.
Configure an upstream proxy (optional)
An upstream proxy allows your registry to fetch Terraform modules and providers from external Terraform-protocol registries when they are not available locally. The default upstream is registry.terraform.io.
Create an upstream proxy
In the Artifact Registry module, select the dropdown next to New Artifact Registry and select Upstream Proxy.
Select Terraform as the proxy type.
Enter an Upstream Proxy Key.
Optionally, add a Description and Labels.
Select your Source:
Terraform Registry
Custom
If you choose Custom, enter your Remote Registry URL (for example,
https://registry.terraform.io).Choose your Authentication method (
Anonymousby default for public Terraform registries).Click Create Upstream Proxy to establish the connection.
Configure the upstream proxy in your registry
In the Artifact Registry module, select an existing Terraform Artifact Registry.
Go to the Configuration tab.
In the Advanced (Optional) section, click Configure Upstream.
Select from the list of compatible proxies to add them to your registry.
Select Save to save the configuration.
Set up the Terraform client
In your Harness Terraform Artifact Registry, click Set Up Client and follow the instructions to configure Terraform or OpenTofu to use the registry.
Configure a module
1. Generate identity token
In your Harness Terraform Artifact Registry, click Set Up Client.
Click Generate Token to generate an identity token.
2. Configure ~/.terraformrc
Add the following to ~/.terraformrc:
3. Upload module
Upload the module directory to the registry:
4. Use module
Reference the module in your
.tffile:
Run
terraform init.
1. Generate identity token
In your Harness Terraform Artifact Registry, click Set Up Client.
Click Generate Token to generate an identity token.
2. Configure ~/.tofurc
Add the following to ~/.tofurc:
3. Upload module
Upload the module directory to the registry:
4. Use module
Reference the module in your
.tffile:
Run
tofu init.
Configure a provider
1. Generate identity token
In your Harness Terraform Artifact Registry, click Set Up Client.
Click Generate Token to generate an identity token.
2. Configure ~/.terraformrc
Add the following to ~/.terraformrc:
3. Upload provider
Upload a provider binary to the registry:
4. Use provider
Reference the provider in your
.tffile:
Run
terraform init.
1. Generate identity token
In your Harness Terraform Artifact Registry, click Set Up Client.
Click Generate Token to generate an identity token.
2. Configure ~/.tofurc
Add the following to ~/.tofurc:
3. Upload provider
Upload a provider binary to the registry:
4. Use provider
Reference the provider in your
.tffile:
Run
tofu init.
Troubleshooting
Last updated
Was this helpful?