Rework ensure_resource() to work again.