It looks like it should work like this, but I get 0 every time.
onready var sun = get_node("SunLight")
func _ready():
print(RID(sun).get_id())
Otherwise, you can use the visual sever to create the light.
var light_rid = VisualServer.directional_light_create()
But this seems odd.