MeNsaaH / reka

A Cloud Resource management Tool to destroy, stop, resume, or clean up unsed resources
Apache License 2.0
53 stars 3 forks source link
aws cloud gcp infrastructure infrastructure-management

reka

Never forget that instance running again


Build Status deploy

A Cloud Infrastructure Management Tool to stop, resume, clean and destroy resources based on tags. Reka uses a config to determine what actions should be taken on resources. It can prove to be a cost management tool where you can stop your tests environments during breaks, holidays and non-working hours. It can also be a nuke tool to nuke an account. It currently supports both AWS and GCP. A full list of supported resources can be found here

What It can do

Project Name

REKA is derived from a Native Nigerian Language, Igbo, meaning Reap|Tear Down.

BEWARE!

This tool is HIGHLY DESTRUCTIVE and deletes cloud resources! This should be used in environments with WITH CAUTION.

Table of Contents

Getting Started

Installation

Binary

The Reka binary can be downloaded from the Releases and executed directly on its respective OS.

Docker

The reka image is also available on DockerHub.

    docker pull mensaah/reka

If config.yaml is in the current directory, reka can be executed as:

    docker run -it -e AWS_ACCESS_KEY -e AWS_SECRET_ACCESS_KEY\
        -v `pwd`:/config mensaah/reka --config /config/config.yaml

Go

Reka can also be installed like a regular golang Binary if go is installed

go get -u github.com/mensaah/reka

Usage

Reka uses a config file to know what resources to target and the actions to be taken for such resources. Here is an example configuration file that Reka uses.

    reka --config config.yaml

    # To run without destroying any instance, basically just stops, resumes resources
    reka --config config.yaml --disable-destroy

    # To see full range of commands that can executed with reka
    reka help

    # View supported resources
    reka resources

Authentication

Rules

Reka supports different resource rules. These are usually in the form:

rules:
  - name: <RULE_NAME>
    # Target specific resource types
    target:
      - resource-targets
    tags:
      tagKey1: tagValue1
      tagKey2: tagValue2
    condition:
        CONDITIONS

Conditions needs to be met before the action is taken on the resource.

rules:
  - name: stop all staging instances after work and during weekends 
    tags:
      env: staging
    resources:
    - aws.ec2
    - aws.eks
    region: "us-east-2"
    condition:
      activeDuration: 
        startTime: "7:00"
        stopTime: "19:00"
        startDay: Monday
        stopDay: Friday

Specifying the resources list in any rule only applies the rules to those resources alone.

rules:
  - name: nuke all demo instances 2 weeks after demo october 9th (staging)
    tags:
      env: test
      project: proj-demo
    condition:
      terminationDate: "2021-10-23 01:00"
rules:
  - name: Delete all unused instances
    condition:
     terminationPolicy: unused

Excluding Resources

You can additionally exclude resources which will make Reka not to act on those resources even when the satisfy a condition and a rule.


exclude:
  - name: Exclude resources with prod tags in us-east-2
    region: "us-east-2"
    tags:
        env: prod

  - name: Exclude CI EC2 Instances on staging
    tags:
      env: staging
      ci-runner: true
    resources:
      - aws.ec2

RoadMap

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.