#!/usr/bin/env bash # Print origin paths, distribution status, and served index hash. # Used by deploy-web.yaml's always() summary. Never fails the job. set -u DISTRIBUTION_ID="${DISTRIBUTION_ID:-}" SITE_URL="${SITE_URL:-}" echo "=== CloudFront live state ===" if [[ -z "${DISTRIBUTION_ID}" ]]; then echo "DISTRIBUTION_ID unset" exit 0 fi aws cloudfront get-distribution --id "${DISTRIBUTION_ID}" --output json | python3 -c ' import json, sys payload = json.load(sys.stdin) dist = payload.get("Distribution") or {} config = dist.get("DistributionConfig") or {} print("status:", dist.get("Status")) for origin in ((config.get("Origins") or {}).get("Items") or []): print("origin %s: origin_path=%r" % (origin.get("Id"), origin.get("OriginPath") or "")) ' echo if [[ -n "${SITE_URL}" ]]; then echo -n "served index sha256: " curl -fsS --max-time 30 "${SITE_URL%/}/" | python3 -c "import hashlib,sys; print(hashlib.sha256(sys.stdin.buffer.read()).hexdigest())" || echo "unreachable" fi