Coder Social home page Coder Social logo

cli's Introduction

CloudChipr CLI

Build and Push a Docker Image

Overview

Cloudchipr(c8r) CLI is an open source tool that helps users easily identify and clean public cloud resources.

c8r provides a mechanism to apply user defined filters which would help to find, consolidate and delete all idle, abandoned or undesired resources in many different accounts and regions. By default, Cloudchipr CLI uses it's own pre-populated filters. When executed, c8r will check users environment to identify AWS Access credentials, if users are logged in with AWS CLI then they are logged in with c8r as well. Currently, only AWS is supported.

Quick start using Docker

  1. Run with the latest docker image
docker run -it -v ~/.aws/credentials:/root/.aws/credentials cloudchipr/cli c8r collect all --verbose --region all

Currently supported AWS resource types

  • EC2 Instances
  • EBS Volumes
  • RDS Instances
  • Elastic IPs
  • Load Balancers - ALB, NLB, ELB

Usage Examples

Collect all EC2 instances in us-west-2 region which have a Name tag key containing dev substring in the value and have been launched more than 1 day ago

Create the filters file

cat ec2-filters.yaml
and:
  - resource: "launch-time"
    op: "GreaterThanEqualTo"
    value: 1
  - resource: "tag:Name"
    op: "Contains"
    value: "dev"

Then run:

c8r collect ec2 --region us-west-2 -f ec2-filters.yaml
Collect all ebs volumes which are not attached to an instance in us-west-2 region

Create the filters file

cat ebs-filters.yaml
and:
  - resource: "attachments"
    op: "IsEmpty"
  - resource: "volume-age"
    op: "GreaterThanEqualTo"
    value: 0

Then run:

c8r collect ec2 --region us-west-2 -f ec2-filters.yaml
Collect all EIPs in default region which are not associated with an instance and don't have a Name tag

Create the filters file

cat eip-filter.yaml
and:
  - resource: "instance-ids"
    op: "IsAbsent"
  - resource: "association-ids"
    op: "IsAbsent"
  - resource: "tag:owner"
    op: "Exists"

Then run:

 c8r collect eip -f eip-filter.yaml
Collect all resource information from all regions and all connected accounts based on default filters.
Please note, this will work on multiple accounts in case the account that user logged in has assume role privileges to other accounts, typically management account.
c8r collect all --region all --account-id all
Clean

Very simple, clean and collect subcommands have exactly the same filters, simply replace collect with clean in order to delete selected resources.

clean subcommant will perform collect first, then present a confirmation (Y/n) request before executing the clean action.

Dockerless Setup

  • Install NodeJS
  • Install CloudCustodian (c7n) and CloudCustodian Org (c7n-org) for multi-account usage.
  • Set the following environment variables
export C8R_CUSTODIAN=<<PATH_TO_C7N_Binary>>
export C8R_CUSTODIAN_ORG=<<PATH_TO_C7N-ORG_Binary>>
  • Clone the repository and run
cd cli
chmod +x lib/index.js
npm install
npm run build
npm link

Development

  • Run the watch command to build your changes whenever a file is changed
npm run watch
  • Run the build command to build your changes
npm run build

cli's People

Contributors

mirzoyansergey avatar dependabot[bot] avatar marashlyansuren avatar tsardaryan avatar vid-cloud avatar

Forkers

adamyanlina

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.