diff options
author | Christian Cleberg <hello@cleberg.net> | 2025-06-20 13:55:54 -0500 |
---|---|---|
committer | Christian Cleberg <hello@cleberg.net> | 2025-06-20 13:55:54 -0500 |
commit | 785f42901f34aaf356f316c691e3f56138c8608d (patch) | |
tree | 5b8f7a6e33a6af410e511137fdd51b6fa60d0f83 /sections/cloudfront.py | |
download | aws-summary-report-785f42901f34aaf356f316c691e3f56138c8608d.tar.gz aws-summary-report-785f42901f34aaf356f316c691e3f56138c8608d.tar.bz2 aws-summary-report-785f42901f34aaf356f316c691e3f56138c8608d.zip |
initial commit
Diffstat (limited to 'sections/cloudfront.py')
-rw-r--r-- | sections/cloudfront.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sections/cloudfront.py b/sections/cloudfront.py new file mode 100644 index 0000000..df161e6 --- /dev/null +++ b/sections/cloudfront.py @@ -0,0 +1,37 @@ +# cloudfront.py +import boto3 +from datetime import datetime, timedelta, timezone +from tabulate import tabulate + + +def get_section(config): + profile = config["aws"].get("profile") + session = boto3.Session(profile_name=profile if profile else None) + client = session.client("cloudfront") + + now = datetime.now(timezone.utc) + cutoff = now - timedelta(days=2) + + dists = client.list_distributions().get("DistributionList", {}).get("Items", []) + rows = [] + + for dist in dists: + last_mod = dist["LastModifiedTime"] + if last_mod >= cutoff: + rows.append( + [dist["Id"], dist["DomainName"], last_mod.strftime("%Y-%m-%d %H:%M")] + ) + + if not rows: + return "CloudFront Changes:\nNo distributions changed in the last 48h." + + table = tabulate( + rows, headers=["ID", "Domain", "Last Modified"], tablefmt="simple_grid" + ) + lines = [ + "CloudFront Distribution Changes (Last 48h):", + f"[https://{config['aws'].get('region')}.console.aws.amazon.com/cloudfront/v4/home#/distributions]", + table, + ] + + return "\n".join(lines) |