Skip to content

Instantly share code, notes, and snippets.

@asmodeus70
asmodeus70 / cleanup_s3_policy.py
Created February 6, 2020 11:38 — forked from pwilken/cleanup_s3_policy.py
AWS Lambda function for deleting files from S3 bucket, filename contains timestamp. Clean up for everything older then 7 days. Triggered once a week by a CloudWatch Event.
import logging
import boto3
import datetime
from botocore.exceptions import ClientError
def lambda_handler(event, context):
# Set up logging
logging.basicConfig(level=logging.DEBUG,
format='%(levelname)s: %(asctime)s: %(message)s')