How to Create Route 53 Records from AWS Cross-Accounts with Terraform
Over the last few weeks, I wrote a couple of stories on how to use Terraform to create internal and external load balancers and use ACM to create SSL certificates and write records in Route 53 (see below).
- How to Deploy EC2 Instances with an Internal Load Balancer, and ACM SSL Certificate in AWS with Terraform
- How to Deploy EC2 Instances in Multiple AZs, with a Load Balancer, and SSL Certificate in AWS with Terraform
However, these two examples work only when we have the Route 53 public hosted zone in the same AWS account.
In this story, we will learn how to create records in a Route 53 Hosted Zone located on a different AWS account (usually called cross-account).
This story can be used as a reference to implement multi-account solutions in AWS with Terraform or share Route 53 domains across multiple AWS Accounts.
Note: There are several ways to do this, however, I found this way the simplest one to implement.
Defining Multiple AWS Accounts in the Provider File
A typical provider file should look like this:
# Terraform Provider
terraform {
required_providers {
aws = {
source =…