Aws-get-p2 gives me terminated instanceIds

Does the aws-get-p2 get the instanceIds of only the stopped instances? The code looks so -
aws ec2 describe-instances --filters "Name=instance-state-name,Values=stopped,Name=instance-type,Values=p2.xlarge

I had issues with my first two p2.xlarge instances that I created and had to terminate them and then I created a third fresh instance. It took quite some time for the two terminated instances to get deleted. So initially my aws console showed two terminated p2.xlarge instances and the new third p2.xlarge instance which was in stopped state. When I executed aws-get-p2, it returned the instanceId of one of the terminated instances. And I realised it when I executed aws-start which didn’t allow me to start that instance (since it was terminated). I had to manually set the instanceId to the newly created instance before using aws-start.

Now my terminated instances are deleted, so I don’t see this issue.
I was just curious to know when I execute aws-get-p2, why would I get the instanceId of an instance whose “Instance State” said “terminated” when the command says “Name=instance-state-name,Values=stopped”? Am I missing anything here?

1 Like