I have an AWS setup where I have a main AWS account (MainAccount), where I have a public hosted zone for my domain (mydomain.com) and also registered the domain under this account. Then I have a separate AWS account (AppAccount) where I deploy my applications using VPCs and Load balancers. Currently I add a CNAME record that points to the loadbalancer DNS for each app (like app1.mydomain.com, app2.mydomain.com) to be able to reach them.
It is working OK, but I have to switch to the main account to add a new record all the time if I want to set up a new app. I'm looking for a way to be able to set up a new app without doing any modification to the MainAccount (while I still keep the public hosted zone and domain registration on that account).
I've been trying to read up this a bit and I think I found two ways to make it work, but I the whitepapers/examples are quite complicated and I didn't actually make it work, so I'm wondering what I might do wrong and how can it be done properly.
One way I tried is:
Add a public hosted zone to the AppAccount like app1.mydomain.com
Add an aliased A record under this hosted zone that points to my app's load balancer DNS
(repeat both steps for every new app)
This way I'm not able to reach the app from the internet
Another way is:
Add a private hosted zone to AppAccount like mydomain.com (I believe this is the concept of domain overlapping in AWS)
Add an A or CNAME record for the app's load balancer DNS
(repeat last step for each new app)
I also didn't managed to make this work
How can I achieve a similar setup that works?
PS: I'm using AWS CLI to set up the apps