You would:
- Use
describe_auto_scaling_groups()
to obtain a list of Auto Scaling groups
- For each of them, call
describe_policies()
passing in the name of the Auto Scaling group
- Examine the configuration returned and perform your comparisons
Slightly modified version of your code:
import boto3
asg_dict_map = dict()
client = boto3.client('autoscaling')
response = client.describe_auto_scaling_groups()
for asg in response['AutoScalingGroups']:
asg_name = asg['AutoScalingGroupName']
response2 = client.describe_policies(AutoScalingGroupName = asg_name)
for policy in response2['ScalingPolicies']:
policy_name = policy['AutoScalingGroupName']
target_value = policy['TargetTrackingConfiguration']['TargetValue']
asg_dict_map[policy_name] = target_value
print(asg_dict_map)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…