The automated replace function for cloudfront (and likely other services) takes far too long for flask - the page load will time out before the waiter for the distribution is complete. The waiter works, and the new distribution is created, but it's not getting the info on the new URL back to flask.
Probably the best strategy is to split off a separate process that will wait, then populate github and database with new URL, and have the main process simply go back with a flashed message about "new distribution creation is in process" or some such.