import boto3
client = boto3.client('elbv2')
response = client.describe_target_health(
TargetGroupArn='string'
)
for i in response['TargetHealthDescriptions']:
print(i['TargetHealth']['State'])
-----------------------------------------------
healthy
. 비정상일 경우 : 'unhealthy', 'unused'
print(i['TargetHealth']['State'],i['TargetHealth']['Description'])
------------------------------------------------------------------
unhealthy Health checks failed
print(i['TargetHealth']['State'],i['TargetHealth']['Description'])
------------------------------------------------------------------
unused Target is in the stopped state
위와 같이 'State' 에서 상태 값으로 조건 테스트 후 ['Target']['Id'] 를 통하여 2차적인 액션을 취하면 될 것이다.
'AWS Infra' 카테고리의 다른 글
[ AWS ] Python boto3를 이용한 EC2 Instance 정보 구하기 (0) | 2023.05.22 |
---|---|
[ AWS ] Python boto3를 이용하여 WAF IPset IP 수정하기 (0) | 2023.05.16 |
[ AWS ] Python boto3를 이용하여 RDS Connections 데이터 추출 하기 (0) | 2023.05.11 |
[ AWS ] Python boto3를 이용하여 ELB Metric 모니터링 (0) | 2023.05.10 |
[ AWS ] Python boto3를 이용하여 S3 object 스토리지 클래스 변경 (0) | 2023.03.21 |
[ AWS ] Python boto3를 이용하여 s3 log 압축파일(gz) DataFrame 만들기 - CloudFront Logs (0) | 2023.03.16 |
[ Python ] Python을 이용한 ElastiCache Redis Hash Data Export & Import (0) | 2023.02.28 |
[ AWS ] Python boto3를 이용하여 값 CPUCreditBalance 구하기 (0) | 2023.02.02 |