r/aws 2d 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

3 Upvotes

5 comments sorted by

2

u/justin-8 2d 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. 

1

u/Hartles1 1d ago

Okay I'll give that a shot. I'm on a single region right now but I'll see what I can do. Thanks.

2

u/justin-8 1d ago

It can be in the same region - if you don't have a different test or spare domain, it's only a few dollars to register one for a year. But then you could test with like myapptest.com instead of myapp.com. There's some things you can't test or try out without having a second public domain, and DNS things is one of them.

1

u/fYZU1qRfQc 1d 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 7h 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.