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 -
Set up your development environment:
make dev-setup
This installs all Go dependencies and development tools.
-
Build and install the provider locally:
make install
This builds the provider and installs it to your local Terraform plugins directory.
-
Configure Terraform to use your local build by adding this to
~/.terraformrc:provider_installation { dev_overrides { "registry.terraform.io/harness/harness" = "~/.terraform.d/plugins/registry.terraform.io/harness/harness/0.99.0-dev/<OS>_<ARCH>" } direct {} }
Replace
<OS>_<ARCH>with your platform (e.g.,darwin_arm64,linux_amd64). -
To remove the local installation:
make uninstall
make help # Show all available commands
make dev-setup # Set up development environment
make build # Build the provider
make test # Run unit tests
make install # Install provider locallyRun make help to see all available commands. Here's a summary:
| Command | Description |
|---|---|
make build |
Build the provider binary |
make build-all |
Build for all supported platforms (darwin, linux, windows) |
make install |
Build and install to local Terraform plugins directory |
make uninstall |
Remove locally installed provider |
make clean |
Clean build artifacts and Go caches |
make clean-plugins |
Remove all local plugin versions for this provider |
| Command | Description |
|---|---|
make test |
Run unit tests |
make testacc |
Run acceptance tests (requires HARNESS_* env vars) |
make test-coverage |
Run tests with coverage report |
make sweep |
Run sweepers to clean up test resources (use with caution) |
| Command | Description |
|---|---|
make fmt |
Format Go source code |
make fmt-check |
Check if code is properly formatted |
make vet |
Run go vet static analysis |
make lint |
Run golangci-lint |
make check |
Run all code quality checks |
| Command | Description |
|---|---|
make docs |
Generate provider documentation |
make docs-validate |
Validate provider documentation |
make changelog |
Generate changelog from .changelog entries |
| Command | Description |
|---|---|
make deps |
Download and tidy Go dependencies |
make deps-upgrade |
Upgrade all dependencies |
make tools |
Install development tools (tfplugindocs, changelog-build, golangci-lint) |
make dev-setup |
Complete development environment setup |
make version |
Show version information |
make testAcceptance tests create real resources in your Harness account. Set the required environment variables first:
export HARNESS_ACCOUNT_ID="your-account-id"
export HARNESS_API_KEY="your-api-key"
export HARNESS_PLATFORM_API_KEY="your-platform-api-key"
make testaccmake test-coverage
# Opens coverage.html in your browserProvider documentation is auto-generated from schema descriptions:
make docsGenerated docs are placed in the docs/ directory.
Changelog entries are stored in the .changelog/ directory. To generate a new changelog:
make changelogTo add a changelog entry, create a file in .changelog/<PR_NUMBER>.txt:
```release-note:enhancement
resource/harness_platform_connector: Added support for new authentication method
Supported types: `enhancement`, `bug`, `feature`, `new-resource`, `new-data-source`, `breaking-change`, `note`
### Cleaning Up
```sh
# Clean build artifacts
make clean
# Remove all locally installed plugin versions
make clean-plugins
# Remove test resources (sweepers)
make sweep
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Run tests and linting (
make check && make test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open 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.