Skip to main content Link Search Menu Expand Document (external link)

🌱 EcoInfra CLI Reference

Sustainable Infrastructure Analysis

The EcoInfra CLI helps you analyze your Infrastructure-as-Code (IaC) plans and estimate the carbon footprint of your cloud deployments.

🚀 Installation

📦 Pre-built Binaries

Download the latest release for your platform:

GitHub Releases

🔧 Build from Source

For the latest features and development:

git clone git@github.com:eco-infra/ecoinfra.git
npm install
npm run package

⚡ Getting Started

1 Generate Terraform JSON File

Choose one of the following options:

📋 For Plan Analysis (Future Changes)

terraform plan -out=plan.out
terraform show -json plan.out > plan.json

🏗️ For State Analysis (Current Infrastructure)

terraform show -json > state.json

2 Get Your API Token

Log in at eco-infra.com, go to your profile, and create an API key.

3 Run the CLI Analysis

Execute the EcoInfra CLI with your JSON file:

For Plan Analysis:

./ecoinfra-PLATFORM --token <YOUR_TOKEN> --project-name "<PROJECT_NAME>" --file plan.json

For State Analysis:

./ecoinfra-PLATFORM --token <YOUR_TOKEN> --project-name "<PROJECT_NAME>" --file state.json

📝 Usage

Command Syntax

ecoinfra --token <API_TOKEN> --project-name <PROJECT_NAME> --file <TERRAFORM_JSON_FILE> [options]

The tool automatically detects whether the file is a Terraform plan or state JSON and processes it accordingly.

Required Options

--token

Your EcoInfra API key

--project-name

A unique name for your project

--file

Path to Terraform JSON file (plan or state - auto-detected)

Optional Flags

--breakdown

Show detailed resource-by-resource emissions breakdown

--apply

Mark this run as an applied deployment

Legacy Options (Deprecated)

--plan-file Use --file instead
--state-file Use --file instead

💡 Examples

Plan Analysis (Future Changes)

ecoinfra --token c3dc55b6-78a0-43ad-2513-a751e76553de \
  --project-name "Production Account" \
  --file plan.json

Analyzes the carbon impact of planned infrastructure changes before applying them. File type is auto-detected.

State Analysis (Current Infrastructure)

ecoinfra --token c3dc55b6-78a0-43ad-2513-a751e76553de \
  --project-name "Production Account" \
  --file state.json

Analyzes the carbon footprint of your currently deployed infrastructure. File type is auto-detected.

Detailed Breakdown

ecoinfra --token c3dc55b6-78a0-43ad-2513-a751e76553de \
  --project-name "Production Account" \
  --file terraform.json \
  --breakdown

Includes resource-by-resource emissions data for detailed analysis. Works with both plan and state files automatically.

🛠️ CI/CD Integration

Integrate EcoInfra into your continuous integration pipelines to automatically track the carbon impact of infrastructure changes.

GitHub Actions Example

- name: Eco-Infra Carbon Analysis
  uses: ecoinfra/ecoinfra-action@v1.1.2
  with:
    token: $
    project-name: 'my-project'
    plan-file: './terraform/plan.json'

💡 Pro Tip

Set up branch protection rules to require carbon impact analysis before merging infrastructure changes. This helps maintain awareness of environmental impact across your team.