aws-alfred-workflow icon indicating copy to clipboard operation
aws-alfred-workflow copied to clipboard

EC2 instance lookup "State:running" filter isn't working

Open cybrosis opened this issue 7 years ago • 2 comments

When I do a lookup on my existing ec2 instances by name after a re-deployment, the results list includes the terminated instances and the new running instances. As a result I have to quick look into each one to determine which one is running and which one is not.

As a quick fix I edited find_ec2() in aws.py to include the instance state in the results returned to alfred:

title = '%s (%s) (%s)' % (instance['Tag:Name'], instance['InstanceId'], instance['State']['Name'])

however, I would like to see terminated instances filtered out, or only running instances returned.

What do you think?

cybrosis avatar Dec 11 '17 21:12 cybrosis

That probably makes a whole lot of sense.

You should be able to change line 17 from:

response = client.describe_instances(MaxResults=1000, **next_token)

to:

response = client.describe_instances(MaxResults=1000, Filters=[{
    'Name': 'instance-state-name',
    'Values': ['running'],
}], **next_token)

twang-rs avatar Dec 11 '17 21:12 twang-rs

Fix implemented in pull request: #12

cybrosis avatar Dec 11 '17 22:12 cybrosis