Skip to content

Instantly share code, notes, and snippets.

View rssnyder's full-sized avatar
🥨
limitless servers in a serverless world

Riley Snyder rssnyder

🥨
limitless servers in a serverless world
View GitHub Profile
@rssnyder
rssnyder / main.tf
Last active February 2, 2024 15:53
harness scheduled autostopping via instance tags
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
harness = {
source = "harness/harness"
}
}
@rssnyder
rssnyder / main.tf
Created October 24, 2023 14:26
harness terraform provider example
terraform {
required_providers {
harness = {
source = "harness/harness"
}
}
}
provider "harness" {}
@rssnyder
rssnyder / main.py
Created October 23, 2023 13:44
create a perspective for a group of aws accounts using python
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"),
@rssnyder
rssnyder / README.md
Last active September 25, 2023 20:12
get a list of harness projects

get all harness projects using python

setup

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

@rssnyder
rssnyder / delegate_install_ccm.md
Last active February 14, 2024 15:04
harness delegate install for ccm

Installing the Harness Delegate for CCM

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

@rssnyder
rssnyder / main.tf
Created August 4, 2023 17:34
harness ccm terraform for aws cost connectors
resource "harness_platform_connector_awscc" "master" {
identifier = "master"
name = "master"
account_id = "759984737373"
report_name = "harnessccm"
s3_bucket = "harnessccm"
features_enabled = [
"BILLING",
]
@rssnyder
rssnyder / main.tf
Created August 4, 2023 17:32
harness ccm terraform for azure cost connectors
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"
@rssnyder
rssnyder / main.tf
Created August 4, 2023 17:29
creating k8s and k8s cost connectors for harness ccm
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" {
@rssnyder
rssnyder / ccm_service_account.yaml
Created July 24, 2023 20:42
creates a namespace, service account, SA token, cluster role and binding for using CCM in a k8s cluster
apiVersion: v1
kind: Namespace
metadata:
name: harness-delegate-ng
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: harness-delegate-ng
@rssnyder
rssnyder / custom_delegate_upgrader_image.py
Created July 24, 2023 18:42
get the latest version of the delegate for your harness account and update the image that the delegate upgrader uses
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(