Skip to content

cu-cit-cloud-team/aws-credit-automation

 
 

Repository files navigation

AWS Credit Automation

Collects credit information across all AWS accounts from your AWS Identity Center (SSO) portal using browser automation.

Prerequisites

  • Devcontainer
  • Google Chrome on the Devcontainer host

Configuration

The script uses the AWSAdministratorAccess permission set by default. If your accounts use a different permission set, set the TARGET_ROLE environment variable in the devcontainer.json file to the name of the permission set you want to target (e.g. sso-admin).

Usage

1. Launch Chrome with remote debugging on your devcontainer host

Linux:

google-chrome --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 --user-data-dir=/tmp/chrome-debug-profile

macOS:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 --user-data-dir=/tmp/chrome-debug-profile

Windows (PowerShell):

& "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 --user-data-dir=$env:TEMP\chrome-debug-profile

2. Log into AWS Identity Center

In the Chrome window that opens, navigate to your AWS Identity Center portal (e.g. https://d-xxxxxxxxxx.awsapps.com/start) and log in.

3. Open the devcontainer for the project

4. In the devcontainer terminal, run the script

python collect_credits.py

Output

  • A formatted report is printed to the terminal
  • A credits_report.json file is saved with structured results per account, including status (ok, or an error reason) and any credits found

Exporting Credits to CSV / Excel

Use convert_credits.py to convert credits_report.json into a flat CSV and/or Excel file. Accounts with multiple credits are expanded so each credit occupies its own row. Accounts with no credits are included as a single row with blank credit columns.

Install dependencies

pip install -r requirements.txt

Run the exporter

# Export to both CSV and Excel (default)
python convert_credits.py

# Export to CSV only
python convert_credits.py --format csv

# Export to Excel only
python convert_credits.py --format excel

# Specify a custom input file and output name (no extension)
python convert_credits.py my_report.json --format both --output my_output

Output columns

Column Description
account_name AWS account name
account_id 12-digit AWS account ID
status Scrape status (ok, error message, etc.)
credit_name Name of the AWS credit
amount_issued Total amount originally issued
expiration_date Credit expiration date
amount_used Amount consumed so far
amount_remaining Remaining balance

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%