How to migrate a UniFi Cloud Key and USG to a Cloud Gateway Max (UCG-Max)

I recently migrated my UniFi-based networking setup over to a Cloud Gateway Max (UCG-Max). The whole thing took about an hour, which included a couple of minutes of internet downtime. Despite being a bit anxious about what might go wrong, I found it surprisingly simple.