Hello everyone, I’ve recently fell in love with CDK and have had more and more exposure to infra/ devops work. But what I cannot for the love of me figure out is how what to do with domains, (this is my own startup that I’ll be talking about)
We have several moving parts, some of which should have their own domain, and alongside that, we also have several environments. So ideally I’d love to have `staging-analytics.company.com` or some variation of that. But what I found to be cumbersome is the following, 1) having stuff related to acm or route53 seems to be tricky in CDK since it can sometimes hang indefinitely until something is propagated or if something is misconfigured, and 2), we use the company emails for AWS accounts, so I cannot move the domain to AWS or there’s a risk of getting locked out of our accounts.
So with all of this in mind, how is this usually approached? I would love to have the domains be handled via the cdk as well, as I love having everything in code
There are some things that need to be handled imperatively, for which the SDK is better suited. If you want to create a certificate with ACM, for example, you could use the RequestCertificateCommand, and you would also need to validate the domain through your registrar’s DNS settings.
If you are willing to add one more degree of subdomain (i.e. analytics.staging.companyname.com) what you can do is domain delegation from your registar for the subdomain staging.companyname.com to Route53 and at that point all the automated DNS validation constructs can be used. Then for certain prod ones such as the public facing site you can do a manual delegation or write a one off script.
I use cdk for Terraform instead. My domain is on Cloudflare and it has a Terraform provider to manage it. Also Terraform works faster and more reliable than cloudformation.
Wildcard certificate for each env like *.dev.company.com, set the ARN of the certificate as an SSM variable or in cdk.json, import and use. Route53 shouldn’t have any additional complications. You can manage that shared certificate in its own stack, via clickops, or however you like.