aws-samples / amazon-cloudwatch-auto-alarms

Automatically create and configure Amazon CloudWatch alarms for EC2 instances, RDS, and AWS Lambda using tags for standard and custom CloudWatch Metrics.
MIT No Attribution
91 stars 85 forks source link

object is not subscriptable with instance_info['Tags'] #13

Open gli68 opened 3 years ago

gli68 commented 3 years ago

Hello - Alarm was not generated in my case as your python scripts ran into errors specially with instance_info: instance_info = check_alarm_tag(instance_id, create_alarm_tag)

instance_info was returned either as bool or NoneType from check_alarm_tag, neither was considered subscriptable in process_alarm_tags(instance_id, instance_info, default_alarms, metric_dimensions_map, sns_topic_arn, cw_namespace, create_default_alarms_flag, alarm_separator)

Below are the errors in Lambda log events (the line numbers may not be the same as in your scripts as I've added some print lines for debugging purpose):

[ERROR] TypeError: 'bool' object is not subscriptable Traceback (most recent call last):   File "/var/task/cw_auto_alarms.py", line 149, in lambda_handler     process_alarm_tags(instance_id, instance_info, default_alarms, metric_dimensions_map, sns_topic_arn,   File "/var/task/actions.py", line 190, in process_alarm_tags     tags = instance_info['Tags']

'NoneType' object is not subscriptable: TypeError Traceback (most recent call last): File "/var/task/cw_auto_alarms.py", line 158, in lambda_handler cw_namespace, create_default_alarms_flag, alarm_separator) File "/var/task/actions.py", line 190, in process_alarm_tags tags = instance_info['Tags'] TypeError: 'NoneType' object is not subscriptable

I tried both Python 3.6 and 3.8. Why am I getting the above errors and how to resolve? Thanks!