GithubHelp home page GithubHelp logo

boavizta / cloud-scanner Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 7.0 4.17 MB

๐Ÿ“ก Get Boavizta impact data for your aws cloud account usage.

License: GNU Affero General Public License v3.0

Rust 99.20% Dockerfile 0.80%
aws cli serverless sustainability

cloud-scanner's People

Contributors

da-ekchajzer avatar damienfernandes avatar demeringo avatar dependabot[bot] avatar jnioche avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cloud-scanner's Issues

Provide a docker image that includes Boavizata API

Problem

Publish an additional docker version that includes a local copy of Boavizta API (to allow usage with reduced internet access), in which case it could be simpler to build on top of Boavizta API docker image.

Solution

Alternatives

Additional context or elements

Add amortization of manufacture impacts

Problem

Today, manufacturing impacts of instances are given globally (for the entire lifetime of the underlying infrastructure).
As a user, I would like to get the impacts corresponding to a given period of time.

Solution

Boavizta API v0.2.x brings the possibility to amortize manufacture impacts over a given time (using the Linear Allocation).

  • Integrate this amortization functionnality (maybe using optional parameters)
  • document it

Alternatives

Additional context or elements

Avoid querying Boavizata API when instance type is not supported

Some aws instance types are not yet in the Boavizta data set.

The current behavior is to query Boavizta API for any instance type, and if the type is not found (resulting in error 500), the error is caught by cloud-scanner, and an empty impact string is returned ({}) for this instance.

It would be more efficent to pre-check which type of instances are supported by Boavizta Dataset and query the API only for relevant instances.

The serve metrics function does not work in docker container

Bug description

When running cloud scanner in docker, the servefunction does not start (nothing seems exposed on 127.0.0.1:8000).

To Reproduce

Expected behavior

JSON OUTPUT

Additional context

This is not only related to the missing expose port in docker file #153 , despite adding it on local test and it does not fix the startup.

Support Azure instances

Problem

Support assesment of Instances of Azure Account.

Solution

Feature On hold for the time being because we lack Azure VM impact data in Boavizta Dataset.

Alternatives

Additional context or elements

Get impact by scanning a cloud account

A a person who manage an AWS account, I want to run cloud scanner to retrieve the impacts of the resources in my account.

At first, this scanner is intended to be run manually, as a CLI tool, but we should consider wrapping it in a serverless function later.

Map all CLI parameters in the serverless version

Problem

Current sls version of cloud-scanner uses hardcoded parameters to do a default scan (defaut, region, defaut api url, 1 hour use time a.s.o)

Solution

Map Inputs parameters of the CLI to the severless app.

Alternatives

Additional context or elements

Improve documentation

Problem

Doc is incomplete and Readme is becoming a bit complicated to follow.

Solution

Area to improve

  • Building on Linux
  • Builing on Windows
  • Serverless deployment
  • Methodology (i.e. where data come from) with pointer to Boavizta API material
  • A general page about the different deployments models (CLI vs serverless, and using private API vs other API)
  • A specific chapter about generating metrics (sample rate, data returned)
  • Document setup with prometheus and grafana see #114
  • A chapter about limitations
  • It may better work with a dedicated doc, maybe using mdbook https://github.com/rust-lang/mdBook

Alternatives

Additional context or elements

Export Boavizta API rust SDK to it's own crate and repository

Problem

The generated SDK used to wrap calls to Boavizta API is embeded in the codebase of cloud-scanner.
It makes it heavy and unpractical to maintain (or resuer)

Solution

Extract the Boavizta API Rust SDK to it's own repository and publish it as a crate.
As a first step, this extract will be just a manual copy / publish of existing code (not necessary to automate it).

Alternatives

  • (abandonned) Publish the Rust SDK directly from the Boavizta API repository

Additional context or elements

