Using example.com as the input domain, this module will:
- Create a Route53 zone for example.com
- Create a bucket named example.com
- Create a bucket named www.example.com
- Create a Route53 A record example.com for the static website bucket of example.com
- Create a Route53 A record www.example.com for the static website bucket of www.example.com
This is possibly the simplest way of sending traffic from one domain to another using AWS services. The only caveat is that two bucket names needs to be available on AWS S3.
- Put main.tf in a module folder, for example
modules/site-redirect/main.tf
Use module like this within your terraform plan:
module "redirect_example_com" {
source = "modules/site-redirect"
domain = "example.com"
redirect = "https://send.traffic.here.example.com"
# Accepts a provider, if you have multiple defined
providers {
"aws" = "aws"
}
}
Credits and inspiration:
@chorsnell - correct! :) Feel free to add a reference here if you modify the gist to allow this! :)