agent: |
Lu9BiCTB0klqNB47oBmBGet All AWS Route53 Health Checks
Get All AWS Route53 Health Checks
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
This task retrieves a list of all health checks that have been configured in Amazon's Route53 service. AWS Route53 is a scalable and highly available domain name system (DNS) web service. A health check in Route53 monitors the health and performance of your web applications, web servers, and other resources. By fetching all health checks, users can review, manage, or diagnose the operational status and configuration of their resources, ensuring that the routing policies are working as expected. This can be especially useful for maintaining high availability and redundancy in distributed systems or for troubleshooting issues related to DNS routing.
inputs
outputs
import boto3
creds = _get_creds(cred_label)['creds']
access_key = creds['username']
secret_key = creds['password']
# Initialize boto3 client for Amazon Route53
route53 = boto3.client('route53',aws_access_key_id=access_key,aws_secret_access_key=secret_key)
def get_all_healthchecks():
"""
Retrieve all health checks from Route53.
Returns:
- list: List of health check IDs.
"""
healthchecks = []
try:
# Using paginator to handle potential pagination of results
paginator = route53.get_paginator('list_health_checks')
for page in paginator.paginate():
for healthcheck in page['HealthChecks']:
healthchecks.append(healthcheck['Id'])
except route53.exceptions.Route53ServiceError as e:
print(f"Route53 service error fetching health checks: {e}")
except Exception as e:
print(f"Error fetching health checks: {e}")
finally:
return healthchecks
#Main Block
print("Fetching all health checks...")
all_healthchecks = get_all_healthchecks()
print(f"Found {len(all_healthchecks)} health checks.")
for hc in all_healthchecks:
print(hc)
copied