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
90 stars 84 forks source link

Actions.py check_alarm_tag error in call ec2_client.describe_instances #35

Closed mpechner-akasa closed 1 year ago

mpechner-akasa commented 1 year ago

You are missing the "tag:" as part of the filer name. instance = ec2_client.describe_instances( Filters=[ { 'Name': 'tag:tag-key', 'Values': [ tag_key ] } ], InstanceIds=[ instance_id ]

    )
knizami commented 1 year ago

Hi Michael, thanks for opening this issue. However I believe this code is correct. This code is using the 'tag-key' search where we are only verifying that that Create_Auto_Alarms. tag is present and the value isn't important. In order to activate the solution, you only need to have this tag key present. You can change the default activation tag key by setting the ALARM_TAG environment variable.

Per boto3 documentation for describe_instances:

tag-key - The key of a tag assigned to the resource. Use this filter to find all resources that have a tag with a specific key, regardless of the tag value.

mpechner-akasa commented 1 year ago

yes, sorry about that. Closed my PR