### Setup Proxy on RedHat VM Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/optimize-cloud-costs-with-intelligent-cloud-auto-stopping-rules/autostopping-rules This script installs and configures the necessary components for the Harness AutoStopping proxy on a RedHat-based system. It includes setting up firewalld, installing Envoy, and configuring the proxy services. ```shell #!/bin/bash set -e set -o nounset sudo su echo "Installing and configuring firewalld" dnf install -y firewalld systemctl start firewalld systemctl enable firewalld echo "Initiate exposing ports" firewall-cmd --permanent --add-port=80/tcp firewall-cmd --permanent --add-port=443/tcp firewall-cmd --reload echo "Upgrading packages" yum update -y echo "Install required packages" yum install -y gnupg2 curl zip wget echo "Installing envoy" rm -rf /usr/share/keyrings/getenvoy-keyring.gpg mkdir -p /usr/share/keyrings curl -sL 'https://deb.dl.getenvoy.io/public/gpg.8115BA8E629CC074.key' | sudo gpg --dearmor -o /usr/share/keyrings/getenvoy-keyring.gpg echo a077cb587a1b622e03aa4bf2f3689de14658a9497a9af2c427bba5f4cc3c4723 /usr/share/keyrings/getenvoy-keyring.gpg | sha256sum --check wget -O /usr/bin/envoy https://github.com/envoyproxy/envoy/releases/download/v1.31.0/envoy-1.31.0-linux-x86_64 echo "Downloaded envoy" chmod +x /usr/bin/envoy mkdir -p /var/lw_proxy/ echo 'accessPointID="" apiURL="" proxyPort=8093 usageTrackingPort=8094 authToken="{REPLACE_WITH_ACCESS_TOKEN}" accountID="{REPLACE_WITH_ACCOUNT_ID}"' > /var/lw_proxy/config.toml echo "Generated config file" wget -O /var/lw_proxy/envoy.zip "https://lightwing-downloads-temp.s3.ap-south-1.amazonaws.com/autostopping-custom-lb-3.0.0.zip" unzip -o /var/lw_proxy/envoy.zip -d /var/lw_proxy sed -i 's|/var/lw_proxy/envoyproxymanager|/usr/bin/envoyproxymanager|g' /var/lw_proxy/lw_proxy.service cp /var/lw_proxy/envoyproxymanager /usr/bin/envoyproxymanager chmod +x /usr/bin/envoyproxymanager echo "Downloaded proxy manager components" wget -O /var/lw_proxy/tcp_proxy.zip "https://lightwing-downloads-temp.s3.ap-south-1.amazonaws.com/autostopping-tcp-proxy-3.4.zip" unzip -o /var/lw_proxy/tcp_proxy.zip -d /var/lw_proxy sed -i 's|/var/lw_proxy/tcpproxymanager|/usr/bin/tcpproxymanager|g' /var/lw_proxy/lw_tcp_proxy.service cp /var/lw_proxy/tcpproxymanager /usr/bin/tcpproxymanager chmod +x /usr/bin/tcpproxymanager echo "Setup proxy executables" cp /var/lw_proxy/envoy.service /etc/systemd/system/envoy.service cp /var/lw_proxy/lw_proxy.service /etc/systemd/system/lw_proxy.service cp /var/lw_proxy/lw_tcp_proxy.service /etc/systemd/system/lw_tcp_proxy.service echo "Starting proxy services" systemctl daemon-reload sudo systemctl enable envoy.service sudo systemctl enable lw_proxy.service sudo systemctl enable lw_tcp_proxy.service systemctl start envoy.service systemctl start lw_proxy.service systemctl start lw_tcp_proxy.service ``` -------------------------------- ### Install ECG on UNIX Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/configure-ecg-for-auto-stopping-rules Make the installation script executable and run it as root to install ECG. ```Shell cat install.sh chmod +x install.sh sudo ./install.sh ``` -------------------------------- ### Example Pod Cost Calculation Source: https://developer.harness.io/docs/cloud-cost-management/get-started/key-concepts Illustrates pod cost calculation using specific pod and node resource values, and an example hourly node price. ```text Pod Resources = (cpuUnits: 1024, memoryMB: 4096) Node Resource = (cpuUnits: 4096, memoryMB: 15360) n1-standard-4 Node Resource = (cpuUnits: 4096, memoryMB: 15360) n1-standard-4 Pod cost = ((1024/4096)  * 0.095 ) + ((4096/15360)) *  0.095) = 0.0490833333 ``` -------------------------------- ### Install Sample Nginx Application for Kubernetes Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/kubernetes-autostopping-quick-start-guide Apply this YAML configuration to your Kubernetes cluster to install a sample nginx application. This application is used to test AutoStopping rules. ```yaml apiVersion: v1 kind: Namespace metadata: name: autostopping-sample --- apiVersion: apps/v1 kind: Deployment metadata: name: autostopping-sample-app namespace: autostopping-sample labels: app: autostopping-sample-app spec: replicas: 1 selector: matchLabels: app: autostopping-sample-app template: metadata: labels: app: autostopping-sample-app spec: containers: - name: autostopping-sample-app image: nginx:1.14.2 ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: autostopping-sample-svc namespace: autostopping-sample spec: selector: app: autostopping-sample-app ports: - protocol: TCP port: 80 targetPort: 80 ``` -------------------------------- ### Commitment Orchestrator Setup IAM Permissions Source: https://developer.harness.io/docs/cloud-cost-management/feature-permissions These permissions are required to enable the actual setup flow for the Commitment Orchestrator. ```json "ec2:PurchaseReservedInstancesOffering", "ec2:GetReservedInstancesExchangeQuote", "ec2:DescribeInstanceTypeOfferings", "ec2:AcceptReservedInstancesExchangeQuote", "ec2:DescribeReservedInstancesModifications", "ec2:ModifyReservedInstances", "ce:GetCostAndUsage", savingsplans:DescribeSavingsPlansOfferings, savingsplans:CreateSavingsPlan ``` -------------------------------- ### Download ECG for UNIX Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/configure-ecg-for-auto-stopping-rules Download the ECG installation file for Linux AMD64 architecture using wget. ```Shell wget https://lightwing-downloads-temp.s3.ap-south-1.amazonaws.com/ecg/ecg_1.2.0_linux_amd64.zip ``` -------------------------------- ### Install ECG as a Windows Service Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/configure-ecg-for-auto-stopping-rules Installs the Harness Autostopping ECG executable as a Windows service. This allows ECG to run in the background and monitor user sessions automatically. ```powershell .\harness_autostop_ecg_windows_amd64.exe install ``` -------------------------------- ### Configure ECG TOML File Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/configure-ecg-for-auto-stopping-rules Example configuration for the ECG TOML file, including account ID, rule hostname, and optional process and metrics watchers. ```TOML accountID = "abcdSmUISimoRrJL6NL12w" ruleHostName = "fluent-katydid-c6p67ucpv2dpsb76i66g.schedules-ce-dev.lightwingtest.com" [process] condition = "trainmodel.py" [metrics] cpu = "50" memory = "1Gb" ``` -------------------------------- ### Setup Terraform Providers and Locals Source: https://developer.harness.io/docs/cloud-cost-management/kb-reference-architecture/best-practices/k8s/k8s-and-ccm-k8s-connectors Configure the Harness Terraform provider and define cluster names using the locals block. This setup is required before creating connectors. ```terraform terraform { required_providers { harness = { source = "harness/harness" } } } provider "harness" {} locals { cluster_names = toset(["cluster-a", "cluster-b", "cluster-c"]) } ``` -------------------------------- ### Cloud-init Configuration for RedHat VM Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/optimize-cloud-costs-with-intelligent-cloud-auto-stopping-rules/autostopping-rules This cloud-config script is used to prepare a RedHat VM for the AutoStopping proxy setup. It ensures user scripts are executed during the finalization stage. ```yaml #cloud-config cloud_final_modules: - [scripts-user, always] ``` -------------------------------- ### Run Python Script for Process Watcher Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/configure-ecg-for-auto-stopping-rules Example of a Python script that might be monitored by the Process Watcher. ```Shell > python trainmodel.py ``` -------------------------------- ### Cloud-Init Script for Ubuntu AMIs Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/optimize-cloud-costs-with-intelligent-cloud-auto-stopping-rules/autostopping-rules This script is used for Ubuntu AMIs to set up the Harness cloud auto-stopping rules. It installs necessary packages, downloads and configures Envoy, and sets up systemd services for proxy management. ```shell Content-Type: multipart/mixed; boundary="//" MIME-Version: 1.0 --// Content-Type: text/cloud-config; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config.txt" #cloud-config cloud_final_modules: [scripts-user, always] --// Content-Type: text/x-shellscript; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="userdata.txt" #!/bin/bash set -e set -o nounset sudo su apt update apt install -y apt-transport-https gnupg2 curl lsb-release zip wget rm -rf /usr/share/keyrings/getenvoy-keyring.gpg curl -sL 'https://deb.dl.getenvoy.io/public/gpg.8115BA8E629CC074.key' | sudo gpg --dearmor -o /usr/share/keyrings/getenvoy-keyring.gpg echo a077cb587a1b622e03aa4bf2f3689de14658a9497a9af2c427bba5f4cc3c4723 /usr/share/keyrings/getenvoy-keyring.gpg | sha256sum --check echo "deb [arch=amd64 signed-by=/usr/share/keyrings/getenvoy-keyring.gpg] https://deb.dl.getenvoy.io/public/deb/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/getenvoy.list apt update wget -O /usr/bin/envoy https://github.com/envoyproxy/envoy/releases/download/v1.31.0/envoy-1.31.0-linux-x86_64 chmod +x /usr/bin/envoy mkdir -p /var/lw_proxy/ echo 'accessPointID="" apiURL="" proxyPort=8093 usageTrackingPort=8094 authToken="" accountID=""' > /var/lw_proxy/config.toml wget -O /var/lw_proxy/envoy.zip "https://lightwing-downloads-temp.s3.ap-south-1.amazonaws.com/autostopping-custom-lb-3.1.0.zip" unzip -o /var/lw_proxy/envoy.zip -d /var/lw_proxy chmod +x /var/lw_proxy/envoyproxymanager wget -O /var/lw_proxy/tcp_proxy.zip "https://lightwing-downloads-temp.s3.ap-south-1.amazonaws.com/autostopping-tcp-proxy-3.4.zip" unzip -o /var/lw_proxy/tcp_proxy.zip -d /var/lw_proxy chmod +x /var/lw_proxy/tcpproxymanager cp /var/lw_proxy/envoy.service /etc/systemd/system/envoy.service cp /var/lw_proxy/lw_proxy.service /etc/systemd/system/lw_proxy.service cp /var/lw_proxy/lw_tcp_proxy.service /etc/systemd/system/lw_tcp_proxy.service systemctl daemon-reload sudo systemctl enable envoy.service sudo systemctl enable lw_proxy.service sudo systemctl enable lw_tcp_proxy.service systemctl start envoy.service systemctl start lw_proxy.service systemctl start lw_tcp_proxy.service --//-- ``` -------------------------------- ### Embed Tango Video Guide Source: https://developer.harness.io/docs/hdh/style-guide Use this format to embed Tango video guides into documentation using the DocVideo plugin. Ensure the src attribute points to the correct Tango embed link. ```html ``` -------------------------------- ### Example Cloud Custodian Policy for EBS Volume Migration Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-governance/asset-governance/asset-governance This example demonstrates a Cloud Custodian policy to find all gp2 EBS volumes and migrate them to the gp3 type. It includes the resource type, filters, and actions. ```yaml policies: - name: "migrate-ebs-to-gp3" resource: "aws_ebs_volume" filters: - "type": "gp2" actions: - "type": "modify-volume" type: "gp3" ``` -------------------------------- ### Cloud-Init Script for Amazon Linux AMI Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/optimize-cloud-costs-with-intelligent-cloud-auto-stopping-rules/autostopping-rules This script is for Amazon Linux AMIs to configure the Harness cloud auto-stopping rules. It updates packages, installs dependencies, downloads Envoy, and sets up the necessary proxy components and systemd services. ```shell Content-Type: multipart/mixed; boundary="==BOUNDARY==" MIME-Version: 1.0 --==BOUNDARY== Content-Type: text/cloud-config; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config.txt" #cloud-config cloud_final_modules: - [scripts-user, always] --==BOUNDARY== Content-Type: text/x-shellscript; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="userdata.txt" #!/bin/bash set -e set -o nounset LOG_FILE="/var/log/user-data.log" exec > >(tee -a "$LOG_FILE") 2>&1 echo ">>> Updating packages..." yum update -y echo ">>> Installing required packages with replacement..." dnf install -y curl gnupg2 unzip wget --allowerasing echo ">>> Downloading Envoy..." wget -O /usr/bin/envoy https://github.com/envoyproxy/envoy/releases/download/v1.31.0/envoy-1.31.0-linux-x86_64 chmod +x /usr/bin/envoy echo ">>> Setting up Lightwing proxy config..." mkdir -p /var/lw_proxy/ cat < /var/lw_proxy/config.toml accessPointID="" apiURL="" proxyPort=8093 usageTrackingPort=8094 authToken="" accountID="" EOF echo ">>> Downloading and installing Lightwing proxy components..." wget -O /var/lw_proxy/envoy.zip "https://lightwing-downloads-temp.s3.ap-south-1.amazonaws.com/autostopping-custom-lb-3.1.0.zip" unzip -o /var/lw_proxy/envoy.zip -d /var/lw_proxy chmod +x /var/lw_proxy/envoyproxymanager wget -O /var/lw_proxy/tcp_proxy.zip "https://lightwing-downloads-temp.s3.ap-south-1.amazonaws.com/autostopping-tcp-proxy-3.4.zip" unzip -o /var/lw_proxy/tcp_proxy.zip -d /var/lw_proxy chmod +x /var/lw_proxy/tcpproxymanager echo ">>> Setting up systemd services..." cp /var/lw_proxy/envoy.service /etc/systemd/system/envoy.service ``` -------------------------------- ### Override File for Connected Environment Source: https://developer.harness.io/docs/cloud-cost-management/get-started/ccm-smp/aws-smp Example configuration for the override.yaml file when deploying in a connected environment. Includes settings for CCM, SMTP secret creation, license, and database. ```yaml global: ccm: enabled: true smtpCreateSecret: enabled: true license: ng: database: clickhouse: enabled: true ccm: batch-processing: cloudProviderConfig: S3_SYNC_CONFIG_BUCKET_NAME: [AWS Setup - bucket name from here 'harness-ccm-service-data-bucket-'] S3_SYNC_CONFIG_REGION: [AWS Setup - Create S3 buckets step - Use region from here] ``` -------------------------------- ### Navigate to ECG Directory Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/configure-ecg-for-auto-stopping-rules Changes the current directory to the location where the ECG executable was placed. This is a prerequisite for installing the service. ```powershell cd C:\Users\Administrator\harness ``` -------------------------------- ### Override File for Air-gapped Environment with Proxy Source: https://developer.harness.io/docs/cloud-cost-management/get-started/ccm-smp/aws-smp Example configuration for the override.yaml file in an air-gapped environment. Enables proxy settings for AWS SDK calls and specifies proxy host, port, and protocol. ```yaml global: ccm: enabled: true smtpCreateSecret: enabled: true license: ng: # -- To enable the use of a proxy for AWS SDK calls to services such as organization, CUR (Cost and Usage Report), CE (Cost Explorer), and IAM (Identity and Access Management), set the `global.proxy.enabled` parameter to true. # -- Set the `global.proxy.host` parameter by specifying the proxy host or IP address (for example, localhost, 127.0.0.1) # -- Set the `global.proxy.port` parameter by specifying the proxy port. It takes an integer value. # -- Set the `global.proxy.username` parameter and `global.proxy.password` parameter by specifying the proxy username and password. If not required, remove it or leave it blank. # -- Set the `global.proxy.protocol` parameter as https. proxy: enabled: true host: localhost port: 80 username: "" password: "" protocol: https # -- CACM uses `us-east-1` as the default region where the respective endpoint URLs are used for STS (Security Token Service), ECS (Elastic Container Service), and CloudWatch services. However, if there is a need to specify a different region, you have the option to customize the endpoint URLs using the following configuration: # -- Set the `global.awsServiceEndpointUrls.enabled` parameter to true to enable endpoint URLs. # -- Set a valid AWS region in the `global.awsServiceEndpointUrls.endPointRegion.host` parameter to specify the region where this endpoint is accessible. # -- Set the the STS (Security Token Service) endpoint URL in the `global.awsServiceEndpointUrls.stsEndPointUrl` parameter. # -- Set the ECS (Elastic Container Service) endpoint URL in the `global.awsServiceEndpointUrls.ecsEndPointUrl` parameter. # -- Set the CloudWatch endpoint URL in the `global.awsServiceEndpointUrls.cloudwatchEndPointUrl` parameter. awsServiceEndpointUrls: enabled: true endPointRegion: us-east-2 stsEndPointUrl: https://sts.us-east-2.amazonaws.com ecsEndPointUrl: https://ecs.us-east-2.amazonaws.com cloudwatchEndPointUrl: https://monitoring.us-east-2.amazonaws.com database: clickhouse: enabled: true ccm: batch-processing: cloudProviderConfig: S3_SYNC_CONFIG_BUCKET_NAME: [AWS Setup - bucket name from here 'harness-ccm-service-data-bucket-'] S3_SYNC_CONFIG_REGION: [AWS Setup - Create S3 buckets step - Use region from here] # -- To enable the use of a proxy for AWS S3 sync, set the `ccm.batch-processing.cliProxy.enabled` parameter to true. # -- Set the `ccm.batch-processing.cliProxy.host` parameter by specifying the proxy host or IP address (for example, localhost, 127.0.0.1) # -- Set the `ccm.batch-processing.cliProxy.port` parameter by specifying the proxy port. It takes an integer value. # -- Set the `ccm.batch-processing.cliProxy.username` parameter and `ccm.batch-processing.cliProxy.password` parameter by specifying the proxy username and password. If not required, remove it or leave it blank. # -- Set the `ccm.batch-processing.cliProxy.protocol` parameter as http. cliProxy: enabled: true host: localhost port: 80 username: "" password: "" protocol: http ``` -------------------------------- ### Example Cost Efficiency Score Calculation Source: https://developer.harness.io/docs/cloud-cost-management/get-started/key-concepts Illustrates how to calculate the efficiency score based on defined baselines for unallocated and idle resources. It shows a practical application of the utilization baseline formula. ```plaintext Allowed unallocated resources = 5% of the total cost Allowed idle resources = 30% of the total cost Utilized resources baseline defined = 65% If the utilization is 58% of total cost, then the efficiency score = [1 - [(65-58)/65]] * 100 ~ [89 efficiency score] ``` -------------------------------- ### Get Current Helm Chart Values Source: https://developer.harness.io/docs/cloud-cost-management/get-started/ccm-smp/azure-smp Retrieve the current override values for your Helm chart. This is useful for upgrading existing installations. ```bash helm get values -n > override.yaml ``` -------------------------------- ### OpenTofu Configuration for Auto-Stopping Pipeline Source: https://developer.harness.io/docs/cloud-cost-management/kb-reference-architecture/patterns/asset-governance-autostopping-pipeline-ec2 This snippet shows a sample OpenTofu configuration for setting up an auto-stopping pipeline. It includes parameters for connector ID, idle time, schedule days, start/end times, and timezone. The 'when' block specifies conditions for rule execution, such as stage status and the absence of an existing auto-stopping rule. ```hcl CONNECTOR_ID: <+steps.Find_AWS_CCM_Connector_for_Account.output.outputVariables.CONNECTOR_ID> IDLE_TIME: "5" SCHEDULE_DAYS: 1,2,3,4,5 SCHEDULE_START_H: "8" SCHEDULE_START_M: "0" SCHEDULE_END_H: "17" SCHEDULE_END_M: "0" SCHEDULE_TIMEZONE: America/Chicago when: stageStatus: Success condition: <+execution.steps.Create_AutoStopping_Rules.steps.Find_Existing_AutoStopping_Rule.output.outputVariables.RULE_ID> == "" stepGroupInfra: type: KubernetesDirect spec: connectorRef: ${var.kubernetes_connector_id} EOT ``` -------------------------------- ### Initialize AWS and Harness Terraform Providers Source: https://developer.harness.io/docs/cloud-cost-management/kb-reference-architecture/patterns/ec2-scheduled-stopping-tf Sets up the necessary providers for Terraform to interact with AWS and Harness. Ensure your AWS credentials and Harness API key are configured. ```terraform terraform { required_providers { aws = { source = "hashicorp/aws" } harness = { source = "harness/harness" } } } ``` -------------------------------- ### Create Istio VirtualService for AutoStopping Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/kubernetes-autostopping-quick-start-guide Expose your application using an Istio VirtualService. This configuration routes traffic for a specific path to your service. ```yaml apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: httpbin namespace: autostopping-sample spec: gateways: - http-gateway http: - match: - uri: prefix: /autostopping-test route: - destination: port: number: 80 host: autostopping-sample-svc ``` -------------------------------- ### Stamped Mode Filter Example Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-reporting/ccm-cost-categories/cost-categories Filter rows where the pre-computed cost category bucket is 'CB2'. This is used in Stamped Mode. ```sql WHERE costCategory = 'CB2' ``` -------------------------------- ### Get Asset Governance Evaluation Status Source: https://developer.harness.io/docs/cloud-cost-management/faq Use the governance endpoint to retrieve the status of an asset governance evaluation using its execution ID. ```curl curl 'https://app.harness.io/gateway/ccm/api/governance/status/noIGUi15TS-_XrJIPwYczQ?routingId=&accountIdentifier=' \ -H 'x-api-key: pat.token' \ ``` -------------------------------- ### Dynamic Mode Filter Example Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-reporting/ccm-cost-categories/cost-categories Filter rows that satisfy the underlying filter conditions for a specific cost category at query time. This is used in Dynamic Mode. ```sql WHERE awsAccountId = 'acc1' ``` -------------------------------- ### Switch Azure Subscription Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/review-autostopping-rules-reqs Use this command to switch to a different Azure subscription when managing resources. Ensure the correct subscription is selected before executing commands. ```bash az account set -s ``` -------------------------------- ### Cloud Info Configuration File Source: https://developer.harness.io/docs/cloud-cost-management/get-started/ccm-smp/azure-smp This is a sample configuration file for the `cloud-info-secret-mount` secret. Replace placeholders like ``, ``, and `` with their base64 decoded values. ```yaml environment = "production" debug = false shutdownTimeout = "5s" [config.vault] enabled = false address = "" token = "" secretPath = "" [log] format = "json" level = "info" [metrics] enabled = false address = ":9090" [jaeger] enabled = false # Configure either collectorEndpoint or agentEndpoint. # When both are configured collectorEndpoint will take precedence and the exporter will report directly to the collector. collectorEndpoint = "http://localhost:14268/api/traces?format=jaeger.thrift" agentEndpoint = "localhost:6831" # username = "" # password = "" [app] address = ":8000" basePath = "/" [scrape] enabled = true interval = "24h" [provider.amazon] enabled = false # See available regions in the documentation: # https://aws.amazon.com/about-aws/global-infrastructure/regions_az # region = "us-east-1" # Static credentials # accessKey = "" # secretKey = "" # Shared credentials # sharedCredentialsFile = "" # profile = "" # IAM Role ARN to assume # assumeRoleARN = "" # http address of a Prometheus instance that has AWS spot price metrics via banzaicloud/spot-price-exporter. # If empty, the cloudinfo app will use current spot prices queried directly from the AWS API. prometheusAddress = "" # advanced configuration: change the query used to query spot price info from Prometheus. prometheusQuery = "avg_over_time(aws_spot_current_price{region=\"~s\", product_description=\"Linux/UNIX\"}[1w])" # Amazon pricing API credentials (optional) # Falls back to the primary credentials. [provider.amazon.pricing] # See available regions in the documentation: ``` -------------------------------- ### AWS Secrets Configuration Source: https://developer.harness.io/docs/cloud-cost-management/get-started/ccm-smp/aws-smp These are the AWS-specific secrets that need to be configured for Harness CCM services. Ensure you use the correct keys and values as per AWS setup instructions. ```yaml S3_SYNC_CONFIG_ACCESSKEY: [AWS Setup - Add a new user - Use saved aws access key] S3_SYNC_CONFIG_SECRETKEY: [AWS Setup - Add a new user- Use saved aws secret key] ``` ```yaml config-file: [Sample can be found below] ``` ```yaml AWS_ACCESS_KEY: [AWS Setup - Add a new user - Use saved aws access key] AWS_SECRET_KEY: [AWS Setup - Add a new user- Use saved aws secret key] AWS_ACCOUNT_ID: [AWS Setup - Id from here] AWS_DESTINATION_BUCKET: [AWS Setup - bucket name from here 'harness-ccm-service-data-bucket-'] AWS_TEMPLATE_LINK: [AWS Setup - Create S3 buckets step - Use complete path of CF template] CE_AWS_TEMPLATE_URL: [AWS Setup - Create S3 buckets step - Use c ``` -------------------------------- ### Configure Harness Azure Cloud Cost Connector with Terraform Source: https://developer.harness.io/docs/cloud-cost-management/kb-reference-architecture/onboarding/azure This Terraform configuration sets up an Azure Cloud Cost connector in Harness. Ensure you have the Harness Terraform provider installed and configured. ```hcl resource "harness_platform_connector_azure_cloud_cost" "billing" { identifier = "billing" name = "billing" features_enabled = ["BILLING", "VISIBILITY", "OPTIMIZATION"] tenant_id = "3e93deba-142a-459a-ab89-eea28bdb589c" subscription_id = "e9ce099c-531b-4f97-b681-e7a02e032e4f" billing_export_spec { storage_account_name = "harnesscostexportstorage" container_name = "harness" directory_name = "export" report_name = "harnesscostexport" subscription_id = "e9ce099c-531b-4f97-b681-e7a02e032e4f" } } ``` -------------------------------- ### Clone Helm Chart Repository Source: https://developer.harness.io/docs/cloud-cost-management/get-started/ccm-smp/azure-smp Clone the Harness Helm charts repository to your local machine. This is the first step before deploying or upgrading charts. ```bash git clone git@github.com:harness/helm-charts.git cd main/src/harness ``` -------------------------------- ### Unzip and Navigate ECG Directory Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/configure-ecg-for-auto-stopping-rules Unzip the downloaded ECG archive and change into the extracted directory. ```Shell unzip ecg_1.2.0_linux_amd64.zip cd ecg_1.2.0_linux_amd64 ``` -------------------------------- ### GCP Dataflow Job Hanged State Policy Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-governance/asset-governance/recommendations Policy to list Dataflow jobs that have been in a running or draining state for more than 1 day. It filters based on start time and current state. ```yaml policies: - name: list-hanged-gcp-dataflow-job resource: gcp.dataflow-job description: List Dataflow jobs that have been in an hanged state for more than 1 day. filters: - type: value key: startTime op: greater-than value_type: age value: 1 - type: value key: currentState value: - JOB_STATE_RUNNING - JOB_STATE_DRAINING - JOB_STATE_CANCELLING ``` -------------------------------- ### Configure Process Watcher with REGEX Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/configure-ecg-for-auto-stopping-rules Use a regular expression with the Process Watcher to match any Python program. ```TOML [process] condition = "python*" ``` -------------------------------- ### Create Nginx Ingress Rule for AutoStopping Source: https://developer.harness.io/docs/cloud-cost-management/use-ccm-cost-optimization/autostopping-guides/kubernetes-autostopping-quick-start-guide Expose your application by creating an ingress rule for Nginx. This YAML defines the service, port, and path for your application. ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: autostopping-sample-ig namespace: autostopping-sample annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: ingressClassName: nginx rules: - http: paths: - path: / pathType: Prefix backend: service: name: autostopping-sample-svc port: number: 80 ``` -------------------------------- ### Calculate Node Cost Source: https://developer.harness.io/docs/cloud-cost-management/get-started/key-concepts Node cost is calculated based on the cloud platform's public pricing API or trued up via a cloud connector. This example shows a basic calculation for 24 hours. ```text Cost for 24 hours = 24 * 0.1900 = $4.56. ``` -------------------------------- ### Main Execution Logic Source: https://developer.harness.io/docs/cloud-cost-management/kb-reference-architecture/patterns/asset-governance-autostopping-pipeline-ec2 This Python script orchestrates the creation of autostopping rules and schedules. It reads configuration from environment variables and handles potential errors during the process. ```python def create(): rule_id = create_autostopping_rule( getenv("INSTANCE_ID"), getenv("REGION"), getenv("CONNECTOR_ID"), int(getenv("IDLE_TIME", 130)), ) if rule_id: print(f"created rule {rule_id} for", getenv("INSTANCE_ID")) environ["RULE_ID"] = str(rule_id) else: environ["RULE_ID"] = "" exit(1) try: days_raw = getenv("SCHEDULE_DAYS", "1,2,3,4,5").split(",") days = [int(x) for x in days_raw] except ValueError: print(f"non integer day supplied: {days_raw}") exit(1) try: start_h = int(getenv("SCHEDULE_START_H")) start_m = int(getenv("SCHEDULE_START_M")) end_h = int(getenv("SCHEDULE_END_H")) end_m = int(getenv("SCHEDULE_END_M")) except ValueError: print("non integer time supplied for start or end h/m") exit(1) schedule_id = create_autostopping_schedule( getenv("INSTANCE_ID"), "created via governance+pipeline automation", getenv("CONNECTOR_ID"), rule_id, days, start_h, start_m, end_h, end_m, getenv("SCHEDULE_TIMEZONE"), ) print(schedule_id) if __name__ == "__main__": create() ``` -------------------------------- ### Get GCP Connector Details API Request Source: https://developer.harness.io/docs/cloud-cost-management/get-started/ccm-smp/gcp-smp Use this Harness API endpoint to retrieve details for your GCP Cloud Cost connector. This is the first step in replaying GCP Billing Export data. ```json { "filterType": "Connector", "types": [ "GcpCloudCost" ] } ```