DEV Community

Ace7-coder
Ace7-coder

Posted on

AWS FinOps Field Notes: Purging Incomplete S3 Multipart Uploads Before They Snowball

While auditing cloud infrastructure costs this week, recurring configuration gaps continue to quietly inflate monthly bills.

Field Insight: The Hidden Cost Trap

Failed or aborted multi-gigabyte S3 uploads leave hidden part fragments billed at full S3 Standard rates indefinitely unless an AbortIncompleteMultipartUpload lifecycle rule is enforced.

Automated Detection: Auditing S3 Buckets Missing Multipart Abort Rules with Boto3

import boto3
from botocore.exceptions import ClientError

def audit_s3_multipart_rules(region='us-east-1'):
    s3 = boto3.client('s3', region_name=region)
    buckets = s3.list_buckets().get('Buckets', [])
    unprotected = []
    for b in buckets:
        name = b['Name']
        try:
            rules = s3.get_bucket_lifecycle_configuration(Bucket=name).get('Rules', [])
        except ClientError as e:
            if e.response['Error']['Code'] == 'NoSuchLifecycleConfiguration':
                rules = []
            else:
                raise
        has_abort = any(
            r.get('Status') == 'Enabled' and 'AbortIncompleteMultipartUpload' in r
            for r in rules
        )
        if not has_abort:
            unprotected.append(name)
            print(f'[ALERT] {name}: missing AbortIncompleteMultipartUpload lifecycle rule.')
    print(f'Buckets missing multipart cleanup: {len(unprotected)} of {len(buckets)}')
    return unprotected

if __name__ == '__main__':
    audit_s3_multipart_rules()
Enter fullscreen mode Exit fullscreen mode

Running ad-hoc scripts in a single account or region does not scale across enterprise AWS Organizations. Sustained cloud cost governance requires automated anomaly detection, cross-account STS role assumption, and scheduled auditing.

  • 📦 Install Free Single-Account CLI: pip install aws-finops-auditor (PyPI | GitHub)
  • 💼 Managing Multiple Accounts or Client Infrastructure?
    • Practitioner License ($149/yr): Single-account CLI scanner, compliance exports, and dynamic bash remediation.
    • Consultancy & Agency Pack ($999/yr): Automated multi-account STS role assumption, CloudFormation StackSets, and branded executive PDF showback reports.

👉 Get the AWS Cloud Cost Auditor on Gumroad

Top comments (0)