def METHOD_NAME(build_config):
    if build_config.service_role is not None:
        from ebcli.lib.iam import get_roles
        role = build_config.service_role
        validated_role = None
        existing_roles = get_roles()
        for existing_role in existing_roles:
            if role == existing_role['Arn'] or role == existing_role['RoleName']:
                validated_role = existing_role['Arn']
                break
        if validated_role is None:
            LOG.debug("Role '{0}' not found in retrieved list of roles".format(role))
            raise ValidationError("Role '{0}' does not exist.".format(role))
        build_config.service_role = validated_role
    else:
        io.log_warning(
            "To learn more about creating a service role for CodeBuild, see Docs:"
            " https://docs-aws.amazon.com/codebuild/latest/userguide/"
            "setting-up.html#setting-up-service-role"
        )
        raise ValidationError("No service role specified in buildspec; this is a required argument.")
    if build_config.image is None:
        raise ValidationError("No image specified in buildspec; this is a required argument.")