Filtering instances by IAM role in boto3?

Is there a way to filter instances by IAM role? Basically I want a script that terminates all the instances that I've launched, but doesn't touch instances launched with other IAM roles.