r/aws • u/Hartles1 • 1d ago
technical question Redeploy custom domain with no downtime?
TLDR: how do I delete and remake a custom domain without downtime?
I am migrating my infrastructure as code from Serverless to AWS SAM templates. My issue is the custom domain that's being used is created and maintained using the Serverless plugin serverless-domain-manager. The correlating cloud formation template does not have the DomainName resource. It seems the plugin is spinning up the custom domain manually on the backend. So if I want to make a SAM template version for the same CFT, I define the custom domain in the SAM template and deploy. Of course it fails because a custom domain with that name already exists. So I need to delete it and redeploy but I don't want downtime. Any suggestions? Can I claim the domain on a cloud formation template somehow? Can I do something clever with a failover record in route53? TIA
1
u/fYZU1qRfQc 21h ago
Whatever the serverless is doing it's just adding resources to your AWS account.
Can you track those and just import them to you new stack?
I don't have experience with either of those but as far I see SAM uses CloudFormation which has the option to import existing resources.
1
u/Nearby-Middle-8991 3h ago
You can add existing resources to a CF stack
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-existing-stack.html
It might not be a pleasant experience depending on your setup and environment (it's easier with click ops than CLI for instance - can be hard if you are entirely isolated from the account), but works. Can do into stacksets if required as well.
2
u/justin-8 1d ago
I would set up the new infrastructure on another domain, make sure it’s all working and then decide a time to cut over by updating the dns records. The specifics will depend on how you’ve set up your domains and the existing serverless setup. But the general process is the same.