We tried first to publish rhe Rust SDK in the CI chain of Boavizta API repository (see Boavizta/boaviztapi#84), but it turns out it is not very practical because:

  • the publish model for crate.io recommends that the code published as crate is available in public repo
  • it is generated code (so it is not commited by default inside Boavizta API repo)
  • it may require manual adaptations to conform to clippy rules
  • it seems easier to maintain in it's own repository (and avoid mixing concerns with Boavizta API repository

Reduce size of cloud-scanner image

Problem

Docker image is unecessary big (~90MB because based on Ubuntu).

Solution

Update dockerfile to use Alpine as a base container.

Alternatives

Additional context or elements

Improve region support

Problem

At the moment only a limited list of aws_regions is supported.

Solution

We need to match ISO country codes with AWS regions.

Actual region<-> is translation code should be externalized, and even better we should rely on a third party package for this.

Alternatives

Additional context or elements

Use instance usage metrics to query API (impacts of usage/workload)

Problem

Current version of cloud-scanner only returns defaults impacts of the aws cloud instances (i.e. the usage rate of instances is not considered, only instance types).

Solution

Retrieve instance usage metrics from AWS API and use them when querying Boavizta API to get more realistic results.

Additional context or elements

See meta issue here #3

Example payload format for custom cloud usage query on Boavizta API

{
  "hours_use_time": 2,
  "usage_location": "FRA",
  "workload": {
    "10": {
      "time": 0
    },
    "50": {
      "time": 1
    },
    "100": {
      "time": 0
    },
    "idle": {
      "time": 0
    }
  }
}

Publish docker image to a public registry

Problem

Docker image is currently build in CI and available only on the private registry of this project.
Cannot be retrieved without authentication / proper permission which make deployment difficult in Enterprise context.

Solution

Publish the image to docker registry.

Not sure if Boavizta org has account / credentials setup for docker registry.

Alternatives

Additional context or elements

Publish the scanner as a docker image

Problem

As a new user I would like to quickly test the scanner without compiling or installing anything.

Solution

  • Publish a docker image including the precompiled tool.
  • Maybe publish also a version that includes a local copy of Boavizta API (to allow usage with reduced internet access), in which case it could be simpler to build on top of Boavizata API docker image.: migrated to issue #21
  • Document usage in the readme.

Publish scanner as a serverless application

Problem

Running the cloud-scanner on a AWS account from outside the account is not the preferred setup for large organizations using AWS, for several reasons:

  • potential data leaking outside of the account
    • Inventory / usage data sent to the api (e.g. leaking in api log endpoint)
    • Result data: analysis, inventory (e.g. result exported from aws account)
  • requires end user elevated permission (using individual aws IAM user to perform the query)
  • need for local setup of the scanner before use.

Solution

Wrap the scanner as a serveless app that can easily be deployed to an aws account. โšก

This allows:

  • to create a custom role for the lambda (and limit the permission to strict minimum)
  • audit capability
  • easy deployment
  • possibility to embed Boavizta API (permitting a kind of offline use to avoid usage data leaking outside the aws account).
  • easy to automate scanning

Alternatives

Additional context or elements

Preference for using the serverless framework to easily wrap the rust binary. https://www.serverless.com/

Use aws instances use time and location to query API

Problem

Current version of cloud-scanner only returns defaults impacts of the aws cloud instances (i.e. the usage duration and location of instances is not considered, only instance types).

This means that we retrieve only defaults values.

Solution

Pass the following json body when querying API

{
  "hours_use_time": 2,
  "usage_location": "FRA"
}

Alternatives

Additional context or elements

โš  We do not consider the workload for the time being, only global use time and location.

Rationale for this is that current workload implementation is under evolution API side, so we wait for implementation of:

API doc:

Document metrics server

Problem

  • Update Readme
  • Add a page in doc

Solution

Alternatives

Additional context or elements

Precise the metrics we would like to see in the dashboard

Problem

We build a demo dashboard to display metrics of cloud scanner but the units and sample rate can be questionned.

Objective of this issue is to discuss which metrics would be relevant to display to an end-user.

Solution

  • Maybe display impacts per year of equivalent usage (e.g. this allow easy comparison to a 2 tons objective per example).
  • Decide how we attribute the manufacture impacts.

Alternatives

Additional context or elements

Implement a standalone metric server / endpoint

Problem

It would be easier for quick testing if cloud scanner could be embedded with prometheus and grafana in a docker compose file.
But in standalone mode (i.e. non serverless) cloud scanner does not offer a metric http endpoint that can refreshed / scrapped.

Solution

Add an option in CLI to serve metrics continuously on localhost:300/metrics

Alternatives

Additional context or elements

Wrong default API URL

Bug description

Wen using scanner without passing custom API URL, queries fails.

To Reproduce

Run the scanner without passing any custom URL, fails because the default set in code includes a trailing slash (that make requests fail).

Unit tests pass because they use correct URL (only CLI, wich is not tested fails).

Expected behavior

Should use https://api.boavizta.org (without trailing slash) as default.

Refactor to ease testing and code readibility

Problem

Code is a bit hard to follow and there are several interdependencies between modules and data objects.

Solution

Refactor to use more API agnostic (cloud or Boavizta) data objects and "nterfaces" to ease testing.

Alternatives

Additional context or elements

Idea is also to ease the future support of differents cloud providers, impact providers and results exporters.

See https://github.com/Boavizta/cloud-scanner/blob/chore/refactor-for-testing/docs/refactor.mm.md (use a plantuml renderer to see the map).

Filter instances on tags

Problem

The scan returns all instances of a given account. For large accounts with a lot of instances, we may want to filter results.

Solution

Pass tags to the scan command so that only the instances having theses tags are returned.

Alternatives

Additional context or elements

The general semantic of tags queries on aws seems to be:

  • tag1=value1 tag22=value2 : a AND (instance will need to have both tag1 and tag2 to be retained)
  • tag1=val1,val2,Val3 : a OR (instance needs to have tag1, with any of the 3 values)

https://gist.github.com/simeji/945165da059d2f4ef4bf

Stabilize CLI options

Problem

Cloud scanner CLI is lacking some options and lacks adaptability.

Solution

CLI covers 2 use cases (subcommands) which needs different flags or set of options.

  • get Average (standard) impacts for a given usage duration
  • get Mesured impacts: depending on usage rate (use instance workload), in this case we want to use a start and end date

In addition we need to provide

  • the region (s) to scan (optional)
  • the name for the ouptut file to be saved (optional, default to stdout)
  • a list of tags/values that will be used to filter instances (optional)

Alternatives

Additional context or elements

This CLAP tutorial seems to explain all we need : https://blog.logrocket.com/command-line-argument-parsing-rust-using-clap/

Improve doc about passing AWS credentials

Problem

Documentation is unclear about how to pass aws credentials when use in CLI.
Now only exporting the aws profile through env var (for Linux) is explained... and not in all sections.

See issue #76

Solution

Improve documentation. Describe and test various ways to pass AWS credentials for Unixes and Windows.

Alternatives

Additional context or elements

Allow scanning a different region

Problem

By default the scanner only lists resources of the default region of the current AWS profile (or from where the lambda is deployed).

Solution

Allow to scan resources located in a different region.

  • The parameter already exists in CLI, it is just not used.
  • The region needs to be passed as an optional parameter in the serverless app.

Alternatives

Additional context or elements

Provide a docker-compose to demonstrate the monitoring dashboard

Problem

I want ot quicky spin up a full demo of cloud-scanner, used to show a real time dashboard.

Solution

A docker compose file to showcase the monitoring use-case:

  • cloud-scanner as a metric server (see #149 #148 )
  • local boavizta api instance (instead of querying public test api)
  • prometheus
  • grafana (using demo dashboard)

Alternatives

Additional context or elements

๐Ÿ”ฅ cloud-scanner has to be started with a specific flag to ensure it uses the local API (not the public one)

cloud-scanner -b http://localname/v1 serve

Get detailled impacts (consider usage/workload)

Problem

Get the detailed impacts of instances/account (taking into consideration the usage of the instance through cloud watch metrics or other mechanism).

Solution

Alternatives

Additional context or elements

Original request and way to implement it in #3

Using a private instance of BoaviztAPI does not work

Bug description

Both CLI and serverlss version allow using a private (or specific) instance of Boaviztapi as datasource (instead of the default public instance of Boaviztapi).

This is important for enterprise customer setup where we want to be sure that no data of cloud usage leaks outs to a public API.

The parameter exists (as an env var for the serverless version and a CLI parameter) for the CLI version but in practice, both software use the hardcoded URL of the public API.

To Reproduce

Expected behavior

Ensure that

  • write code in CLI to use the URL passed as an optional parameter (or default to standard public URL)
  • update serverless version makes to use the custom URL passed as environment variable
  • both tools provide helpful error message in case the URL is unreacheable
  • Give example of how to use this private instance in the Cloud Scanner doc for CLI
  • Give example of how to use this private instance in the Cloud Scanner doc for SLS instance

JSON OUTPUT

Additional context

Support Azure

Problem

Support other cloud providers like Azure

Solution

Alternatives

Additional context or elements

May imply CLI option changes See #14

Missing expose port on docker file

Bug description

Docker file is missing the expose port (8000) requiered to expose a metric server

To Reproduce

Expected behavior

JSON OUTPUT

Additional context

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.