Search code examples
amazon-web-servicesamazon-s3amazon-route53website-hosting

AWS: Linking static website to domain name on Route53 of different AWS account


I've been having issues in linking a static website hosted on S3 bucket in one AWS account to a custom domain name regsitered on Route53 on another AWS account. Is it not possible to do such types of linking, where the S3 bucket and the Route53 are on two different AWS accounts? If so, what could be the solution for my case!

Thanks in advance.


Solution

  • An A-record alias is needed at the zone apex (e.g. example.com) but not for subdomains (e.g. www.example.com, because here, you can use a CNAME instead) when hosting a site on S3, and this doesn't work across AWS accounts.

    However... there's one word in your question that leads me to believe the following solution may be useful. The word is "registered."

    custom domain name regsitered on Route53 on another AWS account

    If the domain is registered by the Route 53 registrar under one AWS account, you can still create a Route 53 hosted zone on a different AWS account -- the one with the bucket -- and then change the authoritative nameservers in the Route 53 console in the first account. This delegates operational control to the second account.

    Create a hosted zone for the domain in account 2 (the same one as the bucket). Make a note of the 4 NS records that Route 53 assigns to the hosted zone. Do not change them. Just note what they are. Configure this hosted zone with the appropriate A record alias pointing to the bucket.

    Then, in account 1 (where you registered the domain) in the Route 53 console, click "Registered Domains."

    Select your domain.

    Choose "add/edit name servers."

    Enter the values for the Route 53 name servers that were assigned by Route 53 for the new hosted zone in account 2.

    Wait a few minutes.

    Test.

    It will probably take at least 15 minutes for this to start working (it can theoretically take 48 hours but this is very unlikely), and after this, you can remove the hosted zone from account 1. Its configuration is ignored, anyway, if you don't.

    Route 53 will continue to bill account 1 for the annual registration, but will bill account 2 for the hosted zone. Neither account will be charged for the DNS queries, but account 2 will be billed $0.00 for them, since the queries are against an alias pointing to S3, and in such cases, queries are free.