You have to rewrite application to use something else that's open source and self-hostable.
For new startups, I honestly recommend using DigitalOcean or Vultur. You don't get all the AWS components, but you can build around flexibility. If you have to move, you can take all your Terraform and Anisble scripts, and port them to a new provider (and yes, you do have to rewrite your Terraform config. Every provider is insanely different and the magic of multi-cloud is a myth, but it's still easier than trying to move off of AWS specific services).
I remember back in the day, Stackoverflow ran everything off of a single, very expensive, dedicated server. I've worked at other shops where we've migrated stuff from AWS to self hosted solutions to reduce our $200k/month AWS bill.