Go step by step.
1. Make buckets, identify standalone code (i.e. the one with no external interfaces including database read-writes) e.g. piece of code doing validations or some calculations.
2. Create a API for this with say AWS lambda functions or like.
3. Replace the old code/function with the API.
4. Take next function/piece of code and do it again.
5. In the next phase, involve functions having external interfaces such e.g. the one which is reading the databaes