Extract publish_ami into a class