The short answer to this is to have two versions of the same component (i.e. two implementations, which both share the same interface).
The development environment would look like this:
The production systems would look like this:
As you see, the development version only uses direct function calls. The profile and the user components only contains pure business logic and are not aware of the underlying technology (like Lambda or REST).
In the production system, we have introduced the user-remote component that implements the user interface. It delegates calls via the network to a separate system which contains user. The user-remote contains all knowledge about the underlying technology (like Lambda or REST) and also contains error handling logic related to the underlying technology.