Skip to content

Instantly share code, notes, and snippets.

View polius's full-sized avatar

Pol Alzina polius

View GitHub Profile
@polius
polius / ec2-volumes-scan.py
Created May 13, 2024 09:19
Generate a CSV file listing all EC2 volumes in an AWS account, along with some cost-saving recommendations.
import csv
import boto3
import numpy as np
import argparse
import threading
from datetime import datetime, timedelta, timezone
class main:
def __init__(self):
# Grab parameters
@polius
polius / rds-snapshots.sh
Last active May 8, 2024 14:27
Extract all AWS RDS manual snapshots from all regions into a CSV file.
account="123456789"
echo "Account, Region, SnapshotCreateTime, DBSnapshotIdentifier, DBInstanceIdentifier, Engine, AllocatedStorage" > "$account.csv"
for region in $(aws ec2 describe-regions --profile customer --query "Regions[].RegionName" --output text); do
echo "Region: $region"
snapshots=$(aws rds describe-db-snapshots --profile customer --region $region --query "DBSnapshots[?SnapshotType=='manual'].[SnapshotCreateTime, DBSnapshotIdentifier, DBInstanceIdentifier, Engine, AllocatedStorage]" --output json)
if [ -n "$snapshots" ]; then
echo "$snapshots" | jq -r --arg account "$account" --arg region "$region" '.[] | "\"\($account)\",\"\($region)\"," + @csv' >> "$account.csv"
fi
done
@polius
polius / dynamodb-scan.py
Created February 14, 2024 14:31
A comprehensive tool for analyzing the workload of a DynamoDB table and extracting valuable insights.
# Install dependencies: python3 -m pip install boto3 numpy rich
import json
import boto3
import argparse
import numpy as np
from decimal import Decimal
from datetime import datetime, timedelta
from rich.console import Console
from rich.table import Table
@polius
polius / rds-scan.py
Last active May 23, 2024 15:23
Retrieve the AWS RDS pricing for an Aurora cluster comparing Aurora Standard and Aurora I/O-Optimized modes.
# Install dependencies: python3 -m pip install boto3 rich
import json
import boto3
import argparse
from decimal import Decimal
from datetime import datetime, timedelta, timezone
from rich.console import Console
from rich.table import Table
from rich.tree import Tree