giantswarm / cloud-carbon

Estimate the carbon footprint of AWS EC2 usage based on a usage report
Apache License 2.0
4 stars 0 forks source link
carbon-emissions carbon-footprint carbon-footprint-estimation sustainability

cloud-carbon

A CLI tool to estimate the carbon emissions produced by AWS EC2 usage.

Requirements

This tool needs an AWS Cost and Usage Report as input. These reports are delivered automatically into an S3 bucket. Usually they cover usage of (up to) one calendar month. Time resolution (hourly, daily, monthly) should not make a difference, both hourly and daily have been confirmed to work fine.

One such report is required to be accessible, e. g. downloaded to the local hard drive. The file is expected to be a gzip compressed comma-separated value (CSV) file.

If you don't have Cost and Usage Reports configured, please check the AWS documtation regarding setting this up.

Installation

TODO. Short version: clone the repo and build the binary using go build. Alternatively, download binary from release.

Usage

The CLI is invoked as

cloud-carbon analyse PATH

where PATH must be replaced with the path to the actual CSV file (gzip compressed). As a result, something like this will get printed:

Analysing report from path ./daily-without-ids-00001.csv.gz
Processed 723 lines about EC2 usage.
Time range covered: 2022-08-01 00:00:00 +0000 UTC - 2022-08-22 00:00:00 +0000 UTC (504h0m0s).

  REGION        INSTANCE TYPE  DURATION   EMISSIONS
  eu-central-1  m4.xlarge      648h0m0s   7.0 kgCO2e
  eu-central-1  m5.xlarge      4992h0m0s  66.6 kgCO2e
  eu-central-1  t3.large       504h0m0s   3.4 kgCO2e
  eu-central-1  t3.micro       504h0m0s   2.5 kgCO2e
  eu-central-1  t3.small       72h0m0s    376 gCO2e
  eu-west-1     m5.xlarge      4992h0m0s  62.9 kgCO2e
  eu-west-1     t2.medium      504h0m0s   3.0 kgCO2e
  eu-west-1     t2.micro       1008h0m0s  2.8 kgCO2e
  eu-west-1     t3.small       2136h0m0s  10.6 kgCO2e
  eu-west-2     m5.xlarge      1512h0m0s  14.5 kgCO2e
  eu-west-2     t3.small       480h0m0s   1.8 kgCO2e

                                 TOTAL      175.4 KGCO2E

What you get as a result

The output table gives you an aggregation of all EC2 instance usage per region and instance type.

In the last column you get the estimated emissions, expressed as an amount (in g for grams, kg for kilograms, or MT for metric tons) of CO2 equivalents.

The last row contains the sum total of emissions.

In our example above, we see that the input report covers usage from 1st to 18th of August 2022. We see that instances of several types have been run in three different regions.

In order to be able to interpret the result, please read the blog post linked below under Acknowledhememnts. Here is a summary of things to consider.

Acknowledgements

This tool is based on a methodology and data provided by Teads Engineering.

Data in the pkg/footprint folder has been published by Teads under the Creative Commons Attribution 4.0 International License.

Teads provides an interactive web UI for creating estimates along the same lines.

Detail information regarding the methodology can be found in a blog post.