The Terraform provider for Harness allows you to manage resources in Harness CD and NextGen platforms using infrastructure as code. This provider enables you to automate the provisioning and management of Harness resources such as applications, pipelines, environments, services, connectors, and more.
- First Generation & NextGen Support: Manage resources in both Harness First Generation and NextGen platforms
- Comprehensive Resource Management: Create and manage applications, pipelines, environments, services, connectors, and more
- GitOps Integration: Configure GitOps applications, repositories, and clusters
- Policy Management: Define and enforce governance policies and policy sets
- Feature Flag Management: Configure and manage feature flags for your applications
- AutoStopping Rules: Set up cost optimization with AutoStopping rules for various cloud providers
Full, comprehensive documentation is available on the Terraform Registry website:
terraform {
required_providers {
harness = {
source = "harness/harness"
version = "0.38.5"
}
}
}
# Configure the Harness provider for First Gen resources
provider "harness" {
endpoint = "https://app.harness.io/gateway"
account_id = "YOUR_HARNESS_ACCOUNT_ID"
api_key = "YOUR_HARNESS_API_KEY"
}
# Configure the Harness provider for Next Gen resources
provider "harness" {
endpoint = "https://app.harness.io/gateway"
account_id = "YOUR_HARNESS_ACCOUNT_ID"
platform_api_key = "YOUR_HARNESS_PLATFORM_API_KEY"
}
The provider is available on the Terraform Registry and will be automatically downloaded when you run terraform init
in a configuration that requires it.
-
Clone the repository:
git clone https://github.com/harness/terraform-provider-harness.git cd terraform-provider-harness
-
Install dependencies:
go mod tidy
-
Build the provider:
go build -o terraform-provider-harness
-
Create a file called
local.sh
in the root directory with the following content:#!/bin/sh version=0.40.2 # Specify in this format source=registry.terraform.io/harness/harness platform=darwin_amd64 # Use darwin_arm64 for Apple Silicon based Mac mkdir -p ~/.terraform.d/plugins/$source/$version/$platform/ cp terraform-provider-harness ~/.terraform.d/plugins/$source/$version/$platform/terraform-provider-harness
-
Make the script executable and run it:
chmod +x local.sh ./local.sh
- Update the Terraform CLI configuration file (
.terraformrc
on macOS/Linux,terraform.rc
on Windows):provider_installation { dev_overrides { "registry.terraform.io/harness/harness" = "/path/to/terraform-provider-harness" } direct {} }
Note: Ensure the terraform provider version in your configuration matches the version in the local.sh
script.
Contributions are welcome! Please feel free to submit a Pull Request.
If you have any questions or need assistance:
- Open a new issue
- Join our Slack community
- Visit our documentation
This project is licensed under the terms of the LICENSE file.