AWS SDK

AWS SDK Automation

Python boto3 scripts for EC2 snapshots, S3 lifecycle, and IAM auditing.

Pythonboto3EC2S3IAM

A collection of Python automation scripts using boto3 to handle common AWS operational tasks: scheduled EC2 volume snapshots with retention, S3 intelligent-tiering lifecycle policy deployment, and IAM role auditing to surface unused permissions.

Updated 1 February 2026 Awssdk

Tech Stack

Python3.12
boto3~> 1.34
AWS LambdaScheduled execution

Features

  • EC2 snapshot scheduler with configurable retention window
  • S3 lifecycle rule deployment across multiple buckets
  • IAM role last-used audit with CSV export
  • Dry-run mode for all destructive operations
  • SNS alerts on snapshot failure or IAM anomaly

EC2 Snapshot Scheduler

The snapshot Lambda runs on an EventBridge schedule (default: daily at 02:00 UTC). It snapshots all volumes tagged `Backup=true`, applies a Name tag with the date, and deletes snapshots older than the configured retention window (default 14 days).

IAM Audit

The audit script iterates all IAM roles and checks the `LastUsedDate` field. Roles not used within the threshold (default 90 days) are listed in a CSV report and optionally tagged for decommission review.

Configuration

All scripts read configuration from environment variables or a `config.yaml` file. Deploy to Lambda using the included SAM template, or run locally with `python snapshot.py --dry-run` after configuring AWS credentials.

File Structure

  • src/
    • snapshot.py
    • s3_lifecycle.py
    • iam_audit.py
    • utils.py
  • sam/
    • template.yaml
  • tests/
    • test_snapshot.py
    • test_iam_audit.py
  • config.yaml
  • requirements.txt
  • .gitlab-ci.yml
  • README.md
GitLab (coming soon)