AWS_tools_for_pricing

Python scripts to export EC2 instance details and OpenSearch domain configurations for cost analysis.

https://github.com/davidbmar/AWS_tools_for_pricing  ·  public  ·  shipped

What it is

A collection of standalone Python utilities that query AWS services (EC2 and OpenSearch) and output structured data (CSV or JSON) to facilitate infrastructure pricing and auditing. It bridges the gap between raw AWS API responses and human-readable reports.

Features

Quickstart

pip install boto3
python ec2_csv_list.py
python opensearch2.py

Architecture

flowchart TD
    User[User] -->|Executes| Script[Python Script]
    Script -->|boto3 SDK| EC2_API[EC2 API]
    Script -->|subprocess| AWS_CLI[AWS CLI]
    AWS_CLI -->|API Call| OS_API[OpenSearch API]
    EC2_API -->|Instance Data| Script
    OS_API -->|Domain Config| AWS_CLI
    AWS_CLI -->|JSON Output| Script
    Script -->|Writes| CSV[CSV File]

How it's built

The project consists of independent Python scripts. `ec2_csv_list.py` uses the `boto3` SDK to interact with the EC2 API directly. The OpenSearch scripts (`opensearch2.py`) rely on `subprocess` calls to the AWS CLI, parsing the resulting JSON output. Data is serialized into CSV files for easy import into spreadsheet software.

How it runs

sequenceDiagram
    participant U as User
    participant S as Python Script
    participant B as Boto3/CLI
    participant A as AWS API
    
    U->>S: Run script
    alt EC2 Mode
        S->>B: Initialize boto3 client
        B->>A: describe_instances()
        A-->>B: Instance Metadata
        B-->>S: Parsed Objects
        S->>S: Format to CSV
        S-->>U: Save running_ec2_instances.csv
    else OpenSearch Mode
        S->>B: subprocess.run(aws opensearch...)
        B->>A: list-domain-names / describe-domain
        A-->>B: JSON Response
        B-->>S: Stdout String
        S->>S: Parse JSON & Extract Details
        S-->>U: Print/Save Domain Data
    end

How to apply & reuse

Use these tools to generate an inventory of running resources. Export EC2 instance types and states to estimate compute costs, or dump OpenSearch cluster configurations to analyze search infrastructure spending. The resulting CSVs can be fed into pricing calculators or internal billing dashboards.

At a glance

CapabilitiesEC2 InventoryOpenSearch AuditingCSV ExportCost Analysis Prep
Componentsec2_csv_list.pyopensearch2.pyboto3 ClientAWS CLI Wrapper
TechPython 3boto3AWS CLICSVJSON
Depends onboto3awsclipython3
Integrates withAmazon EC2Amazon OpenSearch Service
PatternsScriptingCLI AutomationData Extraction
Reuse tagsawspricinginventoryec2opensearchpython

Repo hygiene

✓ all on main — nothing unmerged.