def _check_if_instance_profile_exists(self, instance_profile_name):
        try:
            # Client call to get the instance profile with that name
            self._iam_client.get_instance_profile(
                InstanceProfileName=instance_profile_name)

        except ClientError as e:
            # If the instance profile does not exist then the error message
            # would contain the required message
            if e.response['Error']['Code'] == 'NoSuchEntity':
                # No instance profile error.
                return False
            else:
                # Some other error. raise.
                raise e

        return True
Method to verify if a particular role exists
dataset/ETHPy150Open aws/aws-cli/awscli/customizations/datapipeline/createdefaultroles.py/CreateDefaultRoles._check_if_instance_profile_exists