# mr-krabs

> A package to lower your costs with AWS resources

Latest version **1.1.0** (published 2019-05-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install mr-krabs
pnpm add mr-krabs
yarn add mr-krabs
bun add mr-krabs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-05-07 |
| First published | 2018-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Pagar.me Pagamentos S.A. |
| Maintainers | deivis, lucianopf, matheusvellone, otaviopace, pagarme-opensource, rafaeltardivo |
| Keywords | fargate, rds, databases, ecs, aws |

## Links

- npm: https://www.npmjs.com/package/mr-krabs
- Repository: https://github.com/pagarme/mr-krabs
- Homepage: https://github.com/pagarme/mr-krabs#readme
- Issues: https://github.com/pagarme/mr-krabs/issues
- npm.io page: https://npm.io/package/mr-krabs

## Dependencies (1)

- [aws-sdk](https://npm.io/package/aws-sdk.md) 2.301.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2019-05-07
- 1.0.0 — 2018-10-03

## README

<p align="center">
  <a href="https://github.com/pagarme/mr-krabs">
    <img src="https://media.giphy.com/media/yYrYPXatpCMiA/giphy.gif" alt="mr-krabs" >
  </a>
</p>

# mr-krabs

> :crab: :moneybag: A package to lower your AWS costs

## Installation

1. Make sure you have your AWS credentials correctly setup

2. Install the module:
```
npm install --save mr-krabs
```

## Usage

There are basically 2 ways of setting up the intended cluster and service name patterns:

  1 - By providing a file called `krabs.json` at the root of your project:

  ```json
  {
    "clusterName": "demoClusterName",
    "sericeName": "demoServiceName"
  }
  ```

  2 - By providing the config at the function calls as the demo above

  ```js
  const mrKrabs = require('mr-krabs')

  // DETAILS
  function getDetailsOfDemoServices () {
    return mrKrabs.listClusters({ clusterName: 'demoCluster' })
      .then(([clusterName]) =>
        mrKrabs.listServices({ clusterName, serviceName: 'demoServiceName' })
          .then(servicesNames => mrKrabs.getServicesDetails(servicesNames, clusterName))
      )
  }

  // UPSCALE
  function upscaleDemoServices () {
    return mrKrabs.listClusters({ clusterName: 'demoCluster' })
    .then(clusters =>
      Promise.all(
        clusters.map(clusterName =>
          mrKrabs.upScaleAllStoppedServices({ clusterName, serviceName: 'demoServiceName' })
        )
      )
    )
  }


  // DOWNSCALE
  function downscaleDemoServices () {
    return mrKrabs.listClusters({ clusterName: 'demoCluster' })
      .then(clusters =>
        Promise.all(
          clusters.map(clusterName =>
            mrKrabs.downScaleAllRuningServices({ clusterName, serviceName: 'demoServiceName' })
          )
        )
      )
  }

  // Full flow of upscale and downscale all services of the defined clusters/services
  getDetailsOfDemoServices()
    .then(before => {
      console.log('--- BEFORE ---')
      console.log(before)
      return upscaleDemoServices()
    })
    .then(getDetailsOfDemoServices)
    .then(middle => {
      console.log('--- MIDDLE ---')
      console.log(middle)
      return downscaleDemoServices()
    })
    .then(getDetailsOfDemoServices)
    .then(after => {
      console.log('--- AFTER ---')
      console.log(after)
    })
  ```

  You can also mix settings by adding either the config file and supplying the config params, just keep in mind that the precendence order respectively function param and `krabs.json`.

  ## License

  mr-krabs is [MIT licensed](./LICENSE).

---
_Source: https://npm.io/package/mr-krabs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
