Terraform provider
Reference for the harness_platform_har_registry Terraform resource: arguments, computed attributes, examples, and import syntax.
The Harness Terraform provider lets you manage Artifact Registry resources as infrastructure as code. This page covers the harness_platform_har_registry resource, which creates and manages both virtual registries and upstream proxies.
Before you begin
Terraform v1.5.0 or later installed.
A Harness API key (Personal Access Token or Service Account Token). Generate one under My Profile > API Keys.
Your account ID, organization ID, and project ID.
Provider configuration
terraform {
required_providers {
harness = {
source = "harness/harness"
version = ">= 0.30.0"
}
}
}
provider "harness" {
endpoint = "https://app.harness.io/gateway"
account_id = var.harness_account_id
platform_api_key = var.harness_platform_api_key
}Store credentials as environment variables rather than hardcoding them:
harness_platform_har_registry
Creates and manages a Harness Artifacts virtual registry or upstream proxy.
Arguments
Required:
identifier
string
Unique registry identifier within the project. Becomes part of the registry URL.
parent_ref
string
Scope of the registry: account_id (account), account_id/org_id (org), or account_id/org_id/project_id (project).
space_ref
string
Same value as parent_ref. Required for creation.
Optional:
description
string
Human-readable description of the registry.
is_public
bool
Make the registry publicly accessible. Default: false. Requires the PL_ALLOW_TO_SET_PUBLIC_ACCESS feature flag.
allowed_pattern
list(string)
Artifact name patterns that are allowed on push. If set, only matching names are accepted.
blocked_pattern
list(string)
Artifact name patterns that are blocked on push. Takes precedence over allowed_pattern.
metadata
map(string)
Custom key-value labels. Keys and values must match [letters, numbers, _ . / = + - @]. Maximum 49 entries.
Computed (read-only):
id
string
Resource ID, assigned by Harness.
created_at
string
ISO 8601 timestamp of when the registry was created.
url
string
Registry URL for client configuration (e.g. https://pkg.harness.io/<account_id>/<identifier>).
config block
The config block defines whether the resource is a client-facing virtual registry or an upstream proxy, and how it behaves.
Required:
type
string
VIRTUAL for a client-facing registry; UPSTREAM for a caching proxy.
Optional:
upstream_proxies
list(string)
Identifiers of upstream proxies to attach. VIRTUAL type only. Order determines resolution priority.
source
string
Upstream source. Required for UPSTREAM type. Values: Dockerhub, MavenCentral, PyPi, Terraform Registry, Custom, and others per package type.
auth_type
string
Top-level auth method: Anonymous or UserPassword. Required for UPSTREAM type.
url
string
Upstream registry URL. Required when type = UPSTREAM and package_type = HELM.
firewall_mode
string
Dependency Firewall enforcement mode: ALLOW (default, Firewall off), ENABLED (audit only), or QUARANTINE (block on violation). Not supported for DOCKER and HELM.
remote_url_suffix
string
Path suffix appended to the upstream URL. Python UPSTREAM with Custom source only. Leading and trailing slashes are normalized.
debian_config
block
Debian-specific index settings. VIRTUAL + DEBIAN type only. Go to config.debian_config block.
config.auth block
Provides credentials for an UPSTREAM registry when auth_type = "UserPassword".
auth_type
string
Required. Must be UserPassword or Anonymous.
user_name
string
Username.
secret_identifier
string
Identifier of the Harness secret that holds the password or token.
secret_space_path
string
Scope where the secret lives: account_id, account_id/org_id, or account_id/org_id/project_id. Defaults to space_ref when empty.
access_key
string
(Sensitive) Raw access key value.
access_key_identifier
string
Identifier of the Harness secret for the access key.
access_key_secret_path
string
Scope of the access key secret.
secret_key_identifier
string
Identifier of the Harness secret for the secret key.
secret_key_secret_path
string
Scope of the secret key secret.
config.debian_config block
Controls Debian repository index generation for VIRTUAL + DEBIAN registries.
remote_indexed_architectures
list(string)
Architectures included in the index. Defaults to ["amd64", "i386", "arm64"].
optional_index_compression_formats
list(string)
Additional compression formats for metadata files, for example, [".xz"].
Examples
Virtual registry
A client-facing registry that stores artifacts directly:
Virtual registry with upstream proxy
Route cache misses through Docker Hub:
Upstream proxy with authenticated access
For private registries or Docker Hub authenticated pulls:
Registry with artifact filtering and metadata
Restrict which artifacts can be pushed and attach labels:
Debian virtual registry with custom index settings
Dependency Firewall in quarantine mode
Block and quarantine artifacts that violate policies on pull:
Import
Import an existing registry into Terraform state using the resource's scope path and identifier.
After import, run terraform plan to confirm there are no unexpected diffs before applying changes.
Supported package types
Valid values for the package_type argument:
DOCKER
Docker container images
HELM
OCI-compliant Helm charts
HELM_HTTP
HTTP (non-OCI) Helm charts
MAVEN
Maven artifacts
PYTHON
Python / PyPI packages
NPM
npm packages
NUGET
NuGet / .NET packages
GENERIC
Generic / Raw files
RPM
RPM packages
CARGO
Cargo (Rust) packages
GO
Go modules
CONDA
Conda packages
DEBIAN
Debian / APT packages
ALPINE
Alpine / APK packages
WOLFI
Wolfi APK packages
CONAN
Conan (C/C++) packages
RUBY
RubyGems
TERRAFORM
Terraform modules and providers
TERRAFORM_BACKEND
Terraform state backend
CRAN
R / CRAN packages
COMPOSER
PHP Composer packages
DART
Dart packages
SWIFT
Swift packages
HUGGINGFACE
Hugging Face models and datasets
PUPPET
Puppet modules
RAW
Raw file storage
Troubleshooting
Next steps
Harness Terraform provider on the Terraform Registry
Last updated
Was this helpful?