get all harness projects using python
set the following in your environment
HARNESS_ACCOUNT_ID
: your harness account id
HARNESS_PLATFORM_API_KEY
: a harness token with orgs and projects read
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 5.0" | |
} | |
harness = { | |
source = "harness/harness" | |
} | |
} |
terraform { | |
required_providers { | |
harness = { | |
source = "harness/harness" | |
} | |
} | |
} | |
provider "harness" {} |
from os import getenv | |
from requests import post | |
HEADERS = {"x-api-key": getenv("HARNESS_PLATFORM_API_KEY")} | |
PARAMS = { | |
"routingId": getenv("HARNESS_ACCOUNT_ID"), | |
"accountIdentifier": getenv("HARNESS_ACCOUNT_ID"), |
A Harness Delegate is a service you run in your kubernetes cluster that monitors usage and gathers metrics.
To install the delegate, we can use Helm with a values file.
Add the Harness Helm repository: helm repo add harness-delegate https://app.harness.io/storage/harness-download/delegate-helm-chart/
Make sure the repo is updated: helm repo update harness-delegate
resource "harness_platform_connector_awscc" "master" { | |
identifier = "master" | |
name = "master" | |
account_id = "759984737373" | |
report_name = "harnessccm" | |
s3_bucket = "harnessccm" | |
features_enabled = [ | |
"BILLING", | |
] |
resource "harness_platform_connector_azure_cloud_cost" "billing" { | |
identifier = "billing" | |
name = "billing" | |
features_enabled = ["BILLING", "VISIBILITY", "OPTIMIZATION"] | |
tenant_id = "b229b2bb-5f33-4d22-bce0-730f6474e906" | |
subscription_id = "e8389fc5-0cb8-44ab-947b-c6cf62552be0" | |
billing_export_spec { | |
storage_account_name = "harnesscostexport" | |
container_name = "harness" |
resource "harness_platform_connector_kubernetes" "cluster-a" { | |
identifier = "cluster_a" | |
name = "cluster-a" | |
inherit_from_delegate { | |
delegate_selectors = ["cluster-a"] | |
} | |
} | |
resource "harness_platform_connector_kubernetes_cloud_cost" "cluster-a-ccm" { |
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: harness-delegate-ng | |
--- | |
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
name: harness-delegate-ng |
from requests import get, put | |
if __name__ == "__main__": | |
harness_account_id = "wlgELJ0TTre5aZhzpt8gVA" | |
harness_platform_api_key = "xxxxxxxxxx" | |
custom_delegate_location = "my_docker_repo/harness/delegate" | |
resp = get( |