All Projects → hortonworks → cloud-haunter

hortonworks / cloud-haunter

Licence: Apache-2.0 license
Cloud agnostic resource monitoring and janitor tool

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to cloud-haunter

deploy-cloudrun
This action deploys your container image to Cloud Run.
Stars: ✭ 238 (+981.82%)
Mutual labels:  gcp
cloud-detect
Module that determines a host's cloud provider.
Stars: ✭ 28 (+27.27%)
Mutual labels:  gcp
tfc-agent
Examples related to the Terraform Cloud Agent, a remote runner for Terraform Cloud Business and Terraform Enterprise
Stars: ✭ 44 (+100%)
Mutual labels:  gcp
tfquery
tfquery: Run SQL queries on your Terraform infrastructure. Query resources and analyze its configuration using a SQL-powered framework.
Stars: ✭ 297 (+1250%)
Mutual labels:  gcp
course-material
Course Material for in28minutes courses on Java, Spring Boot, DevOps, AWS, Google Cloud, and Azure.
Stars: ✭ 544 (+2372.73%)
Mutual labels:  gcp
terraform-modules
Reusable Terraform modules
Stars: ✭ 12 (-45.45%)
Mutual labels:  gcp
k8s-digester
Add digests to container and init container images in Kubernetes pod and pod template specs. Use either as a mutating admission webhook, or as a client-side KRM function with kpt or kustomize.
Stars: ✭ 65 (+195.45%)
Mutual labels:  gcp
gke-ip-address-management
An application to help with IP Address Management (IPAM) for Google Kubernetes Engine (GKE) clusters. Easily allows the calculation of the subnets required to spin up GKE clusters in VPC-native mode. See it at: https://googlecloudplatform.github.io/gke-ip-address-management/
Stars: ✭ 45 (+104.55%)
Mutual labels:  gcp
GoogleCloudLogging
Swift (Darwin) library for logging application events in Google Cloud.
Stars: ✭ 24 (+9.09%)
Mutual labels:  gcp
vertex-edge
A tool for training models to Vertex on Google Cloud Platform.
Stars: ✭ 24 (+9.09%)
Mutual labels:  gcp
cloud-opensource-java
Tools for detecting and avoiding linkage errors in GCP open source projects
Stars: ✭ 128 (+481.82%)
Mutual labels:  gcp
polygon-etl
ETL (extract, transform and load) tools for ingesting Polygon blockchain data to Google BigQuery and Pub/Sub
Stars: ✭ 53 (+140.91%)
Mutual labels:  gcp
drf-angular-docker-tutorial
Dockerized Django Back-end API using DRF with Angular Front-end Tutorial
Stars: ✭ 53 (+140.91%)
Mutual labels:  gcp
waihona
Rust crate for performing cloud storage CRUD actions across major cloud providers e.g aws
Stars: ✭ 46 (+109.09%)
Mutual labels:  gcp
fluent-plugin-gcs
Google Cloud Storage output plugin for Fluentd.
Stars: ✭ 39 (+77.27%)
Mutual labels:  gcp
bigflow
A Python framework for data processing on GCP.
Stars: ✭ 96 (+336.36%)
Mutual labels:  gcp
spindle
A distributed locking library built on top of Cloud Spanner and TrueTime.
Stars: ✭ 47 (+113.64%)
Mutual labels:  gcp
nodecloud-cli
📝 Command line interface for open cloud
Stars: ✭ 30 (+36.36%)
Mutual labels:  gcp
datacatalog-tag-manager
Python package to manage Google Cloud Data Catalog tags, loading metadata from external sources -- currently supports the CSV file format
Stars: ✭ 17 (-22.73%)
Mutual labels:  gcp
blockchain-etl-streaming
Streaming Ethereum and Bitcoin blockchain data to Google Pub/Sub or Postgres in Kubernetes
Stars: ✭ 57 (+159.09%)
Mutual labels:  gcp

CircleCI Go Report Card

Cloud Haunter

Haunter is a pokémon ghost which will poison and kill your unidentified and orphan cloud resources

The main goal of this project is to save costs in the cloud by monitoring and terminating resources. Cloud Haunter (ch) supports the three major cloud providers.

The project is under construction, use on your own risk!

Supported resources


AWS AZURE GCP
Stack Cloudformation stack, Native stack assembled by tags Resource group Native stack assembled by tags
Instance EC2 instance Virtual machine Compute Engine instances
Disk EC2 disk - Compute Engine disks
Access IAM user - IAM service accounts
Database RDS database - SQL instances
Alert CloudWatch alarm - -
Storage - Storage account -

Filters appliable to resources:

  • long running
  • without owner
  • actually running
  • already stopped
  • old cloud credentials
  • resource unused

