diff options
Diffstat (limited to 'sections/route53.py')
-rw-r--r-- | sections/route53.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sections/route53.py b/sections/route53.py new file mode 100644 index 0000000..d2da7cf --- /dev/null +++ b/sections/route53.py @@ -0,0 +1,40 @@ +# route53.py +import boto3 +from tabulate import tabulate + + +def get_section(config): + profile = config["aws"].get("profile") + region = config["aws"]["region"] # Not used by Route53, but kept for consistency + + session = boto3.Session(profile_name=profile if profile else None) + client = session.client("route53") + + health_checks = client.list_health_checks()["HealthChecks"] + rows = [] + + for hc in health_checks: + hc_id = hc["Id"] + name = hc.get("HealthCheckConfig", {}).get( + "FullyQualifiedDomainName", "Unnamed" + ) + status = client.get_health_check_status(HealthCheckId=hc_id) + status_summary = status["HealthCheckObservations"] + healthy = all( + obs["StatusReport"]["Status"].startswith("Success") + for obs in status_summary + ) + state = "HEALTHY" if healthy else "UNHEALTHY" + rows.append([name, state]) + + if not rows: + return "Route 53 Health Checks:\nNo health checks configured." + + table = tabulate(rows, headers=["Domain", "Status"], tablefmt="simple_grid") + lines = [ + "Route 53 Health Checks:", + f"[https://{config['aws'].get('region')}.console.aws.amazon.com/route53/v2/healthchecks/home]", + table, + ] + + return "\n".join(lines) |