Put a large pan of salted water on to boil. Halve the courgettes lengthways and scoop out and discard the core, then slice the courgettes at an angle into small diagonal pieces. Put the spaghetti in the pan of boiling water and cook following pack instructions.
To make the creamy carbonara sauce, put the egg yolks in a bowl, add half of the grated cheese, and mix with a fork. Add up to 3 tbsp water to make the sauce less thick. Season and set aside.
Heat a large frying pan on a medium to high heat and pour in a little olive oil. Fry the courgette slices and thyme leaves with a good grinding of black pepper for a minute or two until the courgette starts to soften, then add the mushrooms. Fry for 2-3 mins until golden and slightly softened. For the last minute of the cooking, add the garlic.
Working quickly, drain the pasta, reserving a little of the cooking water. Toss the pasta in the pan with the courgettes and mushrooms, then remove from the heat and add a ladleful of the reserved cooking water and the egg and cheese sauce. Add the fresh parsley, if using, and the lemon zest and juice, then sprinkle over most of the remaining cheese. Stir everything together quickly to coat the pasta. The egg will cook if the pasta is still hot. If you’re worried about it, put back on the heat for 1 min.
Pour in a little more of the cooking water, if needed. You should have a silky and shiny sauce. Season to taste, then sprinkle with a little more cheese to serve. Eat straight away, as the sauce can become thick and stodgy if left for too long.