Actions appliable to resources:

  • send notification
  • log result
  • print result in json format
  • stop instances [AWS, AZURE, GCP]
  • terminate instances [AWS, AZURE, GCP]
  • terminate stacks [AWS, AZURE, GCP]
  • terminate disks [AWS, GCP]
  • terminate images [AWS, AZURE, GCP]
  • cleanup storages [AZURE]

Prerequisites


For the proper work, you have to use some custom tags/labels on your cloud resources.

AWS

  • Owner tag: owner
  • Ignore tag: cloud-cost-reducer-ignore
  • Resource grouping label: Cloudera-Environment-Resource-Name (for native stacks)

Azure

  • Owner tag: owner
  • Ignore tag: cloud-cost-reducer-ignore
  • Resource creation time, because Azure SDK doesn't response it: cb-creation-timestamp

Google

  • Owner label: owner
  • Ignore label: cloud-cost-reducer-ignore
  • Resource grouping label: cloudera-environment-resource-name
  • Resource description (optional): Generated by CDP.

There is an option to use custom tags/labels, but you have to recompile the project with a bunch of custom environment variables like OWNER_LABEL. Please check Makefile.

Resource filtering

This tool works well if you use it from early days of your cloud account and all of your users are following the basic rules of tagging instances. On the other hand introducing it on an existing environment should be pain in the back. There is an option to declare your include/exclude policies in a YAML file (please have look at utils/testdata/filterConfig.yml). CH will include/exclude all the resources where the name, owner, or any of the tags are matching with the given configuration.

Installation


curl -Ls https://github.com/hortonworks/cloud-haunter/releases/download/v0.5.41/cloud-haunter_0.5.41_$(uname)_x86_64.tgz | tar x

NOTE: You can find the latest version released under https://github.com/hortonworks/cloud-haunter/releases

Usage


NAME:
   Cloud Haunter
USAGE:
   ch -o=operation -a=action [-f=filter1,filter2] [-c=cloud1,cloud2]
VERSION:
   v0.5.7-snapshot

AUTHOR(S):
   Hortonworks
OPERATIONS:
	-o getAccess
	-o getAlerts
	-o getDatabases
	-o getDisks
	-o getImages
	-o getInstances
	-o getStacks
	-o getStorages
	-o readImages
FILTERS:
	-f failed
	-f longrunning
	-f match
	-f nomatch
	-f oldaccess
	-f ownerless
	-f running
	-f stopped
	-f unused
ACTIONS:
	-a cleanup
	-a json
	-a log
	-a notification
	-a stop
	-a termination
CLOUDS:
	-c AWS_GOV
	-c AWS
	-c AZURE
	-c GCP
FILTER_CONFIG:
	-fc=/location/of/filter/config.yml
DRY RUN:
	-d
VERBOSE:
	-v
DISABLE_IGNORE_LABEL:
	-i
EXACT_MATCH_OWNERS:
	-e
HELP:
	-h

Environment variables

AWS

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

Azure

  • AZURE_SUBSCRIPTION_ID
  • AZURE_TENANT_ID
  • AZURE_CLIENT_ID
  • AZURE_CLIENT_SECRET

Google

  • GOOGLE_PROJECT_ID
  • GOOGLE_APPLICATION_CREDENTIALS, location of service account JSON

HipChat

  • HIPCHAT_TOKEN
  • HIPCHAT_SERVER
  • HIPCHAT_ROOM

Slack

  • SLACK_WEBHOOK_URL

Long running

  • RUNNING_PERIOD, default: 24h

Old access

  • ACCESS_AVAILABLE_PERIOD, default: 2880h

Retention days for cleanup

  • RETENTION_DAYS, default: 90

Usage examples

Terminate AWS stacks with owners not exactly matching the known owners, even if they have an ignore label

# Set up cloud provider settings
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...

# Run Cloud Haunter
ch -o getStacks -a termination -f nomatch -c aws -fc known-owners-filter-config.yml -i -e

Terminate Azure instances with specific owners if they are running longer than 6 hours

# Set up cloud provider settings
export AZURE_SUBSCRIPTION_ID=...
export AZURE_TENANT_ID=...
export AZURE_CLIENT_ID=...
export AZURE_CLIENT_SECRET=...

# Set up additional parameters
export RUNNING_PERIOD=6h

# Run Cloud Haunter
ch -o getInstances -a termination -f longrunning,match -c azure -fc owner-filter-config-v2.yml -e

NOTE: You can find example filter config files under utils/testdata

Development

Dependencies

  • Golang 1.15
  • Docker
  • GNU Make

Building the project

Make sure you have the needed dependencies ony your development machine, then simply use make for building the project:

make build

You may also need to format your changes before building to pass the pre-build checks, you can do this with make format

Adding a new dependency

  • Import the dependency in your go code
  • Run make mod-tidy

Releasing a new version

VERSION={{new-semantic-version}} make release
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].