Hamblett Consultancy
Setting up GSuite GMail Custom Domains With AWS Route53 hero image

BLOG ARTICLE

Setting up GSuite GMail Custom Domains With AWS Route53

How to Set Up G Suite Gmail for Custom Domains with AWS Route 53 Setting up a custom email domain can elevate your small business or startup by providing a professional touch to your communi...

2 June 2021

How to Set Up G Suite Gmail for Custom Domains with AWS Route 53

Setting up a custom email domain can elevate your small business or startup by providing a professional touch to your communications. This guide will walk you through setting up G Suite (now Google Workspace) Gmail using AWS Route 53, which handles your domain’s DNS management. While the process is straightforward, there are a few pitfalls that aren’t well-documented. This guide will help you avoid them and ensure a smooth setup.

The free, official “Check MX” tool will help you debug these issues, and you should use it, but it doesn’t have Route53 specific instructions.

Step 1: Log in to AWS and Access Route 53

Log in to your AWS management console and find the “Route 53” (direct link) product, which is Amazon’s nonsense name for DNS management. Then click on hosted zones.

UK IT Consultancy Services - Hamblett Consultancy LtdUK IT Consultancy Services – Hamblett Consultancy LtdNationwide Remote IT Support Services - Hamblett Consultancy LtdNationwide Remote IT Support Services – Hamblett Consultancy Ltd

Step 2: Create the MX records for Gsuite

If you don’t have a domain name here, then your DNS isn’t managed by AWS, and this article is not right for you!

First the easy part:

  • Click on your domain
  • Then click “Go to Record Sets”
  • Then click “Create Record Set”
  • Leave the name blank
  • Change the type to “MX – Mail Exchange”

Change the TTL field to 3600.

Then in the “value” field, paste in exactly (this is the same for everyone):

1 ASPMX.L.GOOGLE.COM 5 ALT1.ASPMX.L.GOOGLE.COM 5 ALT2.ASPMX.L.GOOGLE.COM 10 ALT3.ASPMX.L.GOOGLE.COM 10 ALT4.ASPMX.L.GOOGLE.COM

Note: these values come from the official documentation, formatted here for Route53’s syntax. If you want, you can verify the hosts. They aren’t likely to change.

Step 3: You’re Done! Unless…

This is the basic setep you need to send emails with DNS in Route53. However, Google suggests you verify your domain with some more security steps. The previously mentioned “Check MX” tool will complain if you stop here. You should verify your bananas!

Step 4: Add a “SPF” text entry

Create a new TXT entry with no name:

For the value, paste in exactly (with quotes):

"v=spf1 include:_spf.google.com ~all"

Then click “Create”. I don’t know or care what this is, but it’s documented here if you’re curious.

If you already have a TXT record with no name and Route53 errors, then put the above line in the existing TXT record, with quotes, on a new line, and save it.

Step 5: Create the “domain key” / DKIM record

Google’s tools and interface are often nightmarish and poorly documented, so I’m including some screenshots.

Log in to your Google Suite admin console using your Google Suite admin account: https://admin.google.com/.

Navigate the maze: Apps > G Suite > Gmail > Authenticate Email.

Now click “Generate new record”. Don’t click anything else yet.

Back in Route53, create a new, named TXT record. For the name, paste in the name from your generated record in GSuite. It’s probably “google._domainkey“. Change the type to “TXT – Text”:

Now for the tricky part. Google tells you to paste in the whole TXT record value from GSuite admin, but if you do, you’ll get the error:

Copy to ClipboardSyntax HighlighterCharacterStringTooLong (Value is too long) encountered with '"v=DKIM1;...

The solution to this is to chop up your value into multiple quoted strings (not new lines), with a maximum of 255 characters in each string, and a space between each chunk. It doesn’t have to be equal chopping.

For example, if your value looks something like:

Copy to ClipboardSyntax Highlighter"v=DKIM1; k=rsa; p=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc"

You can chop it up at arbitrary places:

Copy to ClipboardSyntax Highlighter"v=DKIM1; k=rsa; p=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab" "cdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc"

Note those are single spaces, not newlines, between each chunk!

Paste the chopped up value (including all quote marks on all lines) into the value and create your TXT record.

Then, when Google gets off its lazy behind and fetches your new DNS records, you can click the “START AUTHENTICATION” button on the GSuite admin page. It should be pretty fast, and you can tell it has started when you see:

Don’t worry if it complains about your DNS not updating, you can click “START AUTHENTICATION” as many times as you want!

Troubleshooting

The Check MX tool usually gives good output and instructions. If you want to verify you set up your TXT and MX records correctly, you can try this from the command line.

Verify the domain SPF:

Copy to ClipboardSyntax Highlighter$ dig -t TXT yourdomain.com ;; QUESTION SECTION: ;yourdomian.com. IN TXT ;; ANSWER SECTION: yourdomian.com. 300 IN TXT "v=spf1 include:_spf.google.com ~all"

Verify the domain key (if you named it, replace _domainkey):

Copy to ClipboardSyntax Highlighter$ dig -t TXT google._domainkey.yourdomain.com ;; QUESTION SECTION: ;yourdomian.com. IN TXT ;; ANSWER SECTION: google._domainkey.yourdomain.com. 300 IN TXT "v=DKIM1\; k=rsa\; p=...

Summary

By following these steps, you’ll successfully send emails using your custom domain through G Suite, with DNS hosted on AWS Route 53. If you encounter issues or need further assistance, don’t hesitate to contact us for support. Your professional email setup is just the beginning of streamlined and elevated business communications!