This an interesting idea, but I'd be skeptical of having this much coupling between application code and infrastructure. It's like an anti-12 Factor App.
It might make sense for something like a "serverless" app where the units of the business logic are intended to map directly onto cloud provider entities.
It reminds me of https://aws.github.io/chalice/ but cloud-agnostic and Typescript in place of Python
replies(1):